Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [Reporting] Correct the docvalue_fields params in the search query Download CSV from Dashboard Panel (#52833) #53918

Merged
merged 1 commit into from
Jan 3, 2020
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