1- <!-- $PostgreSQL: pgsql/doc/src/sgml/textsearch.sgml,v 1.49 2009/04/14 00:49:56 tgl Exp $ -->
1+ <!-- $PostgreSQL: pgsql/doc/src/sgml/textsearch.sgml,v 1.50 2009/04/19 20:36:06 tgl Exp $ -->
22
33<chapter id="textsearch">
44 <title id="textsearch-title">Full Text Search</title>
@@ -454,12 +454,12 @@ WHERE to_tsvector(body) @@ to_tsquery('friend');
454454<programlisting>
455455SELECT title
456456FROM pgweb
457- WHERE to_tsvector(title || body) @@ to_tsquery('create & table')
457+ WHERE to_tsvector(title ||' ' || body) @@ to_tsquery('create & table')
458458ORDER BY last_mod_date DESC LIMIT 10;
459459</programlisting>
460460
461- For clarity we omitted the <function>coalesce</function> function
462- which would be needed tosearch rows that contain <literal>NULL</literal>
461+ For clarity we omitted the <function>coalesce</function> function calls
462+ which would be needed tofind rows that contain <literal>NULL</literal>
463463 in one of the two fields.
464464 </para>
465465
@@ -526,7 +526,7 @@ CREATE INDEX pgweb_idx ON pgweb USING gin(to_tsvector(config_name, body));
526526 Indexes can even concatenate columns:
527527
528528<programlisting>
529- CREATE INDEX pgweb_idx ON pgweb USING gin(to_tsvector('english', title || body));
529+ CREATE INDEX pgweb_idx ON pgweb USING gin(to_tsvector('english', title ||' ' || body));
530530</programlisting>
531531 </para>
532532
@@ -540,7 +540,7 @@ CREATE INDEX pgweb_idx ON pgweb USING gin(to_tsvector('english', title || body))
540540<programlisting>
541541ALTER TABLE pgweb ADD COLUMN textsearchable_index_col tsvector;
542542UPDATE pgweb SET textsearchable_index_col =
543- to_tsvector('english', coalesce(title,'') || coalesce(body,''));
543+ to_tsvector('english', coalesce(title,'') ||' ' || coalesce(body,''));
544544</programlisting>
545545
546546 Then we create a <acronym>GIN</acronym> index to speed up the search: