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

(Combined query not working on JSON Array objects). "And(&)" operation is not working on each JSON Object with in the JSON Array. Instead it is working as "OR" across all the JSON objects of JSON array in Redis Search. #677

Open
shashirangam opened this issue Sep 17, 2024 · 0 comments

Comments

@shashirangam
Copy link

shashirangam commented Sep 17, 2024

Combined query not working on JSON Array objects.

JSON format:

 {
  "description": "list of items",
  "items": [
    {
      "status": 2,
      "enabled": true,
      "name": "Item1",
      "price": 500
    },
    {
      "status": 0,
      "enabled": true,
      "name": "Item2",
      "price": 1000
    },
    {
      "status": 0,
      "enabled": true,
      "name": "Item2",
      "price": 1200
    }
  ]
}

I created index in different ways as below.

FT.CREATE jindex ON JSON PREFIX 1 jsn: SCHEMA $.description as description TAG $.items.[*].name as name TAG $.items.[*].price as price NUMERIC $.items.[*].status as status NUMERIC

FT.CREATE tindex ON JSON PREFIX 1 jsn: SCHEMA $.description as description TAG $.items.*.name as name TAG $.items.*.price as price NUMERIC $.items.*.status as status NUMERIC

FT.CREATE mindex ON JSON PREFIX 1 jsn: SCHEMA $.description as description TAG $.items.[0:].name as name TAG $.items.[0:].price as price NUMERIC $.items.[0:].status as status NUMERIC

FT.CREATE gindex ON JSON PREFIX 1 jsn: SCHEMA $.description as description TAG $.items[*].name as name TAG $.items[*].price as price NUMERIC $.items[*].status as status NUMERIC

Insert data:

JSON.SET jsn:1 $ '{"description":"list of items","items":[{"status":2,"enabled":true,"name":"Item1","price":500},{"status":0,"enabled":true,"name":"Item2","price":1000},{"status":0,"enabled":true,"name":"Item2","price":1200}]}'

FT.SEARCH jindex '(@status:[0 0]) (@name:{Item1})'

                             (or)

FT.SEARCH jindex '(@status:[0 0]) & (@name:{Item1})'

                             (or)

FT.SEARCH tindex '(@status:[0 0]) (@name:{Item1})'

                             (or)

FT.SEARCH tindex '(@status:[0 0]) & (@name:{Item1})'

                             (or)

FT.SEARCH mindex '(@status:[0 0]) (@name:{Item1})'

                             (or)

FT.SEARCH mindex '(@status:[0 0]) & (@name:{Item1})'

                             (or)

FT.SEARCH gindex '(@status:[0 0]) (@name:{Item1})'

                             (or)

FT.SEARCH gindex '(@status:[0 0]) & (@name:{Item1})'

The above all commands returning one record as in screenshot instead of 0 records. But the status(0) & item(Item1) both are not available in one JSON object.

image

It is breaking our implementation where ever redis-search, business logic depends on json array. Thank you in advance for your quick response.

I am using the redis-stack latest version using docker

docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 -v "D:/storage:/data:rw" redis/redis-stack:latest

@shashirangam shashirangam changed the title "And(&)" operation is not working on JSON Object with in the JSON Array. Instead it is working as "OR" across all the JSON objects of JSON array in Redis Search. (Combined query not working on JSON Array objects.). "And(&)" operation is not working on JSON Object with in the JSON Array. Instead it is working as "OR" across all the JSON objects of JSON array in Redis Search. Sep 17, 2024
@shashirangam shashirangam changed the title (Combined query not working on JSON Array objects.). "And(&)" operation is not working on JSON Object with in the JSON Array. Instead it is working as "OR" across all the JSON objects of JSON array in Redis Search. (Combined query not working on JSON Array objects). "And(&)" operation is not working on JSON Object with in the JSON Array. Instead it is working as "OR" across all the JSON objects of JSON array in Redis Search. Sep 17, 2024
@shashirangam shashirangam changed the title (Combined query not working on JSON Array objects). "And(&)" operation is not working on JSON Object with in the JSON Array. Instead it is working as "OR" across all the JSON objects of JSON array in Redis Search. (Combined query not working on JSON Array objects). "And(&)" operation is not working on JSON Object with in the one JSON Array. Instead it is working as "OR" across all the JSON objects of JSON array in Redis Search. Sep 17, 2024
@shashirangam shashirangam changed the title (Combined query not working on JSON Array objects). "And(&)" operation is not working on JSON Object with in the one JSON Array. Instead it is working as "OR" across all the JSON objects of JSON array in Redis Search. (Combined query not working on JSON Array objects). "And(&)" operation is not working on one JSON Object with in the JSON Array. Instead it is working as "OR" across all the JSON objects of JSON array in Redis Search. Sep 17, 2024
@shashirangam shashirangam changed the title (Combined query not working on JSON Array objects). "And(&)" operation is not working on one JSON Object with in the JSON Array. Instead it is working as "OR" across all the JSON objects of JSON array in Redis Search. (Combined query not working on JSON Array objects). "And(&)" operation is not working on each JSON Object with in the JSON Array. Instead it is working as "OR" across all the JSON objects of JSON array in Redis Search. Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant