Re: JSON Path and GIN Questions
Erik Rijkers <er@xs4all.nl>
From: Erik Rijkers <er@xs4all.nl>
To: Erik Wienhold <ewie@ewie.name>, "David E. Wheeler"
<david@justatheory.com>, pgsql-hackers@lists.postgresql.org
Date: 2023-09-13T05:11:52Z
Lists: pgsql-hackers
Op 9/13/23 om 03:00 schreef Erik Wienhold: > Hi David, > > On 13/09/2023 02:16 CEST David E. Wheeler <david@justatheory.com> wrote: > >> CREATE TABLE MOVIES (id SERIAL PRIMARY KEY, movie JSONB NOT NULL); >> \copy movies(movie) from PROGRAM 'curl -s https://raw.githubusercontent.com/prust/wikipedia-movie-data/master/movies.json | jq -c ".[]" | sed "s|\\\\|\\\\\\\\|g"'; >> create index on movies using gin (movie); >> analyze movies; >> >> I have been confused as to the difference between @@ vs @?: Why do these >> return different results? >> >> david=# select id from movies where movie @@ '$ ?(@.title == "New Life Rescue")'; >> id >> ---- >> (0 rows) >> >> david=# select id from movies where movie @? '$ ?(@.title == "New Life Rescue")'; >> id >> ---- >> 10 >> (1 row) >> >> I posted this question on Stack Overflow (https://stackoverflow.com/q/77046554/79202), >> and from the suggestion I got there, it seems that @@ expects a boolean to be >> returned by the path query, while @? wraps it in an implicit exists(). Is that >> right? > > That's also my understanding. We had a discussion about the docs on @@, @?, and > jsonb_path_query on -general a while back [1]. Maybe it's useful also. > >> If so, I’d like to submit a patch to the docs talking about this, and >> suggesting the use of jsonb_path_query() to test paths to see if they return >> a boolean or not. > > +1 > > [1] https://www.postgresql.org/message-id/CACJufxE01sxgvtG4QEvRZPzs_roggsZeVvBSGpjM5tzE5hMCLA%40mail.gmail.com > > -- > Erik "All use of json*() functions preclude index usage." That sentence is missing from the documentation. Erik Rijkers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Doc: add a bit to indices.sgml about what is an indexable clause.
- b7412e293b6b 17.0 landed
- b4c147ac6fd5 13.14 landed
- afc987e19610 15.6 landed
- 8b9d39254816 16.2 landed
- 7a4bdd986ab9 14.11 landed
- 499342e81b0f 12.18 landed