Java Mailing List Archive

http://www.java2.5341.com/

Home » java-user.lucene »

Re: How to use Sort cass in Lucene 2.4.0?

Todd Benge

2008-11-05

Replies: Find Java Web Hosting

Author LoginPost Reply
I think it's like this:

Sort sort = new Sort("FIELDNAME", true);
TopFieldDocs docs = searcher.searcher(query, null, n, sort); // n is
the number of documents you want to retrieve

ScoreDoc[] hits = docs.scoreDocs;
for (int i = 0; i<docs.totalHits; i++ ) {
  Document doc = searcher.doc(hits[i].doc);
}

Hope this helps.

Todd


2008/11/5 장용석 <need4spd@(protected)>:
> hi.
> I have a question :)
>
> In lucene 2.3.X I did use Sort class like this..
>
> Sort sort = new Sort("FIELDNAME", true);
> Hits hits = searcher.search(query, sort);
>
> but, in lucene 2.4.0 search(Query, Sort) method is deprecated. I was
> searched API, so I found this method
> search(query, filter, n, sort)
>
> Could one of you point me to an example of code for querying without using
> the deprecated method search(query, sort)?
>
> and an example of code for method search(query, filter, n, sort). :)
>
> Thanks. :)
>
>
> --
> DEV용식
> http://devyongsik.tistory.com
>
©2008 java2.5341.com - Jax Systems, LLC, U.S.A.