Repository navigation
Description
Environment
- Redis: 7.4.7
- RedisJSON / ReJSON: 2.8.9 (module version 20809)
- RediSearch: 2.10.20 (module version 21020)
- Deployment: Redis Stack in Docker on a Windows host
- The current development branch has not been tested.
Current behavior
Writing the following document with JSON.SET succeeds:
{"amount":0.9999999999999999}
However, immediately reading it with JSON.GET returns:
{"amount":1.0}
JSON.RESP also returns the numeric value 1.0.
The expected nearest binary64 value for the submitted literal is the representable value immediately below 1.0. It should remain distinct from 1.0.
This change affects strict numeric filtering. With three documents, I observed:
| ID | Submitted amount | Amount returned by JSON.GET |
|---|---|---|
| 0 | 0.5 | 0.5 |
| 1 | 0.9999999999999999 | 1.0 |
| 2 | 1.0 | 1.0 |
The numeric filter @amount:[0 (1], representing 0 <= amount < 1, returns only ID 0.
As a control, storing the same decimal strings in HASH fields and creating a separate NUMERIC index returns IDs 0 and 1 for the identical filter.
Steps to reproduce
- Start Redis Stack with the versions listed above.
- Create a fresh RediSearch index ON JSON, indexing
$.amountas an alias namedamountwith type NUMERIC. - Create three JSON documents with amounts 0.5, 0.9999999999999999, and 1.0. Send those decimal literals directly in the JSON text using JSON.SET.
- Read the second document using JSON.GET and JSON.RESP. Observe that its amount is returned as 1.0.
- Query the JSON index with
@amount:[0 (1]. Observe that only the document containing 0.5 is returned. - Create a separate index ON HASH with an
amountNUMERIC field. - Use HSET to store the same three decimal strings in separate HASH records.
- Execute the identical range query against the HASH index. Observe that the records containing 0.5 and 0.9999999999999999 are both returned.
Expected behavior
The submitted literal 0.9999999999999999 should round to the binary64 value immediately below 1.0 and remain distinct from 1.0 after storage and retrieval.
Both ID 0 and ID 1 should satisfy 0 <= amount < 1.
Verification
The behavior was reproduced in independent runs using fresh keys.
Observed results:
- JSON index: count = 1, IDs = [0]
- HASH control: count = 2, IDs = [0, 1]
- JSON readback amounts: [0.5, 1.0, 1.0]
The value change is already observable through JSON.GET before evaluating a numeric filter. No vector search, concurrent writes, or approximate index is required for this reduced reproduction.
Activity
aradalvand commentedon Nov 11, 2026
I second this. We hit this case as well. 64-bit floating-point numbers are NOT roundtripped precisely.
aradalvand commentedon Nov 11, 2026
The root cause appears to be that
serde_jsonis built without itsfloat_roundtripfeature, so floats are parsed with its default best-effort precision, which is sometimes off by one ULP. This affects far more than this one value.Reproduced on Redis 8.10.2 by round-tripping 3,999 random doubles through
JSON.SET/JSON.GET. Both builds below are from the samemastercommit (19c96e8):0.9999999999999999comes back as1.0master, unchanged1.0master+float_roundtrip0.9999999999999999The fix is adding
"float_roundtrip"to theserde_jsonfeatures in the rootCargo.toml. I'll open a PR.