Skip to content

Commit 165aacd

Browse files
committed
Add MoreLikeThis::setMinimumShouldMatch
1 parent 5e22b71 commit 165aacd

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

changes.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ CHANGES
33
2015-04-09
44
- Added Elastica\Query\SimpleQueryString::setMinimumShouldMatch
55
- Added Elastica\Query\FunctionScore::setMinScore
6+
- Added Elastica\Query\MoreLikeThis::setMinimumShouldMatch
67

78
2015-04-08
89
- Added new methods to Elastica\Aggregation\DateHistogram: setOffset, setTimezone

lib/Elastica/Query/MoreLikeThis.php

+13
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public function setMaxQueryTerms($maxQueryTerms)
6363
*
6464
* @param float $percentTermsToMatch Percentage
6565
* @return $this
66+
*
67+
* @deprecated Option "percent_terms_to_match" deprecated as of ES 1.5. Use "minimum_should_match" instead.
6668
*/
6769
public function setPercentTermsToMatch($percentTermsToMatch)
6870
{
@@ -158,4 +160,15 @@ public function setStopWords(array $stopWords)
158160
{
159161
return $this->setParam('stop_words', $stopWords);
160162
}
163+
164+
/**
165+
* Set minimum_should_match option.
166+
*
167+
* @param int|string $minimumShouldMatch
168+
* @return $this
169+
*/
170+
public function setMinimumShouldMatch($minimumShouldMatch)
171+
{
172+
return $this->setParam('minimum_should_match', $minimumShouldMatch);
173+
}
161174
}

test/lib/Elastica/Test/Query/MoreLikeThisTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ public function testSetPercentTermsToMatch()
104104
$this->assertEquals($match, $query->getParam('percent_terms_to_match'));
105105
}
106106

107+
public function testSetMinimumShouldMatch()
108+
{
109+
$query = new MoreLikeThis();
110+
111+
$match = '80%';
112+
$query->setMinimumShouldMatch($match);
113+
114+
$this->assertEquals($match, $query->getParam('minimum_should_match'));
115+
}
116+
107117
public function testSetMinDocFrequency()
108118
{
109119
$query = new MoreLikeThis();

0 commit comments

Comments
 (0)