<para>
Returns a number that indicates how similar the two arguments are.
The range of the result is zero (indicating that the two strings are
completely dissimilar) to one (indicating that the two strings are
identical).
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>show_trgm</primary></indexterm>
<function>show_trgm</function> ( <type>text</type> )
<returnvalue>text[]</returnvalue>
</para>
<para>
Returns an array of all the trigrams in the given string.
(In practice this is seldom useful except for debugging.)
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>word_similarity</primary></indexterm>
<function>word_similarity</function> ( <type>text</type>, <type>text</type> )
<returnvalue>real</returnvalue>
</para>
<para>
Returns a number that indicates the greatest similarity between
the set of trigrams in the first string and any continuous extent
of an ordered set of trigrams in the second string. For details, see
the explanation below.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>strict_word_similarity</primary></indexterm>
<function>strict_word_similarity</function> ( <type>text</type>, <type>text</type> )
<returnvalue>real</returnvalue>
</para>
<para>
Same as <function>word_similarity</function>, but forces
extent boundaries to match word boundaries. Since we don't have
cross-word trigrams, this function actually returns greatest similarity
between first string and any continuous extent of words of the second
string.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>show_limit</primary></indexterm>
<function>show_limit</function> ()
<returnvalue>real</returnvalue>
</para>
<para>
Returns the current similarity threshold used by the <literal>%</literal>
operator. This sets the minimum similarity between
two words for them to be considered similar enough to
be misspellings of each other, for example.
(<emphasis>Deprecated</emphasis>; instead use <command>SHOW</command>
<varname>pg_trgm.similarity_threshold</varname>.)
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>set_limit</primary></indexterm>
<function>set_limit</function> ( <type>real</type> )
<returnvalue>real</returnvalue>
</para>
<para>
Sets the current similarity threshold that is used by the <literal>%</literal>
operator. The threshold must be between 0 and 1 (default is 0.3).
Returns the same value passed in.
(<emphasis>Deprecated</emphasis>; instead use <command>SET</command>
<varname>pg_trgm.similarity_threshold</varname>.)
</para></entry>
</row>
</tbody>
</tgroup>
</table>
<para>
Consider the following example:
<programlisting>
# SELECT word_similarity('word', 'two words');
word_similarity
-----------------
0.8
(1 row)
</programlisting>
In the first string, the set of trigrams is
<literal>{" w"," wo","wor","ord","rd "}</literal>.
In the second string, the ordered set of trigrams is
<literal>{" t"," tw","two","wo "," w"," wo","wor","ord","rds","ds "}</literal>.
The most similar extent of an ordered set of trigrams in the second string
is <literal>{" w"," wo","wor","ord"}</literal>, and the similarity is
<literal>0.8</literal>.
</para>
<para>
This function returns