1

So inside json we have a key called items which actually contain an array of elements, now we can get selective index from that array using JSON.GET employees-list .items[1].

But in our case what we need is to get a range from this array say elements with index 0-10, 10-20 etc for pagination purpose so that we don't have to get entire data in code and then filter results.

The reason I am looking for it because if we are reading entire list then as data size would be huge data transfer latency would increase as the API using it and redis server aren't on the same instance plus it makes more sense to not have to do it in code if possible.

So first thing is it even possible and if yes how can we it be achieved?

Guy Korland
  • 9,139
  • 14
  • 59
  • 106
vinit payal
  • 1,201
  • 2
  • 13
  • 27

1 Answers1

3

RedisJSON doesn't support full JSONPath syntax and only supports simple single paths. But, you can utilize Redis pipeline support to achieve a good enough result, sending the following in a non-blocking way:

JSON.GET employees-list .items[1]
JSON.GET employees-list .items[2]
JSON.GET employees-list .items[3]

RedisJSON2 on the other hand has full JSONPath support and does support such queries, but currently for backward compatibility it only returns the first element (like RedisJSON). This kind of support is about to be added probably in the next week.

Guy Korland
  • 9,139
  • 14
  • 59
  • 106