Skip to content

Commit

Permalink
fix the bug and add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Dec 11, 2019
1 parent 7a1db7f commit 13092da
Show file tree
Hide file tree
Showing 8 changed files with 2,774 additions and 3 deletions.
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 @@ -80,10 +80,11 @@ export async function generateCsvSearch(

let payloadQuery: QueryFilter | undefined;
let payloadSort: any[] = [];
let docValueFields: any[] = [];
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 @@ -115,7 +116,11 @@ export async function generateCsvSearch(
},
};
}, {});
const docValueFields = indexPatternTimeField ? [indexPatternTimeField] : undefined;

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

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

0 comments on commit 13092da

Please sign in to comment.