From bc393b6d79bb04e8911459983b1aec1e75ab3768 Mon Sep 17 00:00:00 2001 From: Clinton Gormley Date: Fri, 18 Oct 2013 14:24:11 +0200 Subject: [PATCH] Changed the minScore comparator from > to >= Closes #4303 --- docs/reference/search/request/min-score.asciidoc | 5 +++-- .../elasticsearch/common/lucene/MinimumScoreCollector.java | 3 +-- .../search/child/SimpleChildQuerySearchTests.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/reference/search/request/min-score.asciidoc b/docs/reference/search/request/min-score.asciidoc index 18ecf6237cd..f5a212ebf8e 100644 --- a/docs/reference/search/request/min-score.asciidoc +++ b/docs/reference/search/request/min-score.asciidoc @@ -1,7 +1,8 @@ [[search-request-min-score]] === min_score -Allows to filter out documents based on a minimum score: +Exclude documents which have a `_score` less than the minimum specified +in `min_score`: [source,js] -------------------------------------------------- @@ -14,4 +15,4 @@ Allows to filter out documents based on a minimum score: -------------------------------------------------- Note, most times, this does not make much sense, but is provided for -advance use cases. +advanced use cases. diff --git a/src/main/java/org/elasticsearch/common/lucene/MinimumScoreCollector.java b/src/main/java/org/elasticsearch/common/lucene/MinimumScoreCollector.java index 31069453b46..93baf204e53 100644 --- a/src/main/java/org/elasticsearch/common/lucene/MinimumScoreCollector.java +++ b/src/main/java/org/elasticsearch/common/lucene/MinimumScoreCollector.java @@ -20,7 +20,6 @@ package org.elasticsearch.common.lucene; import org.apache.lucene.index.AtomicReaderContext; -import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.Collector; import org.apache.lucene.search.ScoreCachingWrappingScorer; import org.apache.lucene.search.Scorer; @@ -54,7 +53,7 @@ public class MinimumScoreCollector extends Collector { @Override public void collect(int doc) throws IOException { - if (scorer.score() > minimumScore) { + if (scorer.score() >= minimumScore) { collector.collect(doc); } } diff --git a/src/test/java/org/elasticsearch/search/child/SimpleChildQuerySearchTests.java b/src/test/java/org/elasticsearch/search/child/SimpleChildQuerySearchTests.java index 57ebf8d6abc..a9da5644b07 100644 --- a/src/test/java/org/elasticsearch/search/child/SimpleChildQuerySearchTests.java +++ b/src/test/java/org/elasticsearch/search/child/SimpleChildQuerySearchTests.java @@ -1486,7 +1486,7 @@ public class SimpleChildQuerySearchTests extends ElasticsearchIntegrationTest { refresh(); SearchResponse searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("child", matchAllQuery()).scoreType("sum")) - .setMinScore(2) // Score needs to be above 2.0! + .setMinScore(3) // Score needs to be 3 or above! .execute().actionGet(); assertNoFailures(searchResponse); assertThat(searchResponse.getFailedShards(), equalTo(0));