Re: JSONpath query that returns paths to the matches

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Alex R <ralienpp(at)gmail(dot)com>
Cc: pgsql-novice <pgsql-novice(at)lists(dot)postgresql(dot)org>
Subject: Re: JSONpath query that returns paths to the matches
Date: 2021-12-16 16:08:36
Message-ID: CAKFQuwYVhCVwa0qfTfpvkziLnj_ogdpGruJhFqJ=Zig=n2+LuA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, Dec 16, 2021 at 8:57 AM Alex R <ralienpp(at)gmail(dot)com> 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.

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Alex R 2021-12-20 00:19:43 Re: JSONpath query that returns paths to the matches
Previous Message Alex R 2021-12-16 15:56:48 JSONpath query that returns paths to the matches