Pass topScorer=false to sub-scorers if a scorer is wrapped. Wrapped BooleanQuery can return collect-only scorers. See #2505
This commit is contained in:
parent
2449049a84
commit
90bd82ac50
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue