Product: Redis Stack 7.2

Two-part question:

1. SEARCH /Projection on JSON object using REDIS command:

WORKS: Working Query that returns FULL JSON results:

  • FT.SEARCH account:index "@status: {POSTED}"
  • Results: Multiple JSON records returned

NOT WORKING: Scenario that is not working:

  • FT.SEARCH account:index "@status: {POSTED} RETURN 1 status"
  • FT.SEARCH account:index "@status: {POSTED} RETURN 1 '$.status'" (Tried this version too)
  • Result: No Results found message (no errors in both cases)

2. SEARCH /Projection Redis Om NodeJs client library:

Both scenarios I have no way to ask REDIS Stack to return ONLY specific attributes from JSON. As of now I have no way to get this working for both #1 or #2 (with Redis OM)

Tried to look through FT.SEARCH details here https://redis.io/commands/ft.search/ but don't know what I am missing?

Expecting REDIS Search to return ONLY expected attributes of JSON in results (Projection support) Need details on how to get this done both with "REDIS OM" OR at least using direct REDIS Command FT.SEARCH

Looked at both below and don't see it working for me and they seem to be open issues: RedisSearch. Is it possible to return data requested with RETURN keyword as a regular response? https://github.com/redis/redis-om-python/issues/568

Any help is appreciated

1

There are 1 answers

2
Guy Royse On BEST ANSWER

Your quotes are in the wrong place. They go around the query. RETURN is not part of the query, it's an argument. So they don't go around it.

Try this:

FT.SEARCH account:index "@status:{POSTED}" RETURN 1 $.status

Regarding Redis OM for Node.js, it only returns complete documents. This is by design, and there are no plans to change that. If you want finer control, you should use Node Redis directly.