blob: 0277a5ac5081bd3149816d6868ce1081454da02b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
<?php
namespace Elastica\Suggest\CandidateGenerator;
/**
* Class DirectGenerator
* @package Elastica\Suggest\Phrase
* @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html#_direct_generators
*/
class DirectGenerator extends AbstractCandidateGenerator
{
const SUGGEST_MODE_MISSING = 'missing';
const SUGGEST_MODE_POPULAR = 'popular';
const SUGGEST_MODE_ALWAYS = 'always';
/**
* @param string $field
*/
public function __construct($field)
{
$this->setField($field);
}
/**
* Set the field name from which to fetch candidate suggestions
* @param string $field
* @return DirectGenerator
*/
public function setField($field)
{
return $this->setParam("field", $field);
}
/**
* Set the maximum corrections to be returned per suggest text token
* @param int $size
* @return DirectGenerator
*/
public function setSize($size)
{
return $this->setParam("size", $size);
}
/**
* @param string $mode see SUGGEST_MODE_* constants for options
* @return DirectGenerator
*/
public function setSuggestMode($mode)
{
return $this->setParam("suggest_mode", $mode);
}
/**
* @param int $max can only be a value between 1 and 2. Defaults to 2.
* @return DirectGenerator
*/
public function setMaxEdits($max)
{
return $this->setParam("max_edits", $max);
}
/**
* @param int $length defaults to 1
* @return DirectGenerator
*/
public function setPrefixLength($length)
{
return $this->setParam("prefix_len", $length);
}
/**
* @param int $min defaults to 4
* @return DirectGenerator
*/
public function setMinWordLength($min)
{
return $this->setParam("min_word_len", $min);
}
/**
* @param int $max
* @return DirectGenerator
*/
public function setMaxInspections($max)
{
return $this->setParam("max_inspections", $max);
}
/**
* @param float $min
* @return DirectGenerator
*/
public function setMinDocFrequency($min)
{
return $this->setParam("min_doc_freq", $min);
}
/**
* @param float $max
* @return DirectGenerator
*/
public function setMaxTermFrequency($max)
{
return $this->setParam("max_term_freq", $max);
}
/**
* Set an analyzer to be applied to the original token prior to candidate generation
* @param string $pre an analyzer
* @return DirectGenerator
*/
public function setPreFilter($pre)
{
return $this->setParam("pre_filter", $pre);
}
/**
* Set an analyzer to be applied to generated tokens before they are passed to the phrase scorer
* @param string $post
* @return DirectGenerator
*/
public function setPostFilter($post)
{
return $this->setParam("post_filter", $post);
}
}
|