Skip to content

Reject binary doc-values update on an index sort field - #16565

Merged
jimczi merged 2 commits into
apache:mainfrom
jimczi:binary-dv-update-index-sort-guard
Aug 27, 2026
Merged

Reject binary doc-values update on an index sort field#16565
jimczi merged 2 commits into
apache:mainfrom
jimczi:binary-dv-update-index-sort-guard

Conversation

@jimczi

@jimczi jimczi commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

IndexWriter.updateBinaryDocValue is missing the index-sort guard that updateNumericDocValue and the varargs updateDocValues(Term, Field...) already have: it does not reject updating a field that is part of the index sort. Updating a sort field's doc values would make the persisted sort order inconsistent with the values, so it should be rejected up front like the numeric path.

The check goes before verifyOrCreateDvOnlyField here (unlike the numeric method, which checks after). An index sort field is never backed by binary doc values, so if the check came after the type validation it would never be reached — the user would instead get a less clear doc-values-type mismatch error. Placing it first surfaces the same clear "cannot update docvalues field involved in the index sort" message the numeric path gives.

Extended TestIndexSorting.testBadDVUpdate to cover updateBinaryDocValue alongside the existing updateNumericDocValue and varargs assertions.

@jimczi jimczi added this to the 10.6.0 milestone Aug 26, 2026

@martijnvg martijnvg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

jimczi added 2 commits August 27, 2026 09:36
updateBinaryDocValue lacked the index-sort guard that updateNumericDocValue and the varargs updateDocValues already have. An index sort field is never binary, so the check goes before the doc-values-type validation, which would otherwise mask it with a less clear type-mismatch error.
@jimczi
jimczi force-pushed the binary-dv-update-index-sort-guard branch from 8f715ef to 79c2e45 Compare August 27, 2026 07:38
@jimczi
jimczi merged commit 850c45b into apache:main Aug 27, 2026
12 checks passed
@jimczi
jimczi deleted the binary-dv-update-index-sort-guard branch August 27, 2026 08:55
jimczi added a commit to jimczi/lucene that referenced this pull request Aug 27, 2026
updateBinaryDocValue lacked the index-sort guard that updateNumericDocValue and the varargs updateDocValues already have. An index sort field is never binary, so the check goes before the doc-values-type validation, which would otherwise mask it with a less clear type-mismatch error.
jimczi added a commit to jimczi/lucene that referenced this pull request Aug 27, 2026
updateBinaryDocValue lacked the index-sort guard that updateNumericDocValue and the varargs updateDocValues already have. An index sort field is never binary, so the check goes before the doc-values-type validation, which would otherwise mask it with a less clear type-mismatch error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants