fix(pipeline): deterministic merge output ordering
Sort mergedChunks after groupAndMergeOverlapping concatenates results from different merge units. The unit order depends on Go map iteration in the grouping phase, which is non-deterministic. Uses the same tie-breakers as filter_top_k.go to restore consistent ordering at the merge source.main
parent
dfb371154c
commit
3b476c07df
|
|
@ -201,6 +201,10 @@ func (p *PluginMerge) groupAndMergeOverlapping(ctx context.Context, results []*t
|
|||
mergedChunks = append(mergedChunks, g...)
|
||||
}
|
||||
|
||||
// Global sort restores relevance order after map-based grouping.
|
||||
// n is typically < 100, O(n log n) is negligible here.
|
||||
sortSearchResultsDeterministically(mergedChunks)
|
||||
|
||||
pipelineInfo(ctx, "Merge", "output", map[string]interface{}{
|
||||
"merged_total": len(mergedChunks),
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue