public inbox for [email protected]
help / color / mirror / Atom feedFrom: David E. Wheeler <[email protected]>
To: Erik Wienhold <[email protected]>
Cc: [email protected]
Subject: Re: JSON Path and GIN Questions
Date: Sat, 16 Sep 2023 16:26:07 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
On Sep 12, 2023, at 21:00, Erik Wienhold <[email protected]> wrote:
>> 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
I’ve started work on this; there’s so much to learn! Here’s a new example that surprised me a bit. Using the GPS tracker example from the docs [1] loaded into a `:json` psql variable, this output of this query makes perfect sense to me:
david=# select jsonb_path_query(:'json', '$.track.segments.location[*] ? (@ < 14)');
jsonb_path_query
------------------
13.4034
13.2635
Because `[*]` selects all the values. This, however, I did not expect:
david=# select jsonb_path_query(:'json', '$.track.segments.location ? (@[*] < 14)');
jsonb_path_query
------------------
13.4034
13.2635
(2 rows)
I had expected it to return two single-value arrays, instead:
[13.4034]
[13.2635]
It appears that the filter expression is doing some sub-selection, too. Is that expected?
Best,
David
[1]: https://www.postgresql.org/docs/current/functions-json.html#FUNCTIONS-SQLJSON-PATH
Attachments:
[application/pgp-signature] signature.asc (833B, ../[email protected]/2-signature.asc)
download
view thread (11+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: JSON Path and GIN Questions
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox