Convert Simple Query into tsvector & tsquery format.

From: Adarsh Sharma <adarsh(dot)sharma(at)orkash(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Convert Simple Query into tsvector & tsquery format.
Date: 2011-03-18 07:00:50
Message-ID: 4D830322.6070204@orkash.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear all,

I have a simple query mentioned below :

select count(*) from page_content where (content like '%Militant%'
OR content like '%jihad%' OR content like '%Mujahid%' OR
content like '%fedayeen%' OR content like '%insurgent%' OR content
like '%terrORist%' OR
content like '%cadre%' OR content like '%civilians%' OR content like
'%police%' OR content like '%defence%' OR content like '%cops%' OR
content like '%crpf%' OR content like '%dsf%' OR content like '%ssb%')
AND (content like '%kill%' OR content like '%injure%');

I need to convert it into other format that use tsvector & tsquery for
Full-Text Searching.

I try and convert it like :

SELECT count(*) from page_content WHERE publishing_date like '%2010%' and
content_language='en' and content is not null and isprocessable = 1 and
to_tsvector('english',content) @@ to_tsquery('english','Mujahid' || ' | '

|| 'jihad' || ' | ' || 'Militant' || ' | ' || 'fedayeen' || ' | ' ||
'insurgent' || ' | ' || 'terrORist' || ' | ' || 'cadre'

|| ' | ' || 'civilians' || ' | ' || 'police' || ' | ' || 'cops' || ' |
' || 'crpf' || ' | ' || 'defence' || ' | ' || 'dsf' || ' | ' || 'ssb') ;

But not able to convert and use the condition

AND condition ( *AND (content like '%kill%' OR content like
'%injure%')* ) also.*

Please *help me , how to add this to the query.

Thanks & best Regards,
Adarsh Sharma

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Grzegorz Jaśkiewicz 2011-03-18 08:20:01 Re: triggers and FK cascades
Previous Message Joe Abbate 2011-03-18 04:49:44 Re: regclass and search_path