1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-24 10:47:04 +03:00

Fix textsearch documentation examples to not recommend concatenating separate

fields without putting a space between.  Per gripe from Rick Schumeyer.
This commit is contained in:
Tom Lane 2009-04-19 20:36:06 +00:00
parent 1d97c19a0f
commit c1c40e580a

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/textsearch.sgml,v 1.49 2009/04/14 00:49:56 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/textsearch.sgml,v 1.50 2009/04/19 20:36:06 tgl Exp $ -->
<chapter id="textsearch"> <chapter id="textsearch">
<title id="textsearch-title">Full Text Search</title> <title id="textsearch-title">Full Text Search</title>
@ -454,12 +454,12 @@ WHERE to_tsvector(body) @@ to_tsquery('friend');
<programlisting> <programlisting>
SELECT title SELECT title
FROM pgweb FROM pgweb
WHERE to_tsvector(title || body) @@ to_tsquery('create &amp; table') WHERE to_tsvector(title || ' ' || body) @@ to_tsquery('create &amp; table')
ORDER BY last_mod_date DESC LIMIT 10; ORDER BY last_mod_date DESC LIMIT 10;
</programlisting> </programlisting>
For clarity we omitted the <function>coalesce</function> function For clarity we omitted the <function>coalesce</function> function calls
which would be needed to search rows that contain <literal>NULL</literal> which would be needed to find rows that contain <literal>NULL</literal>
in one of the two fields. in one of the two fields.
</para> </para>
@ -526,7 +526,7 @@ CREATE INDEX pgweb_idx ON pgweb USING gin(to_tsvector(config_name, body));
Indexes can even concatenate columns: Indexes can even concatenate columns:
<programlisting> <programlisting>
CREATE INDEX pgweb_idx ON pgweb USING gin(to_tsvector('english', title || body)); CREATE INDEX pgweb_idx ON pgweb USING gin(to_tsvector('english', title || ' ' || body));
</programlisting> </programlisting>
</para> </para>
@ -540,7 +540,7 @@ CREATE INDEX pgweb_idx ON pgweb USING gin(to_tsvector('english', title || body))
<programlisting> <programlisting>
ALTER TABLE pgweb ADD COLUMN textsearchable_index_col tsvector; ALTER TABLE pgweb ADD COLUMN textsearchable_index_col tsvector;
UPDATE pgweb SET textsearchable_index_col = UPDATE pgweb SET textsearchable_index_col =
to_tsvector('english', coalesce(title,'') || coalesce(body,'')); to_tsvector('english', coalesce(title,'') || ' ' || coalesce(body,''));
</programlisting> </programlisting>
Then we create a <acronym>GIN</acronym> index to speed up the search: Then we create a <acronym>GIN</acronym> index to speed up the search: