Trouble with text search select statement - Mailing list pgsql-general

From Mont Rothstein
Subject Trouble with text search select statement
Date
Msg-id 467a83630804301641o5985186n4151e0f44a427e43@mail.gmail.com
Whole thread Raw
Responses Re: Trouble with text search select statement
List pgsql-general
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

pgsql-general by date:

Previous
From: "Ruben Guinez"
Date:
Subject: Full Text Search. In 8.3.1 How ?
Next
From: Klint Gore
Date:
Subject: Re: Trouble with text search select statement