After you get the query object, you can use IndexSearcher's function docFreq(), like this

final Set<Term> terms = new HashSet<Term>();
query = searcher.rewrite(query);
query.extractTerms(terms);
for(Term t : terms){
   int frequency = searcher.docFreq(t);
}

--
--
Chris Lu
-------------------------
Instant Scalable Full-Text Search On Any Database/Application
site: http://www.dbsight.net
demo: http://search.dbsight.com
Lucene Database Search in 3 minutes: 
http://wiki.dbsight.com/index.php?title=Create_Lucene_Database_Search_in_3_minutes

On 11/4/2010 12:53 AM, starz10de wrote:

I need to find the most frequent terms that are appeared with a query.

HighFreqTerms.java can be used only to obtain the high frequency terms in
the whole index.

I need just to find the high frequency terms to the submitted query.

What I do now is:

I search the index with the query and retrieve the relevant documents then
save those documents in a new folder then index them. At the end I use
HighFreqTerms.java in the new index so I can find the most frequent terms to
the query. However, this is very slow and need long time to run.

Any idea how I can do this task efficiently


Thanks in advance



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to