|
1 |
| -<!-- $PostgreSQL: pgsql/doc/src/sgml/textsearch.sgml,v 1.34 2007/11/14 23:43:27 tgl Exp $ --> |
| 1 | +<!-- $PostgreSQL: pgsql/doc/src/sgml/textsearch.sgml,v 1.35 2007/11/14 23:48:55 tgl Exp $ --> |
2 | 2 |
|
3 | 3 | <chapter id="textsearch">
|
4 | 4 | <title id="textsearch-title">Full Text Search</title>
|
@@ -538,23 +538,23 @@ CREATE INDEX pgweb_idx ON pgweb USING gin(to_tsvector('english', title || body))
|
538 | 538 | indexed when the other is <literal>NULL</>:
|
539 | 539 |
|
540 | 540 | <programlisting>
|
541 |
| -ALTER TABLE pgweb ADD COLUMNtextsearch_index tsvector; |
542 |
| -UPDATE pgweb SETtextsearch_index = |
| 541 | +ALTER TABLE pgweb ADD COLUMNtextsearchable_index_col tsvector; |
| 542 | +UPDATE pgweb SETtextsearchable_index_col = |
543 | 543 | to_tsvector('english', coalesce(title,'') || coalesce(body,''));
|
544 | 544 | </programlisting>
|
545 | 545 |
|
546 | 546 | Then we create a <acronym>GIN</acronym> index to speed up the search:
|
547 | 547 |
|
548 | 548 | <programlisting>
|
549 |
| -CREATE INDEX textsearch_idx ON pgweb USING gin(textsearch_index); |
| 549 | +CREATE INDEX textsearch_idx ON pgweb USING gin(textsearchable_index_col); |
550 | 550 | </programlisting>
|
551 | 551 |
|
552 | 552 | Now we are ready to perform a fast full text search:
|
553 | 553 |
|
554 | 554 | <programlisting>
|
555 | 555 | SELECT title
|
556 | 556 | FROM pgweb
|
557 |
| -WHERE to_tsquery('create & table') @@ textsearch_index |
| 557 | +WHEREtextsearchable_index_col @@to_tsquery('create & table') |
558 | 558 | ORDER BY last_mod_date DESC LIMIT 10;
|
559 | 559 | </programlisting>
|
560 | 560 | </para>
|
|