Skip to content

Commit cc00fd7

Browse files
authored
Use BoostQuery rather than FunctionScoreQuery for query-time indices_boost (#52272)
This is a trivial change, but it should result in a slightly more efficient query boost.
1 parent 57fa346 commit cc00fd7

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

server/src/main/java/org/elasticsearch/search/DefaultSearchContext.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.lucene.search.BooleanClause.Occur;
2323
import org.apache.lucene.search.BooleanQuery;
24+
import org.apache.lucene.search.BoostQuery;
2425
import org.apache.lucene.search.Collector;
2526
import org.apache.lucene.search.FieldDoc;
2627
import org.apache.lucene.search.MatchNoDocsQuery;
@@ -31,8 +32,6 @@
3132
import org.elasticsearch.common.Nullable;
3233
import org.elasticsearch.common.lease.Releasables;
3334
import org.elasticsearch.common.lucene.search.Queries;
34-
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
35-
import org.elasticsearch.common.lucene.search.function.WeightFactorFunction;
3635
import org.elasticsearch.common.unit.TimeValue;
3736
import org.elasticsearch.common.util.BigArrays;
3837
import org.elasticsearch.index.IndexService;
@@ -248,7 +247,7 @@ public void preProcess(boolean rewrite) {
248247
parsedQuery(ParsedQuery.parsedMatchAllQuery());
249248
}
250249
if (queryBoost() != AbstractQueryBuilder.DEFAULT_BOOST) {
251-
parsedQuery(new ParsedQuery(new FunctionScoreQuery(query(), new WeightFactorFunction(queryBoost)), parsedQuery()));
250+
parsedQuery(new ParsedQuery(new BoostQuery(query(), queryBoost), parsedQuery()));
252251
}
253252
this.query = buildFilteredQuery(query);
254253
if (rewrite) {

0 commit comments

Comments
 (0)