Filtering by values in a JSONB list with pattern matching operators? #3409
Answered
by
laurenceisla
SpiritQuaddicted
asked this question in
Q&A
-
My table has a field called
Is it possible to query this array with the pattern matching operators (like, ilike, match, imatch)? E.g. I would like to get all results that have any entries matching |
Beta Was this translation helpful? Give feedback.
Answered by
laurenceisla
Apr 16, 2024
Replies: 1 comment
-
I don't think that's possible to do directly. This looks like a case for JSON Path, which is not provided by PostgREST out of the box. You need to use a select *
from tbl
where metadata @@ '$.tags[*] ? (@ starts with "b=2024" || @ starts with "c=.")'; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
wolfgangwalther
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't think that's possible to do directly. This looks like a case for JSON Path, which is not provided by PostgREST out of the box. You need to use a
FUNCTION
orVIEW
to get a filter like this: