tsearch2 and case

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

tsearch2 and case

Uwe Schroeder-2

First of all: Happy Independence Day.

I've got a quick question for those with tsearch2 experience.
I set tsearch2 up and it works great (although I'd like to search for phrases
too, but I guess that's not supported at this time).
Anyways, I noted that the search seems to be case sensitive for some search
terms, particularly abbreviations. So if I'm searching with

to_tsquery('ABCD')  - where ABCD is a standard abbreviation, I get a lot of
hits, but I get none with to_tsquery('abcd') because the abbreviation is
always upper case in my text.

I'd like the search to be completely case insensitive. Can anyone point me in
the right direction?

Thanks for any help.

        UC

--
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone:  +1 650 872 2425 San Bruno, CA 94066
Cell:   +1 650 302 2405 United States
Fax:    +1 650 872 2417

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq
Reply | Threaded
Open this post in threaded view
|

Re: tsearch2 and case

Oleg Bartunov
On Mon, 4 Jul 2005, Uwe C. Schroeder wrote:

>
> First of all: Happy Independence Day.
>
> I've got a quick question for those with tsearch2 experience.
> I set tsearch2 up and it works great (although I'd like to search for phrases
> too, but I guess that's not supported at this time).
> Anyways, I noted that the search seems to be case sensitive for some search
> terms, particularly abbreviations. So if I'm searching with
>
> to_tsquery('ABCD')  - where ABCD is a standard abbreviation, I get a lot of
> hits, but I get none with to_tsquery('abcd') because the abbreviation is
> always upper case in my text.
>
> I'd like the search to be completely case insensitive. Can anyone point me in
> the right direction?

use your own dictionary ! Read gendict tutorial for details.
http://www.sai.msu.su/~megera/oddmuse/index.cgi/Gendict
I would create simple dictionary abbrev which recognize your abbreviations
and use it first before any other dicts. btw, if you did it general enough
please share with us, so other people could use it.

>
> Thanks for any help.
>
> UC
>
> --
> Open Source Solutions 4U, LLC 2570 Fleetwood Drive
> Phone:  +1 650 872 2425 San Bruno, CA 94066
> Cell:   +1 650 302 2405 United States
> Fax:    +1 650 872 2417
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>               http://www.postgresql.org/docs/faq
>

  Regards,
  Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: [hidden email], http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [hidden email])
Reply | Threaded
Open this post in threaded view
|

Re: tsearch2 and case

Greg Stark-3
Oleg Bartunov <[hidden email]> writes:

> > I'd like the search to be completely case insensitive. Can anyone point me in
> > the right direction?
>
> use your own dictionary ! Read gendict tutorial for details.
> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Gendict
> I would create simple dictionary abbrev which recognize your abbreviations
> and use it first before any other dicts. btw, if you did it general enough
> please share with us, so other people could use it.

Do functional indexes interact well with tsearch? Couldn't you just make your
index on lower(col) and then do to_tsquery(lower('ABCD')) ?


--
greg


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Reply | Threaded
Open this post in threaded view
|

Re: tsearch2 and case

Mike Rylander
In reply to this post by Uwe Schroeder-2
On 7/4/05, Uwe C. Schroeder <[hidden email]> wrote:
>
> First of all: Happy Independence Day.
>
> I've got a quick question for those with tsearch2 experience.
> I set tsearch2 up and it works great (although I'd like to search for phrases
> too, but I guess that's not supported at this time).

To do phrase searching just add an additional WHERE clause to your query:

SELECT id FROM tab WHERE ts_idx_col @@ to_tsquery('history&lesson')
AND text_col ~* '.*history\\s+lesson.*';

The full-text index will still be used, and the regex will be used to
prune the results afterwards.

--
Mike Rylander
[hidden email]
GPLS -- PINES Development
Database Developer
http://open-ils.org

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [hidden email]