Alex Rivera | Logout

How do I sort Lucene results by field value using a HitCollector?

Asked 2009-01-30T22:55:39.353
16

I'm using the following code to execute a query in Lucene.Net

var collector = new GroupingHitCollector(searcher.GetIndexReader());
searcher.Search(myQuery, collector);
resultsCount = collector.Hits.Count;

How do I sort these search results based on a field?


Update

Thanks for your answer. I had tried using TopFieldDocCollector but I got an error saying, "value is too small or too large" when i passed 5000 as numHits argument value. Please suggest a valid value to pass.

Edit
Report

1 Answer

0

What you're looking for is probably TopFieldDocCollector. Use it instead of the GroupingHitCollector (what is that?), or inside it.

Comment on this if you need more info. I'll be happy to help.

answered 2009-02-01T08:01:02.077

Your Answer