Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/ltree.sgml`
2f80e8efe5fa901da02b0c05c3e792b94d95d718e249fe180000000100000fad
 </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>&amp;</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 &amp; Russia*@ &amp; !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>&lt;&gt;</literal>,
   <literal>&lt;</literal>, <literal>&gt;</literal>, <literal>&lt;=</literal>, <literal>&gt;=</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>@&gt;</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>&lt;@</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>

Title: ltree Operators and Functions
Summary
The ltree data type has various operators and functions, including comparison operators, specialized operators for ancestor and descendant relationships, and a match operator for lquery patterns, allowing for efficient querying and manipulation of hierarchical data.