-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Reporting/CSV/7.17] allow query from state in parameters (#149297)
## Summary In 7.17.9, we're restoring a report generation API endpoint to create CSV reports based on saved searches. There has been one PR that serves as the first iteration: #148030 This resolves a missing capability from the first iteration. In the first iteration, POST bodies could allow an additional time range filter, which is merged with any saved filters or queries stored in the saved search object: ``` POST /api/reporting/v1/generate/csv/saved-object/search:${savedSearchId} { timerange: { min: '2015-09-20 10:23:36.052', max: '2015-09-20 10:25:55.744' } } ``` This PR is a second iteration. It allows additional "unsaved state" to be merged with the saved object at the time of report generation. ``` POST /api/reporting/v1/generate/csv/saved-object/search:${savedSearchId} state": { "query": { "multi_match": { "type": "best_fields", "query": "cognac", "lenient": true } }, "timerange": <same as before> ``` ``` POST /api/reporting/v1/generate/csv/saved-object/search:${savedSearchId} "state": { "query": [ { "multi_match": { "type": "best_fields", "query": "cognac", "lenient": true } }, { "bool": { "must_not": { "multi_match": { "type": "best_fields", "query": "Pyramidustries", "lenient": true } } } } ], timerange": <same as before> ``` ### Details In the details of #148030, it was stated: > Does not allow "raw state" to be merged with the Search object, as in the previous code (from 7.3-7.8). Otherwise, the API is compatible with the previous code. This PR pushes a bit back against that limitation. Now, requests to generate a report can accept a `state` field in the POST body. This field contains additional "unsaved state" that gets merged with the contents of the stored saved search object. However, the entire functionality of allowing `sort` and `docvalue_fields` keys in the request, is still not restored from the functionality that was implemented in 7.3-7.8. This limitation exists to minimize the complexity of the restored endpoint. Both of the non-restored keys are related to the sorting of documents. The sorting of documents is controlled by the saved search object only. The user can change the sort of the CSV after downloading the report, in a spreadsheet application or by programmatically working on the file. ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
- Loading branch information
Showing
7 changed files
with
237 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...test/reporting_api_integration/reporting_and_security/__snapshots__/csv_saved_search.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters