Set the sortValues on SearchHit post aggregation instead of during the reduce.
This commit is contained in:
parent
0e920c17dd
commit
3f2f1f088d
|
@ -109,10 +109,6 @@ public class InternalTopHits extends InternalAggregation implements TopHits, ToX
|
|||
for (int i = 0; i < reducedTopDocs.scoreDocs.length; i++) {
|
||||
ScoreDoc scoreDoc = reducedTopDocs.scoreDocs[i];
|
||||
hits[i] = (InternalSearchHit) shardHits[scoreDoc.shardIndex].getAt(tracker[scoreDoc.shardIndex]++);
|
||||
if (scoreDoc instanceof FieldDoc) {
|
||||
FieldDoc fieldDoc = (FieldDoc) scoreDoc;
|
||||
hits[i].sortValues(fieldDoc.fields);
|
||||
}
|
||||
}
|
||||
return new InternalTopHits(name, new InternalSearchHits(hits, reducedTopDocs.totalHits, reducedTopDocs.getMaxScore()));
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -79,9 +79,14 @@ public class TopHitsAggregator extends BucketsAggregator implements ScorerAware
|
|||
FetchSearchResult fetchResult = topHitsContext.fetchResult();
|
||||
InternalSearchHit[] internalHits = fetchResult.fetchResult().hits().internalHits();
|
||||
for (int i = 0; i < internalHits.length; i++) {
|
||||
ScoreDoc scoreDoc = topDocs.scoreDocs[i];
|
||||
InternalSearchHit searchHitFields = internalHits[i];
|
||||
searchHitFields.shard(topHitsContext.shardTarget());
|
||||
searchHitFields.score(topDocs.scoreDocs[i].score);
|
||||
searchHitFields.score(scoreDoc.score);
|
||||
if (scoreDoc instanceof FieldDoc) {
|
||||
FieldDoc fieldDoc = (FieldDoc) scoreDoc;
|
||||
searchHitFields.sortValues(fieldDoc.fields);
|
||||
}
|
||||
}
|
||||
return new InternalTopHits(name, topHitsContext.size(), topHitsContext.sort(), topDocs, fetchResult.hits());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue