Skip to content

Filtering on indexed fields with multiple Number only retrieves same type as given Comparable #178

Closed

Description

@tkainrad

Situation

If a field contains multiple different number types, let's say Integers and Doubles, filtering on these columns will still work if the field is not indexed. For example

Filters.eq(fieldName, new Integer(5));

will retrieve also documents that have set a Double value that is numerically equal to 5.

However, once the field is indexed, this does no longer work. On indexed fields, only Documents using the same type will be retrieved.

Question
Is there any workaround in order to be able to filter on indexed fields that contain multiple Number types?

Proposal
I believe the filtering behavior should be the same no matter if the field is indexed or not. If it is not possible to retain the superior behavior that exists with non-indexed fields also for indexed fields, this should be pointed out in the documentation.

Activity

  1. self-assigned this
    on Jul 11, 2019
  2. added this to the 3.3.0 milestone on Jul 11, 2019
  3. anidotnet commented on Jul 12, 2019

    @anidotnet
    Contributor

    The fix is available in latest build - 3.3.0-SNAPSHOT and the repository is - https://oss.sonatype.org/content/repositories/snapshots/org/dizitart/nitrite

    Now for both indexed and un-indexed field you have to provide exact number for equality. Behavior is same for both now - 5.0 and 5 is not equal in java, so it is not in nitrite now.

  4. tkainrad commented on Jul 12, 2019

    @tkainrad
    Author

    Thanks for addressing this so quickly!

    I would have preferred if it were possible for both indexed and un-indexed fields. Also in Java it is possible to compare different Number types. This would allow to store different Number types in a field, making use of the schema-less document store and still being able to filter properly. Now, I basically have to cast everything to double before putting it into Nitrite.

    However, I agree that this is a viable solution.

  5. added a commit that references this issue on Jul 12, 2019
  6. added a commit that references this issue on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions