index on values stored in a json array

From: Raphael Bauduin <rblists(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: index on values stored in a json array
Date: 2013-10-25 09:17:42
Message-ID: CAONrwUEJ2VuUS=5R1whJPcnZfOoPtfkonDgOBsedw6A48RVsCA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I have a table with a column of type json, in which arrays of products are
stored in the form:

{products: [ {id : 123 , name ='product1'}, {id: 214, name: 'product 2}],
size: 'XL'}

Is is possible to create an index on the row's products' ids?
I know I have to use GIN index, but I don't know how to collect the product
ids out of the array in the create index command.

Thanks in advance

raph

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jonathan S. Katz 2013-10-25 14:21:37 Re: index on values stored in a json array
Previous Message Jonathan S. Katz 2013-10-24 21:00:36 Re: Number of days in a tstzrange?