parts of a document to be weighted differently by ranking functions.
</para>
<para>
Note that weight labels apply to <emphasis>positions</emphasis>, not
<emphasis>lexemes</emphasis>. If the input vector has been stripped of
positions then <function>setweight</function> does nothing.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<indexterm>
<primary>length(tsvector)</primary>
</indexterm>
<literal>length(<replaceable class="parameter">vector</replaceable> <type>tsvector</type>) returns <type>integer</type></literal>
</term>
<listitem>
<para>
Returns the number of lexemes stored in the vector.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<indexterm>
<primary>strip</primary>
</indexterm>
<literal>strip(<replaceable class="parameter">vector</replaceable> <type>tsvector</type>) returns <type>tsvector</type></literal>
</term>
<listitem>
<para>
Returns a vector that lists the same lexemes as the given vector, but
lacks any position or weight information. The result is usually much
smaller than an unstripped vector, but it is also less useful.
Relevance ranking does not work as well on stripped vectors as
unstripped ones. Also,
the <literal><-></literal> (FOLLOWED BY) <type>tsquery</type> operator
will never match stripped input, since it cannot determine the
distance between lexeme occurrences.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
A full list of <type>tsvector</type>-related functions is available
in <xref linkend="textsearch-functions-table"/>.
</para>
</sect2>
<sect2 id="textsearch-manipulate-tsquery">
<title>Manipulating Queries</title>
<para>
<xref linkend="textsearch-parsing-queries"/> showed how raw textual
queries can be converted into <type>tsquery</type> values.
<productname>PostgreSQL</productname> also provides functions and
operators that can be used to manipulate queries that are already
in <type>tsquery</type> form.
</para>
<variablelist>
<varlistentry>
<term>
<literal><type>tsquery</type> && <type>tsquery</type></literal>
</term>
<listitem>
<para>
Returns the AND-combination of the two given queries.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<literal><type>tsquery</type> || <type>tsquery</type></literal>
</term>
<listitem>
<para>
Returns the OR-combination of the two given queries.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<literal>!! <type>tsquery</type></literal>
</term>
<listitem>
<para>
Returns the negation (NOT) of the given query.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<literal><type>tsquery</type> <-> <type>tsquery</type></literal>
</term>
<listitem>
<para>
Returns a query that searches for a match to the first given query
immediately followed by a match to the second given query, using
the <literal><-></literal> (FOLLOWED BY)
<type>tsquery</type> operator. For example:
<screen>
SELECT to_tsquery('fat') <-> to_tsquery('cat | rat');
?column?
----------------------------
'fat' <-> ( 'cat' | 'rat' )
</screen>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<indexterm>
<primary>tsquery_phrase</primary>
</indexterm>
<literal>tsquery_phrase(<replaceable class="parameter">query1</replaceable> <type>tsquery</type>, <replaceable class="parameter">query2</replaceable> <type>tsquery</type> [, <replaceable class="parameter">distance</replaceable> <type>integer</type> ]) returns <type>tsquery</type></literal>