------=_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'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 ('bird', 'moon');</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('english', coalesce(col1, '') ||
'' || coalesce(col2, '')));</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('english', coalesce(col1,
'') || '' || coalesce(col2, '')) @[EMAIL PROTECTED]
('english', 'bird');</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('english', coalesce(col1, '')) @[EMAIL PROTECTED]
('english', 'bird');</span><br
style="font-family: courier new,monospace;">
<br>I know I've missed something basic but I can't figure out
what.<br><br>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.<br>
<br>Thanks in advance.<br><br>-Mont<br><br>
------=_Part_2357_23839234.1209598870076--


|