diff --git a/plugin/storage/es/spanstore/reader.go b/plugin/storage/es/spanstore/reader.go index accd1932e53..dbf9d60276e 100644 --- a/plugin/storage/es/spanstore/reader.go +++ b/plugin/storage/es/spanstore/reader.go @@ -139,7 +139,7 @@ func NewSpanReader(p SpanReaderParams) *SpanReader { p.Logger, getTimeRangeIndexFn(p.Archive, p.UseReadWriteAliases, p.RemoteReadClusters), ), - sourceFn: getSourceFn(p.Archive, p.MaxDocCount), + sourceFn: getSourceFn(p.MaxDocCount), maxDocCount: p.MaxDocCount, useReadWriteAliases: p.UseReadWriteAliases, logger: p.Logger, @@ -202,16 +202,13 @@ func addRemoteReadClusters(fn timeRangeIndexFn, remoteReadClusters []string) tim } } -func getSourceFn(archive bool, maxDocCount int) sourceFn { +func getSourceFn(maxDocCount int) sourceFn { return func(query elastic.Query, nextTime uint64) *elastic.SearchSource { - s := elastic.NewSearchSource(). + return elastic.NewSearchSource(). Query(query). - Size(maxDocCount) - if !archive { - s.Sort("startTime", true). - SearchAfter(nextTime) - } - return s + Size(maxDocCount). + Sort("startTime", true). + SearchAfter(nextTime) } } diff --git a/plugin/storage/es/spanstore/reader_test.go b/plugin/storage/es/spanstore/reader_test.go index 3b292008dcd..82e3f8531bf 100644 --- a/plugin/storage/es/spanstore/reader_test.go +++ b/plugin/storage/es/spanstore/reader_test.go @@ -1339,7 +1339,7 @@ func TestBuildTraceByIDQuery(t *testing.T) { } func TestTerminateAfterNotSet(t *testing.T) { - srcFn := getSourceFn(false, 99) + srcFn := getSourceFn(99) searchSource := srcFn(elastic.NewMatchAllQuery(), 1) sp, err := searchSource.Source() require.NoError(t, err)