Gin (Generalized Inverted Index)

PostgreSQL Full Text Search Gin (Generalized Inverted Index) Index

https://www.postgresql.org/docs/current/gin.html

CREATE INDEX name ON table USING GIN (column);

Scenario

  • array
  • json object

Data type

  • hstore
  • json
  • jsonb

Built-in Operator Classes

https://www.postgresql.org/docs/current/gin-builtin-opclasses.html

array_ops

Indexable Operators
&& (anyarray,anyarray)
@> (anyarray,anyarray)
<@ (anyarray,anyarray)
= (anyarray,anyarray)

jsonb_ops

Indexable Operators
@> (jsonb,jsonb)
@? (jsonb,jsonpath)
@@ (jsonb,jsonpath)
? (jsonb,text)
`?
?& (jsonb,text[])

jsonb_path_ops

Indexable Operators
@> (jsonb,jsonb)
@? (jsonb,jsonpath)
@@ (jsonb,jsonpath)

tsvector_ops

Indexable Operators
@@ (tsvector,tsquery)
@@@ (tsvector,tsquery)

Reference