-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
I want to update to the 5.X client but the attached code isn't working (it does work on 4.7.0). When I have 2 JSON items stored and search for the first item based on an aliased property in the JSON object it returns a mangled response. It works as expected if I have only 1 item or more than 2 items stored but when I have exactly 2 items stored it's a problem. Also it only seems to happen with a limit with a size of 1.
The response I would expect is:
{"total":2,"documents":[{"id":"test:itemA","value":{"itemOrder":1}}]}
However the response I get is:
{"total":2,"documents":[{"id":"test:itemA","value":{}},{"id":["itemOrder","1","$","{\"itemOrder\":1}"],"value":{}}]}
The problem query is:
const result = await client.ft.search(indexName, "@itemOrder:[0 10]", {
SORTBY: {
BY: "itemOrder",
DIRECTION: "ASC",
},
LIMIT: {
from: 0,
size: 1, //Using a limit of 1 here seems to be a problem when there are two items stored
},
});
where my index is:
await client.ft.create(
indexName,
{
"$.itemOrder": {
type: "NUMERIC",
AS: "itemOrder",
},
},
{
ON: "JSON",
PREFIX: getKey(""),
}
);
The full code that demonstrates the issue is attached.
Node.js Version
v22.12.0
Redis Server Version
redis_version:7.4.3
Node Redis Version
Platform
Windows and Linux
Logs
Connected to Redis
First item with 1 entry:
result: {"total":1,"documents":[{"id":"test:itemA","value":{"itemOrder":1}}]}
found item: [Object: null prototype] { itemOrder: 1 }
Second item with 2 entries:
result: {"total":2,"documents":[{"id":"test:itemA","value":{}},{"id":["itemOrder","1","$","{\"itemOrder\":1}"],"value":{}}]}
found item: [Object: null prototype] {}
found item: [Object: null prototype] {}
Third item with 3 entries:
result: {"total":3,"documents":[{"id":"test:itemA","value":{"itemOrder":1}}]}
found item: [Object: null prototype] { itemOrder: 1 }