- • Two types for JSONB fields (k/v or just v)
- • Maps multiple values to a single document
INSERT INTO whisky VALUES( '{
"name" : "Glen 25",
"slug" : "glen-albyn-glen-25",
"words" : [ "glen", "albyn", "25" ],
}' );
Key/Value match
CREATE INDEX idxgin ON whisky USING *GIN (properties)*;
SELECT \* FROM whisky WHERE properties *@> '{"slug": "glen-albyn-glen-25"}'*;
Array contains match
CREATE INDEX idxgin ON whisky USING GIN (*( properties -> 'words' )*);
SELECT \* FROM whisky WHERE properties -> 'words' *?* 'albyn';