Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to filter an item in JSON.array #304

Closed
ashifa454 opened this issue Apr 19, 2021 · 9 comments
Closed

How to filter an item in JSON.array #304

ashifa454 opened this issue Apr 19, 2021 · 9 comments
Labels

Comments

@ashifa454
Copy link
Contributor

ashifa454 commented Apr 19, 2021

Hi Team,
I would like to filter an item via "uid" from key "D" which is a JSON.array

{
  "MTYxNTkwMTY5Mzk2Nw-meet": {
    "A": [],
    "B": "discussion",
    "C": "created",
    "D": [
      {
        "uid": "5c0bd0471849cbf4ac34df49"
      }
    ]
  }
}
@gkorland
Copy link
Contributor

what is expected result in this case?

@ashifa454
Copy link
Contributor Author

ashifa454 commented Apr 19, 2021

{ uid:"5c0bd0471849cbf4ac34df49"} if i filter via 5c0bd0471849cbf4ac34df49

@gkorland
Copy link
Contributor

gkorland commented Apr 19, 2021

JSON.GET doc:1 $.MTYxNTkwMTY5Mzk2Nw-meet.D[0]

Or

JSON.GET doc:1 $..D[0]

@ashifa454
Copy link
Contributor Author

ashifa454 commented Apr 19, 2021

I think this will give me the first item from the array, what if I want to find the index on runtime? I was planning to use QGET but after the latest push, it says QGET is an unknown command.

@gkorland
Copy link
Contributor

JSON.GET doc:1 '$..D[?(@.uid=="5c0bd0471849cbf4ac34df49")]'

@gkorland
Copy link
Contributor

@ashifa454 regarding QGET, you're right it was never officially released and we decided the right place for this functionality is RediSearch.
In the upcoming version you will be able to create RediSearch index that follows RedisJSON.

@ashifa454
Copy link
Contributor Author

JSON.GET doc:1 '$..D[?(@.uid=="5c0bd0471849cbf4ac34df49")]'

can you please explain this one or if there is any detailed documentation?

@gkorland
Copy link
Contributor

You can read more about JSONPath here - https://github.com/json-path/JsonPath

@ashifa454
Copy link
Contributor Author

thankyou so much for quick response it worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants