Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to order search results by relevance and another field in Lucene.net

I have a requirement to sort search results by relevance and another field.

I need to do something similar to this:

using Lucene.Net.Search;

SortField[] fields = new[] { SortField.SCORE, new SortField("customField") };
Sort sort = new Sort(fields);

IndexSearcher searcher = GetSearcher();
Hits = searcher.Search(query, sort);

Except, SortField.SCORE is an integer constant, not a SortField.

Lucene.net version 2.3.1.3.

Has anyone come across this?

like image 455
Arnold Zokas Avatar asked May 20 '11 16:05

Arnold Zokas


1 Answers

Found an answer to this:

SortField.FIELD_SCORE

Not sure how or why I missed this...

like image 52
Arnold Zokas Avatar answered Nov 04 '22 17:11

Arnold Zokas