Search Postgresql Archives

Trouble with text search select statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am having trouble getting a multiple column text search select statement to work.

I've setup the following:

CREATE TABLE tstest (col1 text, col2 text);
INSERT INTO tstest (col1, col2) VALUES ('bird', 'moon');
CREATE INDEX tstest_ts_idx ON tstest USING gin(to_tsvector('english', coalesce(col1, '') || '' || coalesce(col2, '')));

I then execute what I believe is the correct select statement:

SELECT * FROM tstest WHERE to_tsvector('english', coalesce(col1, '') || '' || coalesce(col2, '')) @@ to_tsquery('english', 'bird');

If I remove the second column from the to_tsvector in the select statement then it returns the row.

SELECT * FROM tstest WHERE to_tsvector('english', coalesce(col1, '')) @@ to_tsquery('english', 'bird');

I know I've missed something basic but I can't figure out what.

As a side note I don't understand the purpose of the || '' || between the columns in the to_tsvector.  I saw it in several examples.  I've tried both with and without it with no change.

Thanks in advance.

-Mont


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux