Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxtJS-0006rI-AN for pgsql-novice@arkaria.postgresql.org; Thu, 16 Dec 2021 16:08:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mxtJR-0006p7-64 for pgsql-novice@arkaria.postgresql.org; Thu, 16 Dec 2021 16:08:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxtJQ-0006oy-S9 for pgsql-novice@lists.postgresql.org; Thu, 16 Dec 2021 16:08:56 +0000 Received: from mail-ua1-x929.google.com ([2607:f8b0:4864:20::929]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mxtJO-00046w-UQ for pgsql-novice@lists.postgresql.org; Thu, 16 Dec 2021 16:08:56 +0000 Received: by mail-ua1-x929.google.com with SMTP id y22so12027621uap.2 for ; Thu, 16 Dec 2021 08:08:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Wv0G9kV4c61V/WQHQh/qjBj5hm8uY4KiDskP3wBCeVw=; b=KdjIrpmvScr+pytGj59SbzkHDadBYLzm9wLVUYCSsH7hU0GUDshVqrw9o/QwokqhZx ZO7XNg55RY+Y+BYVt2kfTgMG1tXZJPK50ZiS+wf6zzHneDcyrm8NXJPDz+CJQYcs6zeB 2gI7vbFG4x+kTW947h3s0LKLrI1La/lrzF11rQLdFXomz/FPhMTFVTqX+teuQrYV1ydO cRP4Tb8bpQqMAP2UnpSgxI2MbcLRAd7CZKQZZRn/o1YGqWcPrhhv3lEJ19xw+z9/ngBs qRSSURHEB+v2sQ6YcUn4CWF2Ixt2omYPUhte811O/usXONVIAs2f3vobUl3Z5n39t5bN 2Dag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Wv0G9kV4c61V/WQHQh/qjBj5hm8uY4KiDskP3wBCeVw=; b=bp7dZsbYitK0HJljof3Ze9YgiiVfkWTvtw0fCeiHhHcaWKv7jINeWkBEOAMrErokWC +a4dNbxtKz7Byvk/SfayLzTBbkLsU6jbNfjwMhK4Wc78xHtpqybbmCL1Vx78HMQqxqMx jkFK72CLbvqSk6GFZs9XLY3xajK9ZJ8Xs0rvkJV/g9HkqOZPzTaXTmthXt5tDQ3+MTeO dG/jJHhCALiarIvwQ9+qCPNL4AkxcikrqIMO84Q7+GQeQnBKvBl0e532G3LYLIW3iMzR XWIWXCds4dPDNbOX6BK2NzcIDxcuKrzQeQXVt1A8ZdMEn6h/MmO9xAI3VqPmgfLc32DG Wrkw== X-Gm-Message-State: AOAM533+Y2hC/zCL0ZbRUeA4NtHWKI5E8ONmdld50Rs/rohFrdgSN7Gh pu6YwjSvOwfVXthBvHuZcSgBE4UUK18ad86AV8XjONZf X-Google-Smtp-Source: ABdhPJxF9ir967FPhoJZ6KfBZag7JW6ofCmkCClunFn6wvaC6T1Qdp1VxusXaXO0VkwKDisvx6yf5bOGeMnx3aiz/3U= X-Received: by 2002:a05:6102:a4a:: with SMTP id i10mr5832769vss.47.1639670932906; Thu, 16 Dec 2021 08:08:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "David G. Johnston" Date: Thu, 16 Dec 2021 09:08:36 -0700 Message-ID: Subject: Re: JSONpath query that returns paths to the matches To: Alex R Cc: pgsql-novice Content-Type: multipart/alternative; boundary="00000000000081273505d345a316" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000081273505d345a316 Content-Type: text/plain; charset="UTF-8" On Thu, Dec 16, 2021 at 8:57 AM Alex R 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. --00000000000081273505d345a316 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Dec 16, 2021 at 8:57 AM Alex R <ralienpp@gmail.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 ava= ilable out of the box? If not, what would be a sane way of implementing it?=

1. Not that I can see documente= d.

2a See if some other language that has a PL extensi= on for PostgreSQL can do this more easily and write a function in the langu= age.
2b Create a custom C language function based off of one of the= existing "path exists" functions that keeps track of its positio= n 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 per= forms the graph traversal and captures the data like in 2b.

David J.

--00000000000081273505d345a316--