Reputation: 15666
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?
Upvotes: 0
Views: 22
Reputation: 246473
What about the containment operator @>
:
SELECT *
FROM product
WHERE product.data @> '{"availability": [ { "price": 28990 } ] }';
Upvotes: 1