From: | Oleg Bartunov <oleg(at)sai(dot)msu(dot)su> |
---|---|
To: | APseudoUtopia <apseudoutopia(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Full-Text Searching: to_tsquery() vs. plainto_tsquery() |
Date: | 2009-09-04 21:06:48 |
Message-ID: | Pine.LNX.4.64.0909050058250.6801@sn.sai.msu.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
APseudoUtopia,
you invented your own query language, so you should write your own
function, which transforms user's query to ::tsquery, if to_tsquery()
and plainto_tsquery() doesn't satisfy your input language.
Notice, that phrase search will be able only in 8.5 version.
Oleg
On Fri, 4 Sep 2009, APseudoUtopia wrote:
> Hello,
>
> I'm working on setting up a full-text search for some descriptions
> stored in my database. I'm running pg 8.4.
>
>> From what I can tell, there are two functions. One function,
> to_tsquery(), requires that boolean operators (&, |, !) are between
> every word. The other function, plainto_tsquery() does not accept
> boolean operators, and adds & between every word passed to it.
>
> It seems that these two functions only cover the extremes for
> full-text searching. I don't want to force my users to put in & or |
> in every single search they do, so to_tsquery() wont work. However, if
> they want to use something like "apples AND bananas" it will not work
> with plainto_tsquery(). How can I have a "normal" search on my site?
> Normal being defined as the following:
>
> -A search for `apples bananas` returns apples OR bananas (with results
> containing both ranked high)
> -A search for `apples AND bananas` returns results containing both.
> -A search for `apple*` returning results that contain apple, apples,
> applesauce, etc.
> -A search for `"Good Apples"` in quotes returning results that contain
> EXACTLY that phrase.
>
> This seems impossible to do with PostgreSQL with the full-text search
> functions provided without manually parsing the search string from the
> user in my code before querying the DB.
>
> However, even simply parsing the string has it's problems. Simply
> replacing spaces with " | " to OR search terms together and replacing
> "AND" with & would break the query apart due to formatting issues.
>
> How does everyone implement the typical boolean full-text search in
> their database?
>
>
Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru)
Sternberg Astronomical Institute, Moscow University, Russia
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83
From | Date | Subject | |
---|---|---|---|
Next Message | Vikram Patil | 2009-09-05 00:36:56 | Creating Superuser and password |
Previous Message | Christopher Condit | 2009-09-04 20:51:01 | Re: query speed question |