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 > Trouble with te...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 15429 of 16159
Post > Topic >>

Trouble with text search select statement

by mont.rothstein@[EMAIL PROTECTED] ("Mont Rothstein") Apr 30, 2008 at 04:41 PM

------=_Part_2357_23839234.1209598870076
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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]
('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

------=_Part_2357_23839234.1209598870076
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I am having trouble getting a multiple column text search select statement
to work.<br><br>I&#39;ve setup the following:<br><br><span
style="font-family: courier new,monospace;">CREATE TABLE tstest (col1
text, col2 text);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">INSERT INTO tstest
(col1, col2) VALUES (&#39;bird&#39;, &#39;moon&#39;);</span><br
style="font-family: courier new,monospace;"><span style="font-family:
courier new,monospace;">CREATE INDEX tstest_ts_idx ON tstest USING
gin(to_tsvector(&#39;english&#39;, coalesce(col1, &#39;&#39;) ||
&#39;&#39; || coalesce(col2, &#39;&#39;)));</span><br style="font-family:
courier new,monospace;">
<br>I then execute what I believe is the correct select
statement:<br><br><span style="font-family: courier new,monospace;">SELECT
* FROM tstest WHERE to_tsvector(&#39;english&#39;, coalesce(col1,
&#39;&#39;) || &#39;&#39; || coalesce(col2, &#39;&#39;)) @[EMAIL PROTECTED]
(&#39;english&#39;, &#39;bird&#39;);</span><br
style="font-family: courier new,monospace;">
<br>If I remove the second column from the to_tsvector in the select
statement then it returns the row.<br><br><span style="font-family:
courier new,monospace;">SELECT * FROM tstest
WHERE to_tsvector(&#39;english&#39;, coalesce(col1, &#39;&#39;)) @[EMAIL PROTECTED]
(&#39;english&#39;, &#39;bird&#39;);</span><br
style="font-family: courier new,monospace;">
<br>I know I&#39;ve missed something basic but I can&#39;t figure out
what.<br><br>As a side note I don&#39;t understand the purpose of the ||
&#39;&#39; || between the columns in the to_tsvector.&nbsp; I saw it in
several examples.&nbsp; I&#39;ve tried both with and without it with no
change.<br>
<br>Thanks in advance.<br><br>-Mont<br><br>

------=_Part_2357_23839234.1209598870076--
 




 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
tan13V112 Thu Jul 24 1:53:09 CDT 2008.