1

I am going through rejson docs jsonget and cannot find anything related to complex query as for example:

JSON.GET key1 where key1.subkey1 == "test1 || key3.subkey6.subsubkey2 > 2"

Does anybody know if redis supports such a logic with json output? If not, what are the alternatives ?

Guy Korland
  • 9,139
  • 14
  • 59
  • 106
elcomendante
  • 1,113
  • 1
  • 11
  • 28

1 Answers1

3

No - ReJSON does not support complex query logic. What you could do is couple it (in the application) with RediSearch (https://redisearch.io) to index and search your documents.

Disclaimer: ReJSON author here and involved in RediSearch's development to a degree :)

Itamar Haber
  • 47,336
  • 7
  • 91
  • 117
  • How would you recommend coupling ReJSON and RediSearch together? I am still new to Redis, but it looks like RediSearch is used to query an index of strings. Let's say I had an array of JSON objects with an integer and a string put into Redis using ReJSON. My goal is to retrieve an integer from one of those JSON objects based on a query of their strings. If I created a RedisSearch index of those strings and performed a query, how would I then retrieve the integer I want from the JSON object inside of Redis using ReJSON? – Tylo Mar 18 '18 at 13:35
  • Good question :) @Not_a_golfer and I had discussed it in length... two ways to go about it a) do it with client/application-side glue b) extend RediSearch to support arbitrary get/set commands (as it currently does only w/ hashes). Option a - you can implement it, option b - could come as a feature someday. – Itamar Haber Mar 18 '18 at 21:35
  • If I understand RediSearch correctly, you can create an index that is ('text to search', 'id'). And when I conduct a query of 'text', it will return an array of 'id' strings that match. Would it be fine to make these 'id' strings indexes for my JSON data? That way I could use the returned 'id' to make a ReJSON request for data using a command like `JSON.GET myArray [0]` where `0` was a returned 'id' from my RediSearch query. – Tylo Mar 19 '18 at 09:42
  • @Tylo jup, exactly so. – Itamar Haber Mar 19 '18 at 13:34
  • @ItamarHaber - Have you considered using jq to add support for complex queries to reJSON? It should not be too difficult... – peak Jun 03 '18 at 16:32