Fix parameter value for calling data.advanceExact (#44205)

While the code works perfectly well for a single segment, it returns the wrong values for multiple segments. E.g. If we have 500 docs in one segment and if we want to get the doc id = 280 then data.advanceExact(topDocs.scoreDocs[i].doc) works fine. If we have two segments, say, with first segment having docs 1-200 and the second segment having docs 201-500, then 280 is fetched from the second segment but is actually 480. Subtracting the docBase (280-200) takes us to the correct document which is 80 in the second segment and actually 280.
This commit is contained in:
maarab7 2019-07-18 12:51:27 +04:00 committed by Luca Cavanna
parent 7598e0186a
commit 1375cc93a8
1 changed files with 1 additions and 1 deletions

View File

@ -189,7 +189,7 @@ public class ExampleRescoreBuilder extends RescorerBuilder<ExampleRescoreBuilder
}
data = ((AtomicNumericFieldData) fd).getDoubleValues();
}
if (false == data.advanceExact(topDocs.scoreDocs[i].doc)) {
if (false == data.advanceExact(topDocs.scoreDocs[i].doc - leaf.docBase)) {
throw new IllegalArgumentException("document [" + topDocs.scoreDocs[i].doc
+ "] does not have the field [" + context.factorField.getFieldName() + "]");
}