You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Konstantyn Smirnov <in...@yahoo.com> on 2008/06/02 17:44:11 UTC
HitCollector and sorting
Hi all
Currently I'm using the search method returning the Hits object. According
to http://wiki.apache.org/lucene-java/ImproveSearchingSpeed one should use a
HitCollector-oriented search method instead.
But I need another aspect of the "Hits search(...)" method: it's sorting
ability.
Now my code looks like :
def hits = multiSearcher.search( query, Methods.activeFilter, sort )
def iter = hits.iterator()
def results = []
int counter = 0
for( hit in iter ){
if( range.contains( counter ) && hit.document ){
results << Methods.bind( hit.document, lucenizedClasses )
}else if( counter >= upper ) break
counter++
}
So, how can I get the same results using the HitCollector? Also it would be
really nice, if you could point me to some examples of using it...
Thanx in advance,
Konstantyn
--
View this message in context: http://www.nabble.com/HitCollector-and-sorting-tp17604363p17604363.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: HitCollector and sorting
Posted by Konstantyn Smirnov <in...@yahoo.com>.
hossman wrote:
>
> Take a look at TopFieldDocCollector It's a HitCollector provided out of
> the box that does sorting.
>
will it work against a ParallelMultiSearcher?
--
View this message in context: http://www.nabble.com/HitCollector-and-sorting-tp17604363p17881706.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: HitCollector and sorting
Posted by Chris Hostetter <ho...@fucit.org>.
: So, how can I get the same results using the HitCollector? Also it would be
: really nice, if you could point me to some examples of using it...
Take a look at TopFieldDocCollector It's a HitCollector provided out of
the box that does sorting.
If you look at the trunk, the (recently updateed) "demo" file
SearchFiles.java shows how to use TopDocCollector ... TopFieldDocCollector
works exactly the same way, except that it knows about Sorting.
-Hoss
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org