<function>plainto_tsquery</function>.
</para>
</listitem>
<listitem>
<para>
<literal>"quoted text"</literal>: text inside quote marks will be
converted to terms separated by <literal><-></literal>
operators, as if processed by <function>phraseto_tsquery</function>.
</para>
</listitem>
<listitem>
<para>
<literal>OR</literal>: the word <quote>or</quote> will be converted to
the <literal>|</literal> operator.
</para>
</listitem>
<listitem>
<para>
<literal>-</literal>: a dash will be converted to
the <literal>!</literal> operator.
</para>
</listitem>
</itemizedlist>
Other punctuation is ignored. So
like <function>plainto_tsquery</function>
and <function>phraseto_tsquery</function>,
the <function>websearch_to_tsquery</function> function will not
recognize <type>tsquery</type> operators, weight labels, or prefix-match
labels in its input.
</para>
<para>
Examples:
<screen>
SELECT websearch_to_tsquery('english', 'The fat rats');
websearch_to_tsquery
----------------------
'fat' & 'rat'
(1 row)
SELECT websearch_to_tsquery('english', '"supernovae stars" -crab');
websearch_to_tsquery
----------------------------------
'supernova' <-> 'star' & !'crab'
(1 row)
SELECT websearch_to_tsquery('english', '"sad cat" or "fat rat"');
websearch_to_tsquery
-----------------------------------
'sad' <-> 'cat' | 'fat' <-> 'rat'
(1 row)
SELECT websearch_to_tsquery('english', 'signal -"segmentation fault"');
websearch_to_tsquery
---------------------------------------
'signal' & !( 'segment' <-> 'fault' )
(1 row)
SELECT websearch_to_tsquery('english', '""" )( dummy \\ query <->');
websearch_to_tsquery
----------------------
'dummi' & 'queri'
(1 row)
</screen>
</para>
</sect2>
<sect2 id="textsearch-ranking">
<title>Ranking Search Results</title>
<para>
Ranking attempts to measure how relevant documents are to a particular
query, so that when there are many matches the most relevant ones can be
shown first. <productname>PostgreSQL</productname> provides two
predefined ranking functions, which take into account lexical, proximity,
and structural information; that is, they consider how often the query
terms appear in the document, how close together the terms are in the
document, and how important is the part of the document where they occur.
However, the concept of relevancy is vague and very application-specific.
Different applications might require additional information for ranking,
e.g., document modification time. The built-in ranking functions are only
examples. You can write your own ranking functions and/or combine their
results with additional factors to fit your specific needs.
</para>
<para>
The two ranking functions currently available are:
<variablelist>
<varlistentry>
<term>
<indexterm>
<primary>ts_rank</primary>
</indexterm>
<literal>ts_rank(<optional> <replaceable class="parameter">weights</replaceable> <type>float4[]</type>, </optional> <replaceable class="parameter">vector</replaceable> <type>tsvector</type>, <replaceable class="parameter">query</replaceable> <type>tsquery</type> <optional>, <replaceable class="parameter">normalization</replaceable> <type>integer</type> </optional>) returns <type>float4</type></literal>
</term>
<listitem>
<para>
Ranks vectors based on the frequency of their matching lexemes.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<indexterm>
<primary>ts_rank_cd</primary>
</indexterm>
<literal>ts_rank_cd(<optional> <replaceable class="parameter">weights</replaceable> <type>float4[]</type>, </optional> <replaceable class="parameter">vector</replaceable>