public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G. Johnston <[email protected]>
To: Alex R <[email protected]>
Cc: pgsql-novice <[email protected]>
Subject: Re: JSONpath query that returns paths to the matches
Date: Thu, 16 Dec 2021 09:08:36 -0700
Message-ID: <CAKFQuwYVhCVwa0qfTfpvkziLnj_ogdpGruJhFqJ=Zig=n2+LuA@mail.gmail.com> (raw)
In-Reply-To: <CANK1NR1E1CyHcqF+xQvBYBY0+G4GGL_HKDDSad2am74zz_N3mg@mail.gmail.com>
References: <CANK1NR1E1CyHcqF+xQvBYBY0+G4GGL_HKDDSad2am74zz_N3mg@mail.gmail.com>

On Thu, Dec 16, 2021 at 8:57 AM Alex R <[email protected]> wrote:

> It returns 2 matches: "aaa" and "bbb". However, what I'd like to get
> instead is 2 paths that point to the matches, i.e.,:
> - $.that[0]
> - $.nested.deep
>
> Can this be accomplished using means that are available out of the box? If
> not, what would be a sane way of implementing it?
>

1. Not that I can see documented.

2a See if some other language that has a PL extension for PostgreSQL can do
this more easily and write a function in the language.
2b Create a custom C language function based off of one of the existing
"path exists" functions that keeps track of its position in the graph and
the returns that instead of a boolean/whatever.
2c Create your own procedural code, which can be done in pl/pgsql, that
performs the graph traversal and captures the data like in 2b.

David J.


view thread (3+ 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: JSONpath query that returns paths to the matches
  In-Reply-To: <CAKFQuwYVhCVwa0qfTfpvkziLnj_ogdpGruJhFqJ=Zig=n2+LuA@mail.gmail.com>

* 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