index on values stored in a json array - Mailing list pgsql-sql

From Raphael Bauduin
Subject index on values stored in a json array
Date
Msg-id CAONrwUEJ2VuUS=5R1whJPcnZfOoPtfkonDgOBsedw6A48RVsCA@mail.gmail.com
Whole thread
Responses Re: index on values stored in a json array
List 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

pgsql-sql by date:

Previous
From: "Jonathan S. Katz"
Date:
Subject: Re: Number of days in a tstzrange?
Next
From: "Jonathan S. Katz"
Date:
Subject: Re: index on values stored in a json array