diff --git a/src/main/java/org/elasticsearch/common/lucene/all/AllTermQuery.java b/src/main/java/org/elasticsearch/common/lucene/all/AllTermQuery.java index 378dad3a9b3..38fe07d279c 100644 --- a/src/main/java/org/elasticsearch/common/lucene/all/AllTermQuery.java +++ b/src/main/java/org/elasticsearch/common/lucene/all/AllTermQuery.java @@ -74,7 +74,6 @@ public class AllTermQuery extends SpanTermQuery { if (this.stats == null) { return null; } - AtomicReader reader = context.reader(); SloppySimScorer sloppySimScorer = similarity.sloppySimScorer(stats, context); return new AllTermSpanScorer((TermSpans) query.getSpans(context, acceptDocs, termContexts), this, sloppySimScorer); } diff --git a/src/main/java/org/elasticsearch/common/lucene/search/function/FiltersFunctionScoreQuery.java b/src/main/java/org/elasticsearch/common/lucene/search/function/FiltersFunctionScoreQuery.java index 2d3a62a75e6..c05d2edf427 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/function/FiltersFunctionScoreQuery.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/function/FiltersFunctionScoreQuery.java @@ -138,7 +138,7 @@ public class FiltersFunctionScoreQuery extends Query { @Override public Scorer scorer(AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer, Bits acceptDocs) throws IOException { - Scorer subQueryScorer = subQueryWeight.scorer(context, scoreDocsInOrder, topScorer, acceptDocs); + Scorer subQueryScorer = subQueryWeight.scorer(context, scoreDocsInOrder, false, acceptDocs); if (subQueryScorer == null) { return null; } diff --git a/src/main/java/org/elasticsearch/common/lucene/search/function/FunctionScoreQuery.java b/src/main/java/org/elasticsearch/common/lucene/search/function/FunctionScoreQuery.java index 7bb11567ba0..0e7d75ed536 100644 --- a/src/main/java/org/elasticsearch/common/lucene/search/function/FunctionScoreQuery.java +++ b/src/main/java/org/elasticsearch/common/lucene/search/function/FunctionScoreQuery.java @@ -96,7 +96,7 @@ public class FunctionScoreQuery extends Query { @Override public Scorer scorer(AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer, Bits acceptDocs) throws IOException { - Scorer subQueryScorer = subQueryWeight.scorer(context, scoreDocsInOrder, topScorer, acceptDocs); + Scorer subQueryScorer = subQueryWeight.scorer(context, scoreDocsInOrder, false, acceptDocs); if (subQueryScorer == null) { return null; } diff --git a/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java index e32f93d0295..76a1295db6c 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java @@ -24,6 +24,7 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.client.Client; +import org.elasticsearch.index.query.FilterBuilders; import org.elasticsearch.test.integration.AbstractNodesTests; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -227,6 +228,25 @@ public class CustomScoreSearchTests extends AbstractNodesTests { assertThat(response.hits().getAt(0).id(), equalTo("1")); assertThat(response.hits().getAt(1).id(), equalTo("2")); } + + @Test + public void testTriggerBooleanScorer() throws Exception { + client.admin().indices().prepareDelete().execute().actionGet(); + client.admin().indices().prepareCreate("test").setSettings(settingsBuilder().put("index.number_of_shards", 1)).execute().actionGet(); + + client.prepareIndex("test", "type", "1").setSource("field", "value1", "color", "red").execute().actionGet(); + client.prepareIndex("test", "type", "2").setSource("field", "value2", "color", "blue").execute().actionGet(); + client.prepareIndex("test", "type", "3").setSource("field", "value3", "color", "red").execute().actionGet(); + client.prepareIndex("test", "type", "4").setSource("field", "value4", "color", "blue").execute().actionGet(); + client.admin().indices().prepareRefresh().execute().actionGet(); + SearchResponse searchResponse = client.prepareSearch("test") + .setQuery(customFiltersScoreQuery(fuzzyQuery("field", "value")) + .add(FilterBuilders.idsFilter("type").addIds("1"), 3)) + .execute().actionGet(); + assertThat(Arrays.toString(searchResponse.shardFailures()), searchResponse.failedShards(), equalTo(0)); + + assertThat(searchResponse.hits().totalHits(), equalTo(4l)); + } @Test public void testCustomFiltersScore() throws Exception {