From c341b98d8c056e710b47324250a11cd3534774ca Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Wed, 11 Dec 2019 17:25:40 -0700 Subject: [PATCH] fix query bug of empty array --- .../server/lib/generate_csv_search.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 9d6540d36fd8b..4c2e09cbf7db5 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 @@ -80,7 +80,7 @@ export async function generateCsvSearch( let payloadQuery: QueryFilter | undefined; let payloadSort: any[] = []; - let docValueFields: any[] = []; + let docValueFields: any[] | undefined; if (jobParams.post && jobParams.post.state) { ({ post: { @@ -118,7 +118,11 @@ export async function generateCsvSearch( }, {}); if (indexPatternTimeField) { - docValueFields = [indexPatternTimeField].concat(docValueFields); + if (docValueFields) { + docValueFields = [indexPatternTimeField].concat(docValueFields); + } else { + docValueFields = [indexPatternTimeField]; + } } const searchRequest: SearchRequest = {