1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Add prefix support for synonym dictionary

This commit is contained in:
Teodor Sigaev
2009-08-14 14:53:20 +00:00
parent 0c738084fb
commit abd8c94ff9
5 changed files with 111 additions and 8 deletions

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/textsearch.sgml,v 1.52 2009/06/17 21:58:49 tgl Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/textsearch.sgml,v 1.53 2009/08/14 14:53:20 teodor Exp $ -->
<chapter id="textsearch">
<title id="textsearch-title">Full Text Search</title>
@ -2288,6 +2288,63 @@ SELECT * FROM ts_debug('english', 'Paris');
asciiword | Word, all ASCII | Paris | {my_synonym,english_stem} | my_synonym | {paris}
</programlisting>
</para>
<para>
An asterisk (<literal>*</literal>) at the end of definition word indicates
that definition word is a prefix, and <function>to_tsquery()</function>
function will transform that definition to the prefix search format (see
<xref linkend="textsearch-parsing-queries">).
Notice that it is ignored in <function>to_tsvector()</function>.
</para>
<para>
Contents of <filename>$SHAREDIR/tsearch_data/synonym_sample.syn</>:
</para>
<programlisting>
postgres pgsql
postgresql pgsql
postgre pgsql
gogle googl
indices index*
</programlisting>
<para>
Results:
</para>
<programlisting>
=# create text search dictionary syn( template=synonym,synonyms='synonym_sample');
=# select ts_lexize('syn','indices');
ts_lexize
-----------
{index}
(1 row)
=# create text search configuration tst ( copy=simple);
=# alter text search configuration tst alter mapping for asciiword with syn;
=# select to_tsquery('tst','indices');
to_tsquery
------------
'index':*
(1 row)
=# select 'indexes are very useful'::tsvector;
tsvector
---------------------------------
'are' 'indexes' 'useful' 'very'
(1 row)
=# select 'indexes are very useful'::tsvector @@ to_tsquery('tst','indices');
?column?
----------
t
(1 row)
=# select to_tsvector('tst','indices');
to_tsvector
-------------
'index':1
(1 row)
</programlisting>
<para>
The only parameter required by the <literal>synonym</> template is