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

I have a requirement to sort the 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); 

Additionally, SortField.SCORE is an integer constant, not SortField .

Lucene.net version 2.3.1.3.

Has anyone come across this?

+6
source share
1 answer

Found the answer to this question:

 SortField.FIELD_SCORE 

I don’t know how and why I missed this ...

+7
source

Source: https://habr.com/ru/post/888662/


All Articles