<entry>Name</entry>
<entry>Indexable Operators</entry>
</row>
</thead>
<tbody>
<row>
<entry morerows="3" valign="middle"><literal>array_ops</literal></entry>
<entry><literal>&& (anyarray,anyarray)</literal></entry>
</row>
<row>
<entry><literal>@> (anyarray,anyarray)</literal></entry>
</row>
<row>
<entry><literal><@ (anyarray,anyarray)</literal></entry>
</row>
<row>
<entry><literal>= (anyarray,anyarray)</literal></entry>
</row>
<row>
<entry morerows="5" valign="middle"><literal>jsonb_ops</literal></entry>
<entry><literal>@> (jsonb,jsonb)</literal></entry>
</row>
<row>
<entry><literal>@? (jsonb,jsonpath)</literal></entry>
</row>
<row>
<entry><literal>@@ (jsonb,jsonpath)</literal></entry>
</row>
<row>
<entry><literal>? (jsonb,text)</literal></entry>
</row>
<row>
<entry><literal>?| (jsonb,text[])</literal></entry>
</row>
<row>
<entry><literal>?& (jsonb,text[])</literal></entry>
</row>
<row>
<entry morerows="2" valign="middle"><literal>jsonb_path_ops</literal></entry>
<entry><literal>@> (jsonb,jsonb)</literal></entry>
</row>
<row>
<entry><literal>@? (jsonb,jsonpath)</literal></entry>
</row>
<row>
<entry><literal>@@ (jsonb,jsonpath)</literal></entry>
</row>
<row>
<entry valign="middle"><literal>tsvector_ops</literal></entry>
<entry><literal>@@ (tsvector,tsquery)</literal></entry>
</row>
</tbody>
</tgroup>
</table>
<para>
Of the two operator classes for type <type>jsonb</type>, <literal>jsonb_ops</literal>
is the default. <literal>jsonb_path_ops</literal> supports fewer operators but
offers better performance for those operators.
See <xref linkend="json-indexing"/> for details.
</para>
</sect2>
<sect2 id="gin-extensibility">
<title>Extensibility</title>
<para>
The <acronym>GIN</acronym> interface has a high level of abstraction,
requiring the access method implementer only to implement the semantics of
the data type being accessed. The <acronym>GIN</acronym> layer itself
takes care of concurrency, logging and searching the tree structure.
</para>
<para>
All it takes to get a <acronym>GIN</acronym> access method working is to
implement a few user-defined methods, which define the behavior of
keys in the tree and the relationships between keys, indexed items,
and indexable queries. In short, <acronym>GIN</acronym> combines
extensibility with generality, code reuse, and a clean interface.
</para>
<para>
There are two methods that an operator class for
<acronym>GIN</acronym> must provide:
<variablelist>
<varlistentry>
<term><function>Datum *extractValue(Datum itemValue, int32 *nkeys,
bool **nullFlags)</function></term>
<listitem>
<para>
Returns a palloc'd array of keys given an item to be indexed. The
number of returned keys must be stored into <literal>*nkeys</literal>.
If any of the keys can be null, also palloc an array of
<literal>*nkeys</literal> <type>bool</type> fields, store its address at
<literal>*nullFlags</literal>, and set these null flags as needed.
<literal>*nullFlags</literal> can be left <symbol>NULL</symbol> (its initial value)
if all keys are non-null.
The return value can be <symbol>NULL</symbol> if the item contains no keys.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><function>Datum *extractQuery(Datum query, int32 *nkeys,
StrategyNumber n, bool **pmatch, Pointer **extra_data,
bool **nullFlags, int32 *searchMode)</function></term>
<listitem>
<para>
Returns a palloc'd array of keys given a value to be queried; that is,
<literal>query</literal> is the value on the right-hand side of an
indexable operator