redis / redis-om-spring

Spring Data Redis extensions for better search, documents models, and more
MIT License
596 stars 93 forks source link

JSON documents numeric field values are automatically rounding #489

Closed nhealthlive closed 1 month ago

nhealthlive commented 1 month ago

We have the following @Document model

image

Here the surId is a type of Long, But when we set long-range values, It automatically rounds to x000

That is if I set surId as 8301034833169298414 it rounds to 8301034833169298000

If I set surId as 8301034833169297919 it rounds to 8301034833169297000

image

This can be try from the redis insight.

Is there any range limit for NumericField? Any workarounds that you can suggest @bsbodden

bsbodden commented 1 month ago

Unfortunately this is a JSON engine limitation, as the image below shows it happens on insertion. One possible workaround would be to tell Spring to serialize and store it as a string, but then you won't be able to indexed as a number, so features like range indexes would work

see related https://www.techempower.com/blog/2016/07/05/mangling-json-numbers/

Screenshot 2024-07-10 at 11 04 25 PM