diff --git a/doc/src/sgml/textsearch.sgml b/doc/src/sgml/textsearch.sgml index 7d11ffe0616..d813fbcaf8e 100644 --- a/doc/src/sgml/textsearch.sgml +++ b/doc/src/sgml/textsearch.sgml @@ -1,4 +1,4 @@ - + Full Text Search @@ -454,12 +454,12 @@ WHERE to_tsvector(body) @@ to_tsquery('friend'); SELECT title FROM pgweb -WHERE to_tsvector(title || body) @@ to_tsquery('create & table') +WHERE to_tsvector(title || ' ' || body) @@ to_tsquery('create & table') ORDER BY last_mod_date DESC LIMIT 10; - For clarity we omitted the coalesce function - which would be needed to search rows that contain NULL + For clarity we omitted the coalesce function calls + which would be needed to find rows that contain NULL in one of the two fields. @@ -526,7 +526,7 @@ CREATE INDEX pgweb_idx ON pgweb USING gin(to_tsvector(config_name, body)); Indexes can even concatenate columns: -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)); @@ -540,7 +540,7 @@ CREATE INDEX pgweb_idx ON pgweb USING gin(to_tsvector('english', title || body)) ALTER TABLE pgweb ADD COLUMN textsearchable_index_col tsvector; UPDATE pgweb SET textsearchable_index_col = - to_tsvector('english', coalesce(title,'') || coalesce(body,'')); + to_tsvector('english', coalesce(title,'') || ' ' || coalesce(body,'')); Then we create a GIN index to speed up the search: