IndexOutOfBoundsException in TextMultiValues

Description

TextMultiValues wraps an underlying DocValues instance, and we often use the following pattern:

https://github.com/hibernate/hibernate-search/blob/077ac00939656c80559f526399b28b3d297cf0d2/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/lowlevel/docvalues/impl/JoiningTextMultiValuesSource.java#L96-L99

Essentially this code assumes that nextChild() will advance the underlying DocValues instance, so it calls values.nextOrd() right away, assuming that method is already aware that we advanced to a new docId.

But we actually have a cache in TextMultiValues:

https://github.com/hibernate/hibernate-search/blob/077ac00939656c80559f526399b28b3d297cf0d2/backend/lucene/src/main/java/org/hibernate/search/backend/lucene/lowlevel/docvalues/impl/TextMultiValues.java#L88-L124

And if we never call TextMultiValues#advanceExact, that cache doesn't get updated and could lead to incorrect behavior in TextMultiValues#nextOrd.

And in fact, in Lucene 10 it does: https://github.com/hibernate/hibernate-search/pull/3746#issuecomment-1733109330

Activity

Show:
Fixed

Details

Assignee

Reporter

Sprint

Fix versions

Affects versions

Priority

Created September 25, 2023 at 8:12 AM
Updated October 20, 2023 at 11:01 AM
Resolved September 25, 2023 at 10:54 AM