You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Filtering on indexed fields with multiple Number only retrieves same type as given Comparable #178
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, newInteger(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.
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.
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.
Activity
anidotnet commentedon Jul 12, 2019
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.
tkainrad commentedon Jul 12, 2019
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.
merge solution for issue #178
fix(gh-1282): index keys normalize to double only where the conversio…