Re: In need of some JSONB examples ?

From: Tim Smith <randomdev4+postgres(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: In need of some JSONB examples ?
Date: 2015-01-23 18:15:59
Message-ID: CA+HuS5HD3zh41h8m==24gEN56UvCdN21KMn-DM-tw+dRKJ4XBA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> How does it not work?
> In other words what was the query you tried and what was the output?

As in, it doesn't work. Full stop....

\d+ json_test
Table "public.json_test"
Column | Type | Modifiers | Storage | Stats target | Description
---------+-------+-----------+----------+--------------+-------------
content | jsonb | not null | extended | |
Indexes:
"idxgin" gin (content)

truncate json_test;
TRUNCATE TABLE
insert into json_test(content) values('[{"ID": "3119","Desc":"bob"}]');
INSERT 0 1

select content->'Desc' from json_test where content @> '{"ID":"3119"}';
?column?
----------
(0 rows)

On 23 January 2015 at 15:50, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> wrote:
> On 01/23/2015 07:40 AM, Tim Smith wrote:
>>
>> re: (a)
>>
>>> see the documentation pertaining to 'jsonb indexing', to wit:
>>>
>>> -- Find documents in which the key "company" has value "Magnafone"
>>> SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @> '{"company":
>>> "Magnafone"}';
>>
>>
>> Nope, sorry, tried that. Doesn't work for me. Hence the question. ;-)
>
>
> How does it not work?
> In other words what was the query you tried and what was the output?
>
>
>
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2015-01-23 18:49:49 Re: In need of some JSONB examples ?
Previous Message Christophe Pettus 2015-01-23 17:32:54 Re: In need of some JSONB examples ?