-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Reporting: Fix _index and _id columns in CSV export #96097
Reporting: Fix _index and _id columns in CSV export #96097
Conversation
ec4630e
to
51dd5da
Compare
51dd5da
to
7889a86
Compare
@elasticmachine merge upstream |
Pinging @elastic/kibana-app-services (Team:AppServices) |
x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts
Outdated
Show resolved
Hide resolved
src/plugins/discover/public/application/helpers/get_sharing_data.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great job! I left a few minor suggestions.
…generate_csv/generate_csv.ts Co-authored-by: Michael Dokolin <[email protected]>
@elasticmachine merge upstream |
import { getSortForSearchSource } from '../angular/doc_table'; | ||
|
||
export interface ISharingData { | ||
columns: string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets make this optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never mind i see its optional on the report type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code LGTM
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@@ -12,3 +12,5 @@ | |||
export async function loadSharingDataHelpers() { | |||
return await import('../application/helpers/get_sharing_data'); | |||
} | |||
|
|||
export { ISharingData } from '../application/helpers/get_sharing_data'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a quick look, it's late and my local Kibana refuses to bootstrap. could you check the build stats of this PR once it's finished, to be sure there is no significant change because of this? I can review it tomorrow for sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure -- nothing actually imports this interface, but Typescript complained without the export
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even better, this PR saves a few bytes now!
💚 Build Succeeded
Metrics [docs]Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, tested locally, CSV export with _index and _id works again 👍 , thx for taking care of the bundle size
* Reporting: Fix _index and _id columns in CSV export * optimize - cache _columns and run getColumns once per execution * Update x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts Co-authored-by: Michael Dokolin <[email protected]> * feedback * fix typescripts * fix plugin list test * fix plugin list * take away the export interface to test CI build stats Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Michael Dokolin <[email protected]>
* Reporting: Fix _index and _id columns in CSV export * optimize - cache _columns and run getColumns once per execution * Update x-pack/plugins/reporting/server/export_types/csv_searchsource/generate_csv/generate_csv.ts Co-authored-by: Michael Dokolin <[email protected]> * feedback * fix typescripts * fix plugin list test * fix plugin list * take away the export interface to test CI build stats Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Michael Dokolin <[email protected]> Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Michael Dokolin <[email protected]>
Summary
Closes: #96000
Elasticsearch has a bugfix change in 7.13 that invalidates certain metadata fields from being allowed in the fields API of a search request. Previously these fields would be ignored. See elastic/elasticsearch#70575
Kibana CSV Reporting populates the list of fields in the searchSource object with the columns selected in Discover. Since users can select metadata fields in Discover, it opened up the CSV export code to have metadata fields to exist in the list of fields in the searchSource. It did not matter that these fields were ignored by Elasticsearch. The set of fields were later used when generating the CSV to get the order of the columns.
This PR addresses the issue that Elasticsearch now throws an error when invalid metadata fields are passed in the fields API of a search. JobParamsCSV, which is the job payload for CSV report, previously only featured a
searchSource
object. A newcolumns
string array is added to the params in this PR, which provides CSV generation with the selection and ordering of the columns. Thecolumns
param can contain the ID any field that is selectable in Discover, including metadata fields.This screenshot of a select area of the code diff illustrates the change to the job params, in some mock code:
Checklist
For maintainers