O'Reilly logo

Instant Lucene.NET by Michael Heydt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Ordering search results (Should know)

By default Lucene.NET orders search results in ascending order. But you may want to group or order the results by other criteria. Examples could be grouping by tags on the documents (such as categories), by date of submission, or by the documents, title.

This can easily be done with a LINQ query (or other techniques) on the resultant hits, but that's inefficient as Lucene.NET will return all results even if only subsets are required after the post query ordering. This recipe will show several techniques for having Lucene.NET sort a query's results while processing the query instead of having to perform this manually after a query has finished.

How to do it…

There are several overloads of the search method in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required