Arnold Zokas
Arnold Zokas

Reputation: 8580

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?

Upvotes: 8

Views: 2262

Answers (1)

Arnold Zokas
Arnold Zokas

Reputation: 8580

Found an answer to this:

SortField.FIELD_SCORE

Not sure how or why I missed this...

Upvotes: 9

Related Questions