Hi,
The patch looks good.
Comments:
1. The docs should be clarified a little. For instance, it should have a
link back to the definition of a prefix search (12.3.2). I included my
doc suggestions as an attachment.
2. dsynonym_init() uses findwrd() in a slightly confusing (and perhaps
fragile) way. After calling findwrd(), the "end" pointer is pointing at
either the end of the string, or the *; depending on whether the string
ends in * and whether flags is NULL. I only mention this because I had
to take a more careful look to see what was happening. Perhaps add a
comment to make it more clear?
3. The patch looks for the special byte '*'. I think that's fine,
because we depend on the files being in UTF-8 encoding, where it's the
same byte. However, I thought it was worth mentioning in case we want to
support other encodings for text search files later.
Regards,
Jeff Davis
*** textsearch.sgml 2009-08-02 11:22:38.000000000 -0700
--- textsearch.sgml.new 2009-08-02 11:22:27.000000000 -0700
***************
*** 2290,2315 ****
</para>
<para>
! Star sign <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.
! Notice, it is ignored in <function>to_tsvector()</function>.
</para>
<programlisting>
- > cat $SHAREDIR/tsearch_data/synonym_sample.syn
- postgres pgsql
- postgresql pgsql
- postgre pgsql
- gogle googl
- indices index*
- > cat $SHAREDIR/tsearch_data/synonym_sample.syn
postgres pgsql
postgresql pgsql
postgre pgsql
gogle googl
indices index*
=# create text search dictionary syn( template=synonym,synonyms='synonym_sample');
=# select ts_lexize('syn','indices');
ts_lexize
--- 2290,2317 ----
</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
***************
*** 2324,2329 ****
--- 2326,2338 ----
------------
'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?
----------
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers