pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Tsearch not searching 'Y'
5+ messages / 4 participants
[nested] [flat]

* Tsearch not searching 'Y'
@ 2010-04-29 13:13 sandeep prakash dhumale <sandy9940@rediffmail.com>
  2010-04-29 13:56 ` Re: [SQL] Tsearch not searching 'Y' Kenneth Marshall <ktm@rice.edu>
  2010-04-29 14:01 ` Re: Tsearch not searching 'Y' Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 5+ messages in thread

From: sandeep prakash dhumale @ 2010-04-29 13:13 UTC (permalink / raw)
  To: pgsql-sql; pgsql-general@postgresql.org

Hello All,

I am trying to get tsearch working for my application but I am facing a
problem when alphabet 'Y' is the in the tsquery.

can anyone please share some light on it.


# SELECT 'hollywood'::tsvector  @@ to_tsquery('holly:*');
 ?column?
----------
 f
(1 row)

SELECT 'hollywood'::tsvector  @@ to_tsquery('holl:*');
?column?
----------
 t
(1 row)


It works when i put &lt;&gt; in y as below but i don't want to do it that way.

SELECT 'hollywood'::tsvector  @@ to_tsquery('holl&lt;y&gt;:*');
 ?column?
----------
 t

Thanks in advance 

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [SQL] Tsearch not searching 'Y'
  2010-04-29 13:13 Tsearch not searching 'Y' sandeep prakash dhumale <sandy9940@rediffmail.com>
@ 2010-04-29 13:56 ` Kenneth Marshall <ktm@rice.edu>
  2010-04-29 14:14   `  Re: Re: [GENERAL] [SQL] Tsearch not searching 'Y' sandeep prakash dhumale <sandy9940@rediffmail.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Kenneth Marshall @ 2010-04-29 13:56 UTC (permalink / raw)
  To: sandeep prakash dhumale <sandy9940@rediffmail.com>; +Cc: pgsql-sql; pgsql-general@postgresql.org

On Thu, Apr 29, 2010 at 01:13:40PM -0000, sandeep prakash dhumale wrote:
> Hello All,
> 
> I am trying to get tsearch working for my application but I am facing a
> problem when alphabet 'Y' is the in the tsquery.
> 
> can anyone please share some light on it.
> 
> 
> # SELECT 'hollywood'::tsvector  @@ to_tsquery('holly:*');
>  ?column?
> ----------
>  f
> (1 row)
> 
> SELECT 'hollywood'::tsvector  @@ to_tsquery('holl:*');
> ?column?
> ----------
>  t
> (1 row)
> 
> 
> It works when i put &lt;&gt; in y as below but i don't want to do it that way.
> 
> SELECT 'hollywood'::tsvector  @@ to_tsquery('holl&lt;y&gt;:*');
>  ?column?
> ----------
>  t
> 
> Thanks in advance 

That is because the to_tsquery() normalizes the tokens. Here is
what I get from the default configuration:

db=# select to_tsquery('holly:*');
 to_tsquery 
------------
 'holli':*
(1 row)

db=# select to_tsquery('holl:*');
 to_tsquery 
------------
 'holl':*
(1 row)

It is pretty easy to see why you see the behavior that you do.
Maybe you need to change your tsearch configuration to match what
you expect to happen.

Regards,
Ken




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

*  Re: Re: [GENERAL] [SQL] Tsearch not searching 'Y'
  2010-04-29 13:13 Tsearch not searching 'Y' sandeep prakash dhumale <sandy9940@rediffmail.com>
  2010-04-29 13:56 ` Re: [SQL] Tsearch not searching 'Y' Kenneth Marshall <ktm@rice.edu>
@ 2010-04-29 14:14   ` sandeep prakash dhumale <sandy9940@rediffmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: sandeep prakash dhumale @ 2010-04-29 14:14 UTC (permalink / raw)
  To: ktm@rice.edu; +Cc: pgsql-sql; pgsql-general@postgresql.org

 

On Thu, 29 Apr 2010 19:27:33 +0530  wrote
&gt;On Thu, Apr 29, 2010 at 01:13:40PM -0000, sandeep prakash dhumale wrote:
&gt;&gt; Hello All,
&gt;&gt; 
&gt;&gt; I am trying to get tsearch working for my application but I am facing a
&gt;&gt; problem when alphabet 'Y' is the in the tsquery.
&gt;&gt; 
&gt;&gt; can anyone please share some light on it.
&gt;&gt; 
&gt;&gt; 
&gt;&gt; # SELECT 'hollywood'::tsvector @@ to_tsquery('holly:*');
&gt;&gt; ?column?
&gt;&gt; ----------
&gt;&gt; f
&gt;&gt; (1 row)
&gt;&gt; 
&gt;&gt; SELECT 'hollywood'::tsvector @@ to_tsquery('holl:*');
&gt;&gt; ?column?
&gt;&gt; ----------
&gt;&gt; t
&gt;&gt; (1 row)
&gt;&gt; 
&gt;&gt; 
&gt;&gt; It works when i put &lt;&gt; in y as below but i don't want to do it that way.
&gt;&gt; 
&gt;&gt; SELECT 'hollywood'::tsvector @@ to_tsquery('holl&lt;y&gt;:*');
&gt;&gt; ?column?
&gt;&gt; ----------
&gt;&gt; t
&gt;&gt; 
&gt;&gt; Thanks in advance 
&gt;
&gt;That is because the to_tsquery() normalizes the tokens. Here is
&gt;what I get from the default configuration:
&gt;
&gt;db=# select to_tsquery('holly:*');
&gt; to_tsquery 
&gt;------------
&gt; 'holli':*
&gt;(1 row)
&gt;
&gt;db=# select to_tsquery('holl:*');
&gt; to_tsquery 
&gt;------------
&gt; 'holl':*
&gt;(1 row)
&gt;
&gt;It is pretty easy to see why you see the behavior that you do.
&gt;Maybe you need to change your tsearch configuration to match what
&gt;you expect to happen.
&gt;
&gt;Regards,
&gt;Ken
&gt;
&gt;
&gt;-- 
&gt;Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
&gt;To make changes to your subscription:
&gt;http://www.postgresql.org/mailpref/pgsql-general
&gt;



