Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Re: Trouble wit...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 3 Topic 15429 of 17602
Post > Topic >>

Re: Trouble with text search select statement

by kgore4@[EMAIL PROTECTED] (Klint Gore) May 1, 2008 at 12:45 PM

Mont Rothstein wrote:
> 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, '')) @[EMAIL PROTECTED]
 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, '')) 
> @[EMAIL PROTECTED]
 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.
'' isn't supposed to to be the empty string, it's supposed to be a 
quoted space.  to_tsvector separates on whitespace. So with the space, 
it will have the words bird and moon.Without the space, it will have the 
single word birdmoon.

klint.

-- 
Klint Gore
Database Manager
Sheep CRC
A.G.B.U.
University of New England
Armidale NSW 2350

Ph: 02 6773 3789  
Fax: 02 6773 3266
EMail: kgore4@[EMAIL PROTECTED]
 
Sent via pgsql-general mailing list (pgsql-general@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
 




 3 Posts in Topic:
Trouble with text search select statement
mont.rothstein@[EMAIL PRO  2008-04-30 16:41:10 
Re: Trouble with text search select statement
kgore4@[EMAIL PROTECTED]   2008-05-01 12:45:41 
Re: Trouble with text search select statement
mont.rothstein@[EMAIL PRO  2008-04-30 20:23:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 18:49:30 CST 2008.