Skip to content

Commit 13092da

Browse files
committed
fix the bug and add a test
1 parent 7a1db7f commit 13092da

File tree

8 files changed

+2774
-3
lines changed

8 files changed

+2774
-3
lines changed

x-pack/legacy/plugins/reporting/export_types/csv/types.d.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,21 @@
66

77
import { JobDocPayload, JobParamPostPayload, ConditionalHeaders, RequestFacade } from '../../types';
88

9+
interface DocValueField {
10+
field: string;
11+
format: string;
12+
}
13+
14+
interface SortOptions {
15+
order: string;
16+
unmapped_type: string;
17+
}
18+
919
export interface JobParamPostPayloadDiscoverCsv extends JobParamPostPayload {
1020
state?: {
1121
query: any;
12-
sort: any[];
22+
sort: Array<Record<string, SortOptions>>;
23+
docvalue_fields: DocValueField[];
1324
};
1425
}
1526

x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ export async function generateCsvSearch(
8080

8181
let payloadQuery: QueryFilter | undefined;
8282
let payloadSort: any[] = [];
83+
let docValueFields: any[] = [];
8384
if (jobParams.post && jobParams.post.state) {
8485
({
8586
post: {
86-
state: { query: payloadQuery, sort: payloadSort = [] },
87+
state: { query: payloadQuery, sort: payloadSort = [], docvalue_fields: docValueFields },
8788
},
8889
} = jobParams);
8990
}
@@ -115,7 +116,11 @@ export async function generateCsvSearch(
115116
},
116117
};
117118
}, {});
118-
const docValueFields = indexPatternTimeField ? [indexPatternTimeField] : undefined;
119+
120+
if (indexPatternTimeField) {
121+
docValueFields = [indexPatternTimeField].concat(docValueFields);
122+
}
123+
119124
const searchRequest: SearchRequest = {
120125
index: esIndex,
121126
body: {
Binary file not shown.

0 commit comments

Comments
 (0)