0
0
Fork 0

slight fixup to last change to set the sort value

i'd like the sort value to be correct even with the optimizations
not using it
This commit is contained in:
Marty Schoch 2016-08-25 23:13:22 -04:00
parent 931ec677c4
commit 3f8757c05b
1 changed files with 5 additions and 1 deletions

View File

@ -110,6 +110,8 @@ func (hc *HeapCollector) Collect(ctx context.Context, searcher search.Searcher,
return nil
}
var sortByScoreOpt = []string{"_score"}
func (hc *HeapCollector) collectSingle(ctx *search.SearchContext, reader index.IndexReader, d *search.DocumentMatch) error {
// increment total hits
hc.total++
@ -146,7 +148,9 @@ func (hc *HeapCollector) collectSingle(ctx *search.SearchContext, reader index.I
}
// compute this hits sort value
if len(hc.sort) > 1 || len(hc.sort) == 1 && !hc.cachedScoring[0] {
if len(hc.sort) == 1 && hc.cachedScoring[0] {
d.Sort = sortByScoreOpt
} else {
hc.sort.Value(d)
}