(index) Fix term coherence evaluation

The code was incorrectly using the documentId instead of the combined id, resulting in almost all result sets being incorrectly seen as zero.
This commit is contained in:
Viktor Lofgren 2024-04-16 18:07:43 +02:00
parent 1748fcc5ac
commit adf846bfd2
2 changed files with 5 additions and 5 deletions

View File

@ -64,7 +64,7 @@ public class IndexResultValuationContext {
long docId = UrlIdCodec.removeRank(combinedId);
if (!searchTerms.coherences.test(termMetadataForCombinedDocumentIds, docId))
if (!searchTerms.coherences.test(termMetadataForCombinedDocumentIds, combinedId))
return null;
long docMetadata = statefulIndex.getDocumentMetadata(docId);

View File

@ -15,9 +15,9 @@ public record TermCoherenceGroupList(List<TermCoherenceGroup> words) {
this.words = Collections.unmodifiableList(words);
}
public boolean test(TermMetadataForCombinedDocumentIds documents, long docId) {
public boolean test(TermMetadataForCombinedDocumentIds documents, long combinedId) {
for (var coherenceSet : words()) {
if (!coherenceSet.test(documents, docId)) {
if (!coherenceSet.test(documents, combinedId)) {
return false;
}
}
@ -36,11 +36,11 @@ public record TermCoherenceGroupList(List<TermCoherenceGroup> words) {
this(coh.stream().mapToLong(SearchTermsUtil::getWordId).toArray());
}
public boolean test(TermMetadataForCombinedDocumentIds documents, long docId) {
public boolean test(TermMetadataForCombinedDocumentIds documents, long combinedId) {
long overlap = 0xFF_FFFF_FFFF_FFFFL;
for (var word : words) {
overlap &= documents.getTermMetadata(word, docId);
overlap &= documents.getTermMetadata(word, combinedId);
}
return WordMetadata.decodePositions(overlap) != 0L;