First of all thanks for your replies Tom and Ken,

I am little newbie to Tsearch so I appologies if I sound a little confuse.

Tom: If i do by casting like you wrote then i ran into case sensitivity issue also then it does not work for other searches I guess then it sees for exact matches and not normalize to lexims.

Ken: As you said I need to change my configuration, It would be great if you can point me out where i can change that configuration 

and what about that&nbsp; &lt;y&gt; in the query how does it work, does that mean to explicitly include y in to_tsquery.


All your help is higly appriciated.


--Sandy

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Tsearch not searching 'Y'
  2010-04-29 13:13 Tsearch not searching 'Y' sandeep prakash dhumale <sandy9940@rediffmail.com>
@ 2010-04-29 14:01 ` Tom Lane <tgl@sss.pgh.pa.us>
  2010-04-29 17:48   ` Re: [SQL] Tsearch not searching 'Y' John Gage <jsmgage@numericable.fr>
  1 sibling, 1 reply; 5+ messages in thread

From: Tom Lane @ 2010-04-29 14:01 UTC (permalink / raw)
  To: sandeep prakash dhumale <sandy9940@rediffmail.com>; +Cc: pgsql-sql; pgsql-general@postgresql.org

"sandeep prakash dhumale" <sandy9940@rediffmail.com> writes:
> I am trying to get tsearch working for my application but I am facing a
> problem when alphabet 'Y' is the in the tsquery.

> # SELECT 'hollywood'::tsvector  @@ to_tsquery('holly:*');
>  ?column?
> ----------
>  f
> (1 row)

You can't use to_tsquery for this sort of thing, because it tries to
normalize the given words:

regression=# select to_tsquery('holly:*');
 to_tsquery 
------------
 'holli':*
(1 row)

If you do this it works:

regression=# SELECT 'hollywood'::tsvector  @@ 'holly:*'::tsquery;
 ?column? 
----------
 t
(1 row)

So if you want to use prefix matching, don't normalize.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [SQL] Tsearch not searching 'Y'
  2010-04-29 13:13 Tsearch not searching 'Y' sandeep prakash dhumale <sandy9940@rediffmail.com>
  2010-04-29 14:01 ` Re: Tsearch not searching 'Y' Tom Lane <tgl@sss.pgh.pa.us>
@ 2010-04-29 17:48   ` John Gage <jsmgage@numericable.fr>
  0 siblings, 0 replies; 5+ messages in thread

From: John Gage @ 2010-04-29 17:48 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: sandeep prakash dhumale <sandy9940@rediffmail.com>; pgsql-sql; pgsql-general@postgresql.org

You can avoid stemming by using 'simple' instead of 'english' as the  
language of the words in to_tsvector (which is a little more awkward  
than the cast).

"There are no stop words for the simple dictionary. It will just  
convert to lower case, and index every unique word.
SELECT to_tsvector('simple', 'Andy andy The the in out');
  to_tsvector
  -------------------------------------
  'in':5 'out':6 'the':3,4 'andy':1,2
(1 row)

John


On Apr 29, 2010, at 4:01 PM, Tom Lane wrote:

> "sandeep prakash dhumale" <sandy9940@rediffmail.com> writes:
>> I am trying to get tsearch working for my application but I am  
>> facing a
>> problem when alphabet 'Y' is the in the tsquery.
>
>> # SELECT 'hollywood'::tsvector  @@ to_tsquery('holly:*');
>> ?column?
>> ----------
>> f
>> (1 row)
>
> You can't use to_tsquery for this sort of thing, because it tries to
> normalize the given words:
>
> regression=# select to_tsquery('holly:*');
> to_tsquery
> ------------
> 'holli':*
> (1 row)
>
> If you do this it works:
>
> regression=# SELECT 'hollywood'::tsvector  @@ 'holly:*'::tsquery;
> ?column?
> ----------
> t
> (1 row)
>
> So if you want to use prefix matching, don't normalize.
>
> 			regards, tom lane
>
> -- 
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql




^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2010-04-29 17:48 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-04-29 13:13 Tsearch not searching 'Y' sandeep prakash dhumale <sandy9940@rediffmail.com>
2010-04-29 13:56 ` Kenneth Marshall <ktm@rice.edu>
2010-04-29 14:14   ` sandeep prakash dhumale <sandy9940@rediffmail.com>
2010-04-29 14:01 ` Tom Lane <tgl@sss.pgh.pa.us>
2010-04-29 17:48   ` John Gage <jsmgage@numericable.fr>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox