</listitem>
<listitem>
<para>
then has one or more labels, none of which
match <literal>football</literal> nor <literal>tennis</literal>
</para>
</listitem>
<listitem>
<para>
and then ends with a label beginning with <literal>Russ</literal> or
exactly matching <literal>Spain</literal>.
</para>
</listitem>
</orderedlist>
</listitem>
<listitem>
<para><type>ltxtquery</type> represents a full-text-search-like
pattern for matching <type>ltree</type> values. An
<type>ltxtquery</type> value contains words, possibly with the
modifiers <literal>@</literal>, <literal>*</literal>, <literal>%</literal> at the end;
the modifiers have the same meanings as in <type>lquery</type>.
Words can be combined with <literal>&</literal> (AND),
<literal>|</literal> (OR), <literal>!</literal> (NOT), and parentheses.
The key difference from
<type>lquery</type> is that <type>ltxtquery</type> matches words without
regard to their position in the label path.
</para>
<para>
Here's an example <type>ltxtquery</type>:
<programlisting>
Europe & Russia*@ & !Transportation
</programlisting>
This will match paths that contain the label <literal>Europe</literal> and
any label beginning with <literal>Russia</literal> (case-insensitive),
but not paths containing the label <literal>Transportation</literal>.
The location of these words within the path is not important.
Also, when <literal>%</literal> is used, the word can be matched to any
underscore-separated word within a label, regardless of position.
</para>
</listitem>
</itemizedlist>
<para>
Note: <type>ltxtquery</type> allows whitespace between symbols, but
<type>ltree</type> and <type>lquery</type> do not.
</para>
</sect2>
<sect2 id="ltree-ops-funcs">
<title>Operators and Functions</title>
<para>
Type <type>ltree</type> has the usual comparison operators
<literal>=</literal>, <literal><></literal>,
<literal><</literal>, <literal>></literal>, <literal><=</literal>, <literal>>=</literal>.
Comparison sorts in the order of a tree traversal, with the children
of a node sorted by label text. In addition, the specialized
operators shown in <xref linkend="ltree-op-table"/> are available.
</para>
<table id="ltree-op-table">
<title><type>ltree</type> Operators</title>
<tgroup cols="1">
<thead>
<row>
<entry role="func_table_entry"><para role="func_signature">
Operator
</para>
<para>
Description
</para></entry>
</row>
</thead>
<tbody>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>ltree</type> <literal>@></literal> <type>ltree</type>
<returnvalue>boolean</returnvalue>
</para>
<para>
Is left argument an ancestor of right (or equal)?
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>ltree</type> <literal><@</literal> <type>ltree</type>
<returnvalue>boolean</returnvalue>
</para>
<para>
Is left argument a descendant of right (or equal)?
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>ltree</type> <literal>~</literal> <type>lquery</type>
<returnvalue>boolean</returnvalue>
</para>
<para role="func_signature">
<type>lquery</type> <literal>~</literal> <type>ltree</type>
<returnvalue>boolean</returnvalue>
</para>
<para>
Does <type>ltree</type> match <type>lquery</type>?
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>ltree</type> <literal>?</literal> <type>lquery[]</type>
<returnvalue>boolean</returnvalue>