Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion x-pack/legacy/plugins/reporting/export_types/csv/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@

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

interface DocValueField {
field: string;
format: string;
}

interface SortOptions {
order: string;
unmapped_type: string;
}

export interface JobParamPostPayloadDiscoverCsv extends JobParamPostPayload {
state?: {
query: any;
sort: any[];
sort: Array<Record<string, SortOptions>>;
docvalue_fields: DocValueField[];
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ export async function generateCsvSearch(

let payloadQuery: QueryFilter | undefined;
let payloadSort: any[] = [];
let docValueFields: any[] | undefined;
if (jobParams.post && jobParams.post.state) {
({
post: {
state: { query: payloadQuery, sort: payloadSort = [] },
state: { query: payloadQuery, sort: payloadSort = [], docvalue_fields: docValueFields },
},
} = jobParams);
}
Expand Down Expand Up @@ -119,7 +120,15 @@ export async function generateCsvSearch(
},
};
}, {});
const docValueFields = indexPatternTimeField ? [indexPatternTimeField] : undefined;

if (indexPatternTimeField) {
if (docValueFields) {
docValueFields = [indexPatternTimeField].concat(docValueFields);
} else {
docValueFields = [indexPatternTimeField];
}
}

const searchRequest: SearchRequest = {
index: esIndex,
body: {
Expand Down
Binary file not shown.
Loading