Numeric search results are rounded up. Why?

Last updated 22, Mar 2024

Question

Numeric search results are rounded up. Why?

Answer

Consider the following example that creates an index, adds a JSON document, and performs a search.

FT.CREATE item_idx ON JSON PREFIX 1 item: SCHEMA id AS id NUMERIC 

JSON.SET item:1 $ '{"id":999999999999999999}'

FT.SEARCH item_idx * RETURN 1 $.id
1) (integer) 1
2) "item:1"
3) 1) "$.id"
   2) "1000000000000000000"

The numeric index on the id field approximates the value because of the current 32-bit capacity on numeric indexes. If you would like to manage numbers exceeding the range supported by the 32 bits index size, you can index the id as TAG. Retest the case in newer versions and refer to the release notes to understand if this case is improved.

References

Learn more about numeric filters