Skip to content

OAK-12344: Align ORDER BY placement of missing and invalid values in Lucene and Elastic with the query engine - #3184

Closed
hosgood wants to merge 4 commits into
apache:trunkfrom
hosgood:OAK-12344
Closed

hosgood wants to merge 4 commits into
apache:trunkfrom
hosgood:OAK-12344

Conversation

@hosgood

@hosgood hosgood commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

For an ordered property, nodes without a useable value (absent, or not convertible to the declared type) were sorted differently by Lucene (as 0 / the epoch), Elastic (last in both directions) and the query engine (first ascending, last descending). Union queries with ORDER BY could therefore place such nodes in the middle of the results.

Both indexes now follow the query engine’s convention: such nodes sorts first in ascending and last in descending order.

  • Lucene: missing values for Long/Date/Double sorts are set to the smallest value (strings already behaved this way)
  • Elastic: missing: _first on ascending property sorts, missing: _last on descending property sorts

* {@code Export-Package} (see oak-lucene/pom.xml), so toggles here can be removed once retired
* without an OSGi baseline / API compatibility break.
*/
public final class LuceneFeatureToggles {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we use a class that is shared (usable for both Elastic and Lucene)? Like FulltextIndexEditor

@thomasmueller

Copy link
Copy Markdown
Member

Could you open a new PR against the OAK-12344 branch?

@hosgood hosgood closed this Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants