Skip to content

Commit

Permalink
Consistent scores for multi-term SourceConfirmedTestQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
romseygeek committed Oct 13, 2023
1 parent 2ce5392 commit 7d72335
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -215,7 +216,9 @@ public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float bo
return in.createWeight(searcher, scoreMode, boost);
}

final Set<Term> terms = new HashSet<>();
// We use a LinkedHashSet here to preserve the ordering of terms to ensure that
// later summing of float scores per term is consistent
final Set<Term> terms = new LinkedHashSet<>();
in.visit(QueryVisitor.termCollector(terms));
if (terms.isEmpty()) {
throw new IllegalStateException("Query " + in + " doesn't have any term");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ public void testPhrase() throws Exception {
}
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/98712")
public void testMultiPhrase() throws Exception {
try (Directory dir = newDirectory(); IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(Lucene.STANDARD_ANALYZER))) {

Expand Down

0 comments on commit 7d72335

Please sign in to comment.