0

json

{ "availability": [{ "qty": 25, "price": 28990, "is_available": true }, { "qty": 72, "price": 28990, "is_available": true } ] } 

Full text search to find value or node price = 28990 in first array item I use this:

select * from product where to_tsvector(product.data #>> '{availability, 0, price}') @@ to_tsquery('28990') 

Nice.

But I need to find not only it in the first array's item. I need to find it in all items in array. Smt like this (pseudo code):

 select * from product where to_tsvector(product.data #>> '{availability, ... , price}') @@ to_tsquery('28990') 

Is it possible?

1
  • Full text search is the wrong tool for that Commented Aug 20, 2020 at 12:16

1 Answer 1

1

What about the containment operator @>:

SELECT * FROM product WHERE product.data @> '{"availability": [ { "price": 28990 } ] }'; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.