Even after passing a sortfield, score of the document is effecting the sort order of the search results. Is there a way to make lucene to ignore the document score when a specific sort field is passed?
For ex:
DocId Score SortFieldA SortFieldB
1 23.0041 200906030800 Test
2 32.2774 200906020800 Test
3 21.0632 200906030800 Apple
I want the results to be sorted by SortFieldA first and then by SortFieldB. So in the above case the results should be and returned as doc2, doc3 and doc1. But because of the Score, the sort order is getting disturbed.
I noticed that the results are getting sorted properly if the documents have same score.
Code that sets the sort fields:
public override Sort GetSort()
{
List<SortField> sortFields = new List<SortField>();
开发者_Python百科 sortFields.Add(new SortField(StartDateTime.ToString(), SortField.STRING, ReverseSort));
sortFields.Add(new SortField(TitleSort.ToString(), SortField.STRING, ReverseSort));
return new Sort(sortFields.ToArray());
}
Edit: as you do not care for the original score, I believe you need to use a ConstantScoreQuery to get the hits first, and then pass them to the sorter.
Try looking at this question.
精彩评论