Hi, Oleg Bartunov:
First thanks for your quick replay. Could you explain it a little more on "it's general limitation/feature"? I just confuse that to_tsquery('item') function will return a tsquery type which is same as 'item'::tsquery, to my understanding.
Let me explain what I want: First Step: extract top K tokens I have a table with a column as tsvector type. Some records in this column are too big, which contain hundreds tokens. I just want the top K tokens based on the frequency, for example top 5. I am not sure there is a direct way to get such kind top K tokens. I just read them out in Java and count frequency for each token and sort them.
Second Step: generate query Now I will use these tokens to construct a query to search other vectors in the same table. I can not directly use to_tsquery() due to two reasons: 1) The default logic operator in to_tsquery() is "&" but what I need it "|". 2) Since the tokens are from tsvector, they are already normalized. If I use to_tsquery() again, they will be normalized again! For example, “course” -> “cours” -> “cour”. So I just concatenate the top K tokens with “|” and directly use "::tsquery ".
Unfortunately, as you say "it's general limitation/feature”, I can not do that. I checked your manual “Full-Text Search in PostgreSQL A Gentle Introduction”, but could not figure out how. So is it possible to implement what I want in FTS? If so, how?
Thank!
Xu --- On Sun, 1/24/10, Oleg Bartunov <oleg@sai.msu.su> wrote:
From: Oleg Bartunov <oleg@sai.msu.su> Subject: Re: [GENERAL] FTS uses "tsquery" directly in the query To: "xu fei" <autofei@yahoo..com> Cc: pgsql-general@postgresql.org Date: Sunday, January 24, 2010, 2:11 AM
Xu, FTS has nothing with your problem, it's general limitation/feature. Oleg On Sat, 23 Jan 2010, xu fei wrote: > Hi, everyone: > First I can successful run this query:select name, ts_rank_cd(vectors, query) as rank from element, to_tsquery('item') query where query @@ vectors order by rank desc;But actually I want to run this one:select name, ts_rank_cd(vectors, query) as rank from element, 'item'::tsquery query where query @@ vectors order by rank desc;Looks like that FTS does not support directly use "::tsquery " in such query. Do I misunderstand something? Thanks! > Xu > > > Regards, Oleg _____________________________________________________________ Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru), Sternberg Astronomical Institute, Moscow University, Russia Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/phone: +007(495)939-16-83, +007(495)939-23-83
|