Обсуждение: Tsearch not searching 'Y'
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 <> in y as below but i don't want to do it that way.
SELECT 'hollywood'::tsvector @@ to_tsquery('holl<y>:*');
?column?
----------
t
Thanks in advance
"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
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 <> in y as below but i don't want to do it that way. > > SELECT 'hollywood'::tsvector @@ to_tsquery('holl<y>:*'); > ?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
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