Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Lucene.Net.Search.FieldComparer.TermValComparer: Fixed sorting ambiguity between empty fields and missing fields #912

Merged
merged 3 commits into from
Feb 9, 2024

Conversation

NightOwl888
Copy link
Contributor

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a change, please open an issue to discuss the change or find an existing issue.

Summary of the changes (Less than 80 chars)

Lucene.Net.Search.FieldComparer.TermValComparer: Fixed sorting ambiguity between empty fields and missing fields

Description

When using Arrays.Empty<T>() we get a singleton instance. However, this comparer uses reference equality to compare the static fields MISSING_BYTES and NON_MISSING_BYTES. This reverts back to new byte[0] to ensure the reference equality checks pass.

BREAKING

This PR also adds an internal constructor to FieldComparer, since this is a class that we added to make Lucene.NET compile. It is confusing for users who are upgrading because in older versions FieldComparer was not a generic class. Users who are upgrading should use FieldComparer<T>, which reduces or eliminates the need for casting of the underlying type.

…on instance breaks missing vs empty field comparison because the static fields MISSING_BYTES and NON_MISSING_BYTES are tested for reference equality.
… so users upgrading from older versions of Lucene.NET don't attempt to use this class and instead use the Lucene equivalent class, FieldComparer<T>.
@NightOwl888 NightOwl888 merged commit 3f87e84 into apache:master Feb 9, 2024
199 checks passed
@eladmarg
Copy link
Contributor

eladmarg commented Feb 9, 2024

great catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants