|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PSolr\Request; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThis |
|
7
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThisHandler |
|
8
|
|
|
*/ |
|
9
|
|
|
class MoreLikeThis extends Select implements ComponentInterface |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var string |
|
13
|
|
|
*/ |
|
14
|
|
|
protected $handlerName = 'mlt'; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* $var string |
|
18
|
|
|
*/ |
|
19
|
|
|
protected $responseClass = '\PSolr\Response\Response'; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* {@inheritDoc} |
|
23
|
|
|
*/ |
|
24
|
|
|
public function preMergeParams(SolrRequest $request) {} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* {@inheritDoc} |
|
28
|
|
|
*/ |
|
29
|
|
|
public function init() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->mlt(); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param bool $mlt |
|
36
|
|
|
* |
|
37
|
|
|
* @return \PSolr\Request\MoreLikeThis |
|
38
|
|
|
* |
|
39
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThis#MoreLikeThisComponent |
|
40
|
|
|
*/ |
|
41
|
|
|
public function mlt($mlt = true) |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->set('mlt', (bool) $mlt); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param bool $count |
|
48
|
|
|
* |
|
49
|
|
|
* @return \PSolr\Request\MoreLikeThis |
|
50
|
|
|
* |
|
51
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThis#MoreLikeThisComponent |
|
52
|
|
|
*/ |
|
53
|
|
|
public function setCount($count) |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->set('mlt.count', (int) $count); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param string|array $fields |
|
60
|
|
|
* |
|
61
|
|
|
* @return \PSolr\Request\MoreLikeThis |
|
62
|
|
|
* |
|
63
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThis#Common_Parameters |
|
64
|
|
|
*/ |
|
65
|
|
|
public function setSimilarityFields($fields) |
|
66
|
|
|
{ |
|
67
|
|
|
return $this->set('mlt.fl', join(',', (array) $fields)); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @param int $min |
|
72
|
|
|
* |
|
73
|
|
|
* @return \PSolr\Request\MoreLikeThis |
|
74
|
|
|
* |
|
75
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThis#Common_Parameters |
|
76
|
|
|
*/ |
|
77
|
|
|
public function setMinimumTermFrequency($min) |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->set('mlt.mintf', $min); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @param int $min |
|
84
|
|
|
* |
|
85
|
|
|
* @return \PSolr\Request\MoreLikeThis |
|
86
|
|
|
* |
|
87
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThis#Common_Parameters |
|
88
|
|
|
*/ |
|
89
|
|
|
public function setMinimumDocumentFrequency($min) |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->set('mlt.mindf', $min); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @param int $min |
|
96
|
|
|
* |
|
97
|
|
|
* @return \PSolr\Request\MoreLikeThis |
|
98
|
|
|
* |
|
99
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThis#Common_Parameters |
|
100
|
|
|
*/ |
|
101
|
|
|
public function setMinimumWordLength($min) |
|
102
|
|
|
{ |
|
103
|
|
|
return $this->set('mlt.minwl', $min); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @param int $max |
|
108
|
|
|
* |
|
109
|
|
|
* @return \PSolr\Request\MoreLikeThis |
|
110
|
|
|
* |
|
111
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThis#Common_Parameters |
|
112
|
|
|
*/ |
|
113
|
|
|
public function setMaximumWordLength($max) |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->set('mlt.maxwl', $max); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @param int $max |
|
120
|
|
|
* |
|
121
|
|
|
* @return \PSolr\Request\MoreLikeThis |
|
122
|
|
|
* |
|
123
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThis#Common_Parameters |
|
124
|
|
|
*/ |
|
125
|
|
|
public function setMaximumQueryTerms($max) |
|
126
|
|
|
{ |
|
127
|
|
|
return $this->set('mlt.maxqt', $max); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @param int $max |
|
132
|
|
|
* |
|
133
|
|
|
* @return \PSolr\Request\MoreLikeThis |
|
134
|
|
|
* |
|
135
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThis#Common_Parameters |
|
136
|
|
|
*/ |
|
137
|
|
|
public function setMaximumTokens($max) |
|
138
|
|
|
{ |
|
139
|
|
|
return $this->set('mlt.maxntp', $max); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @param bool $boost |
|
144
|
|
|
* |
|
145
|
|
|
* @return \PSolr\Request\MoreLikeThis |
|
146
|
|
|
* |
|
147
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThis#Common_Parameters |
|
148
|
|
|
*/ |
|
149
|
|
|
public function boost($boost = true) |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->set('mlt.boost', (bool) $boost); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @param string|array $fields |
|
156
|
|
|
* An associative array of fields to boosts, e.g. array('field' => 2.0); |
|
157
|
|
|
* |
|
158
|
|
|
* @return \PSolr\Request\MoreLikeThis |
|
159
|
|
|
* |
|
160
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThis#Common_Parameters |
|
161
|
|
|
*/ |
|
162
|
|
|
public function setQueryFields($fields) |
|
163
|
|
|
{ |
|
164
|
|
|
return $this->set('mlt.qf', $this->buildBoostedFields($fields)); |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
// |
|
168
|
|
|
// Handler params |
|
169
|
|
|
// |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* @param bool $include |
|
173
|
|
|
* |
|
174
|
|
|
* @return \PSolr\Request\MoreLikeThis |
|
175
|
|
|
* |
|
176
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThisHandler#Params |
|
177
|
|
|
*/ |
|
178
|
|
|
public function includeMatchedDocuments($include = true) |
|
179
|
|
|
{ |
|
180
|
|
|
return $this->set('mlt.match.include', (bool) $include); |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* @param int $offset |
|
185
|
|
|
* |
|
186
|
|
|
* @return \PSolr\Request\MoreLikeThis |
|
187
|
|
|
* |
|
188
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThisHandler#Params |
|
189
|
|
|
*/ |
|
190
|
|
|
public function setMatchOffset($offset) |
|
191
|
|
|
{ |
|
192
|
|
|
return $this->set('mlt.match.offset', $offset); |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
/** |
|
196
|
|
|
* @param int $option |
|
197
|
|
|
* |
|
198
|
|
|
* @return \PSolr\Request\MoreLikeThis |
|
199
|
|
|
* |
|
200
|
|
|
* @see http://wiki.apache.org/solr/MoreLikeThisHandler#Params |
|
201
|
|
|
*/ |
|
202
|
|
|
public function setInterestingTerms($option) |
|
203
|
|
|
{ |
|
204
|
|
|
return $this->set('mlt.interestingTerms', $option); |
|
205
|
|
|
} |
|
206
|
|
|
} |
|
207
|
|
|
|