diff --git a/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java index b51fbbbb566..000d448b8fb 100644 --- a/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java +++ b/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java @@ -131,7 +131,7 @@ class TermsIncludingScoreQuery extends Query implements Accountable { if (scoreMode.needsScores() == false) { // We don't need scores then quickly change the query: TermsQuery termsQuery = - new TermsQuery(toField, terms, fromField, fromQuery, topReaderContextId); + new TermsQuery(toField, terms, ords, fromField, fromQuery, topReaderContextId); return searcher .rewrite(termsQuery) .createWeight(searcher, org.apache.lucene.search.ScoreMode.COMPLETE_NO_SCORES, boost); diff --git a/lucene/join/src/java/org/apache/lucene/search/join/TermsQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/TermsQuery.java index 729feb19b9c..f9189865b0a 100644 --- a/lucene/join/src/java/org/apache/lucene/search/join/TermsQuery.java +++ b/lucene/join/src/java/org/apache/lucene/search/join/TermsQuery.java @@ -63,9 +63,26 @@ class TermsQuery extends MultiTermQuery implements Accountable { String fromField, Query fromQuery, Object indexReaderContextId) { + this(toField, terms, terms.sort(), fromField, fromQuery, indexReaderContextId); + } + + /** + * @param toField The field that should contain terms that are specified in the next parameter. + * @param terms The terms that matching documents should have. The terms must be sorted by natural + * order. + * @param indexReaderContextId Refers to the top level index reader used to create the set of + * terms in the previous parameter. + */ + TermsQuery( + String toField, + BytesRefHash terms, + int[] ords, + String fromField, + Query fromQuery, + Object indexReaderContextId) { super(toField, CONSTANT_SCORE_BLENDED_REWRITE); this.terms = terms; - ords = terms.sort(); + this.ords = ords; this.fromField = fromField; this.fromQuery = fromQuery; this.indexReaderContextId = indexReaderContextId;