This project is read-only.

How do I sort result by using simplelucene

Jul 25, 2011 at 4:42 PM

Please send me a example about sorting result by using simplelucene... now I'm quite stuck, thx:)

Jul 27, 2011 at 4:41 PM

Assuming you are using a ResultDefinition to transform your results back into a strongly typed object, sorting can be achieved with Linq:


var indexSearcher = new DirectoryIndexSearcher(new DirectoryInfo(indexPath), true);
using (var searchService = new SearchService(indexSearcher)) {
	var query = new ProductQuery().WithPriceBetween(0, 100);
	var result = searchService.SearchIndex<Product>(query.Query, new ProductResultDefinition());
	foreach (var p in result.Results.OrderBy(p => p.Name))

Note the "OrderBy(p => p.Name)".

Taken from the example at