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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
<?php
namespace Elastica\Query;
/**
* More Like This query
*
* @category Xodoa
* @package Elastica
* @author Raul Martinez, Jr <juneym@gmail.com>
* @link http://www.elasticsearch.org/guide/reference/query-dsl/mlt-query.html
*/
class MoreLikeThis extends AbstractQuery
{
/**
* Adds field to mlt query
*
* @param array $fields Field names
* @return \Elastica\Query\MoreLikeThis Current object
*/
public function setFields(array $fields)
{
return $this->setParam('fields', $fields);
}
/**
* Set the "like_text" value
*
* @param string $likeText
* @return \Elastica\Query\MoreLikeThis This current object
*/
public function setLikeText($likeText)
{
$likeText = trim($likeText);
return $this->setParam('like_text', $likeText);
}
/**
* Set boost
*
* @param float $boost Boost value
* @return \Elastica\Query\MoreLikeThis Query object
*/
public function setBoost($boost)
{
return $this->setParam('boost', (float) $boost);
}
/**
* Set max_query_terms
*
* @param int $maxQueryTerms Max query terms value
* @return \Elastica\Query\MoreLikeThis
*/
public function setMaxQueryTerms($maxQueryTerms)
{
return $this->setParam('max_query_terms', (int) $maxQueryTerms);
}
/**
* Set percent terms to match
*
* @param float $percentTermsToMatch Percentage
* @return \Elastica\Query\MoreLikeThis
*/
public function setPercentTermsToMatch($percentTermsToMatch)
{
return $this->setParam('percent_terms_to_match', (float) $percentTermsToMatch);
}
/**
* Set min term frequency
*
* @param int $minTermFreq
* @return \Elastica\Query\MoreLikeThis
*/
public function setMinTermFrequency($minTermFreq)
{
return $this->setParam('min_term_freq', (int) $minTermFreq);
}
/**
* set min document frequency
*
* @param int $minDocFreq
* @return \Elastica\Query\MoreLikeThis
*/
public function setMinDocFrequency($minDocFreq)
{
return $this->setParam('min_doc_freq', (int) $minDocFreq);
}
/**
* set max document frequency
*
* @param int $maxDocFreq
* @return \Elastica\Query\MoreLikeThis
*/
public function setMaxDocFrequency($maxDocFreq)
{
return $this->setParam('max_doc_freq', (int) $maxDocFreq);
}
/**
* Set min word length
*
* @param int $minWordLength
* @return \Elastica\Query\MoreLikeThis
*/
public function setMinWordLength($minWordLength)
{
return $this->setParam('min_word_length', (int) $minWordLength);
}
/**
* Set max word length
*
* @param int $maxWordLength
* @return \Elastica\Query\MoreLikeThis
*/
public function setMaxWordLength($maxWordLength)
{
return $this->setParam('max_word_length', (int) $maxWordLength);
}
/**
* Set boost terms
*
* @param bool $boostTerms
* @return \Elastica\Query\MoreLikeThis
* @link http://www.elasticsearch.org/guide/reference/query-dsl/mlt-query.html
*/
public function setBoostTerms($boostTerms)
{
return $this->setParam('boost_terms', (bool) $boostTerms);
}
/**
* Set analyzer
*
* @param string $analyzer
* @return \Elastica\Query\MoreLikeThis
*/
public function setAnalyzer($analyzer)
{
$analyzer = trim($analyzer);
return $this->setParam('analyzer', $analyzer);
}
/**
* Set stop words
*
* @param array $stopWords
* @return \Elastica\Query\MoreLikeThis
*/
public function setStopWords(array $stopWords)
{
return $this->setParam('stop_words', $stopWords);
}
}
|