Improve SearchSource SearchRequest type#186862
Conversation
|
/ci |
|
/ci |
|
/ci |
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
paul-tavares
left a comment
There was a problem hiding this comment.
Changes to files owned by elastic/security-defend-workflows look good 👍
…kibana into search_source_search_request
|
@mattkime Requesting a review from you on this one since you've been working in |
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| const { track_total_hits, ...body } = searchRequest.body; | ||
| const dataView = typeof searchRequest.index !== 'string' ? searchRequest.index : undefined; | ||
| const index = dataView?.title ?? `${searchRequest.index}`; |
There was a problem hiding this comment.
It appears as though the template literal isn't needed. might leave a note in the code if it is doing something useful
There was a problem hiding this comment.
searchRequest.index is optional and I was trying to get around the type checks while preserving the existing behavior here - that it will be treated as "undefined".
It might be more useful here to actually throw some sort of error instead - I think it is a required parameter here. I'll dig into it a little more.
| toExpressionAst({ asDatatable = true }: ExpressionAstOptions = {}): ExpressionAstExpression { | ||
| const searchRequest = this.mergeProps(); | ||
| const { body, index, query } = searchRequest; | ||
| const dataView = typeof index !== 'string' ? index : undefined; |
There was a problem hiding this comment.
This check on index as to whether its a string or a data view happens enough that it might be abstracted into a function. I'll leave it up to you
There was a problem hiding this comment.
Good point, I'll add this
|
|
||
| return from( | ||
| extendSearchParamsWithRuntimeFields(indexPatterns, requestParams, request.index) | ||
| extendSearchParamsWithRuntimeFields(indexPatterns, requestParams, `${request.index}`) |
There was a problem hiding this comment.
Why the template literal?
mattkime
left a comment
There was a problem hiding this comment.
I made some minor observations, I'll let you decide if you care to act upon them. Otherwise nice improvements that work well!
…kibana into search_source_search_request
…kibana into search_source_search_request
|
/ci |
💚 Build Succeeded
Metrics [docs]Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @lukasolson |
| size: body?.size, | ||
| dsl: JSON.stringify({}), | ||
| index: index?.id, | ||
| index: typeof index === 'string' ? index : `${dataView?.id}`, |
There was a problem hiding this comment.
Just one question here: if dataView is undefined the index value would be set to "undefined". Is that ok?
dej611
left a comment
There was a problem hiding this comment.
Code review only.
Left a single code question.
Approve to unblock it.
* master: (3487 commits) `BedrockChat` & `GeminiChat` (elastic#186809) [ResponseOps] log error when ES Query rules find docs out of time range (elastic#186332) skip flaky suite (elastic#188997) [Security solution][Alert Details] Enable preview feature flag and cypress tests (elastic#188580) [EuiProviders] Warn Developer if EuiProvider is missing (elastic#184608) [Security Solution ] Fixes Timeline infinite loading bug (elastic#188943) Improve SearchSource SearchRequest type (elastic#186862) Deprecate Search Sessions config (elastic#188037) [Synthetics] Add missing monitorType and tag info in cards !! (elastic#188824) [Console Monaco] Resolve uncaught error from tokenizer (elastic#188746) [Data Forge] Add `service.logs` dataset as a data stream (elastic#188786) [Console] Fix failing bulk requests (elastic#188552) Update dependency terser to ^5.31.2 (main) (elastic#188528) [APM][ECO] Telemetry (elastic#188627) [Fleet] Fix uninstall package validation accross space (elastic#188749) Update warning on `xpack.fleet.enableExperimental` (elastic#188917) [DOCS][Cases] Automate more screenshots for cases (elastic#188697) [Fleet] Fix get one agent when feature flag disabled (elastic#188953) chore(investigate): Add investigate-app plugin from poc (elastic#188122) [Monaco Editor] Add Search functionality (elastic#188337) ...
* master: (2400 commits) `BedrockChat` & `GeminiChat` (elastic#186809) [ResponseOps] log error when ES Query rules find docs out of time range (elastic#186332) skip flaky suite (elastic#188997) [Security solution][Alert Details] Enable preview feature flag and cypress tests (elastic#188580) [EuiProviders] Warn Developer if EuiProvider is missing (elastic#184608) [Security Solution ] Fixes Timeline infinite loading bug (elastic#188943) Improve SearchSource SearchRequest type (elastic#186862) Deprecate Search Sessions config (elastic#188037) [Synthetics] Add missing monitorType and tag info in cards !! (elastic#188824) [Console Monaco] Resolve uncaught error from tokenizer (elastic#188746) [Data Forge] Add `service.logs` dataset as a data stream (elastic#188786) [Console] Fix failing bulk requests (elastic#188552) Update dependency terser to ^5.31.2 (main) (elastic#188528) [APM][ECO] Telemetry (elastic#188627) [Fleet] Fix uninstall package validation accross space (elastic#188749) Update warning on `xpack.fleet.enableExperimental` (elastic#188917) [DOCS][Cases] Automate more screenshots for cases (elastic#188697) [Fleet] Fix get one agent when feature flag disabled (elastic#188953) chore(investigate): Add investigate-app plugin from poc (elastic#188122) [Monaco Editor] Add Search functionality (elastic#188337) ...
Summary
Improves the
SearchRequesttype exported from the data plugin. Prior to this PR, it was just aRecord<string, any>. This is just one step in moving toward the correct type.Checklist
Delete any items that are not applicable to this PR.
Risk Matrix
Delete this section if it is not applicable to this PR.
Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.
When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:
For maintainers