--- doc/src/sgml/textsearch.sgml.orig 2008-01-11 22:20:16.000000000 +0100
+++ doc/src/sgml/textsearch.sgml 2008-01-11 22:27:57.000000000 +0100
@@ -418,16 +418,16 @@
It is possible to do full text search with no index. A simple query
to print the title> of each row that contains the word
- friend> in its body> field is:
+ planet> in its body> field is:
SELECT title
-FROM pgweb
-WHERE to_tsvector('english', body) @@ to_tsquery('english', 'friend');
+FROM apod
+WHERE to_tsvector('english', body) @@ to_tsquery('english', 'planet');
- This will also find related words such as friends>
- and friendly>, since all these are reduced to the same
+ This will also find related words such as planets>
+ and planetary>, since all these are reduced to the same
normalized lexeme.
@@ -438,8 +438,8 @@
SELECT title
-FROM pgweb
-WHERE to_tsvector(body) @@ to_tsquery('friend');
+FROM apod
+WHERE to_tsvector(body) @@ to_tsquery('planet');
This query will use the configuration set by
A more complex example is to
- select the ten most recent documents that contain create> and
- table> in the title> or body>:
+ select the ten most recent documents that contain comet> and
+ tail> in the title> or body>:
SELECT title
-FROM pgweb
-WHERE to_tsvector(title || body) @@ to_tsquery('create & table')
-ORDER BY last_mod_date DESC LIMIT 10;
+FROM apod
+WHERE to_tsvector(title || body) @@ to_tsquery('comet & tail')
+ORDER BY sdate DESC LIMIT 10;
For clarity we omitted the coalesce function
@@ -480,7 +480,7 @@
linkend="textsearch-indexes">) to speed up text searches:
-CREATE INDEX pgweb_idx ON pgweb USING gin(to_tsvector('english', body));
+CREATE INDEX apod_idx ON apod USING gin(to_tsvector('english', body));
Notice that the 2-argument version of to_tsvector is
@@ -510,10 +510,10 @@
configuration name is specified by another column, e.g.:
-CREATE INDEX pgweb_idx ON pgweb USING gin(to_tsvector(config_name, body));
+CREATE INDEX apod_idx ON apod USING gin(to_tsvector(config_name, body));
- where config_name> is a column in the pgweb>
+ where config_name> is a column in the apod>
table. This allows mixed configurations in the same index while
recording which configuration was used for each index entry. This
would be useful, for example, if the document collection contained
@@ -526,7 +526,7 @@
Indexes can even concatenate columns:
-CREATE INDEX pgweb_idx ON pgweb USING gin(to_tsvector('english', title || body));
+CREATE INDEX apod_idx ON apod USING gin(to_tsvector('english', title || body));
@@ -538,24 +538,24 @@
indexed when the other is NULL>:
-ALTER TABLE pgweb ADD COLUMN textsearchable_index_col tsvector;
-UPDATE pgweb SET textsearchable_index_col =
+ALTER TABLE apod ADD COLUMN textsearch tsvector;
+UPDATE apod SET textsearch =
to_tsvector('english', coalesce(title,'') || coalesce(body,''));
Then we create a GIN index to speed up the search:
-CREATE INDEX textsearch_idx ON pgweb USING gin(textsearchable_index_col);
+CREATE INDEX textsearch_idx ON apod USING gin(textsearch);
Now we are ready to perform a fast full text search:
SELECT title
-FROM pgweb
-WHERE textsearchable_index_col @@ to_tsquery('create & table')
-ORDER BY last_mod_date DESC LIMIT 10;
+FROM apod
+WHERE textsearch @@ to_tsquery('comet & tail')
+ORDER BY sdate DESC LIMIT 10;
@@ -594,8 +594,7 @@
user query. Also, we need to return results in a useful order, so we need
a function that compares documents with respect to their relevance to
the query. It's also important to be able to display the results nicely.
- PostgreSQL provides support for all of these
- functions.
+ PostgreSQL provides all these functions.