diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts b/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts index 43eedd92f144c..c9ef5e063718b 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts +++ b/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts @@ -101,9 +101,11 @@ export async function generateCsvSearch( payloadQuery ); - const [savedSortField, savedSortOrder] = savedSearchObjectAttr.sort; - const sortConfig = [...payloadSort, { [savedSortField]: { order: savedSortOrder } }]; - + const savedSortConfigs = savedSearchObjectAttr.sort; + const sortConfig = [...payloadSort]; + savedSortConfigs.forEach(([savedSortField, savedSortOrder]) => { + sortConfig.push({ [savedSortField]: { order: savedSortOrder } }); + }); const scriptFieldsConfig = indexPatternFields .filter((f: IndexPatternField) => f.scripted) .reduce((accum: any, curr: IndexPatternField) => { @@ -137,7 +139,6 @@ export async function generateCsvSearch( sort: sortConfig, }, }; - const { callWithRequest } = server.plugins.elasticsearch.getCluster('data'); const callCluster = (...params: any[]) => callWithRequest(req, ...params); const config = server.config(); diff --git a/x-pack/test/functional/es_archives/reporting/hugedata/data.json.gz b/x-pack/test/functional/es_archives/reporting/hugedata/data.json.gz index 093a6461c6e8f..c524379640df7 100644 Binary files a/x-pack/test/functional/es_archives/reporting/hugedata/data.json.gz and b/x-pack/test/functional/es_archives/reporting/hugedata/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/reporting/logs/data.json.gz b/x-pack/test/functional/es_archives/reporting/logs/data.json.gz index ff16bc0c594bd..dbd8f6f8e2e76 100644 Binary files a/x-pack/test/functional/es_archives/reporting/logs/data.json.gz and b/x-pack/test/functional/es_archives/reporting/logs/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/reporting/nanos/data.json.gz b/x-pack/test/functional/es_archives/reporting/nanos/data.json.gz index 9fdf72d4ccaa7..d0531c7607736 100644 Binary files a/x-pack/test/functional/es_archives/reporting/nanos/data.json.gz and b/x-pack/test/functional/es_archives/reporting/nanos/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/reporting/sales/data.json.gz b/x-pack/test/functional/es_archives/reporting/sales/data.json.gz index 3552044c378d0..9478d482abe16 100644 Binary files a/x-pack/test/functional/es_archives/reporting/sales/data.json.gz and b/x-pack/test/functional/es_archives/reporting/sales/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/reporting/scripted_small/data.json.gz b/x-pack/test/functional/es_archives/reporting/scripted_small/data.json.gz index 581271426bdd4..2d6bbce42cc15 100644 Binary files a/x-pack/test/functional/es_archives/reporting/scripted_small/data.json.gz and b/x-pack/test/functional/es_archives/reporting/scripted_small/data.json.gz differ