-
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
Improve SearchSource SearchRequest type #186862
Improve SearchSource SearchRequest type #186862
Conversation
/ci |
/ci |
/ci |
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
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.
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 |
@@ -37,12 +37,15 @@ export function getSearchParamsFromRequest( | |||
const searchParams = getSearchParams(getConfig); | |||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -1157,14 +1166,15 @@ export class SearchSource { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'll add this
@@ -72,7 +72,7 @@ export class SearchAPI { | |||
}); | |||
|
|||
return from( | |||
extendSearchParamsWithRuntimeFields(indexPatterns, requestParams, request.index) | |||
extendSearchParamsWithRuntimeFields(indexPatterns, requestParams, `${request.index}`) |
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.
Why the template literal?
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.
Same as above
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.
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 |
@@ -1190,7 +1204,7 @@ export class SearchSource { | |||
buildExpressionFunction<EsdslExpressionFunctionDefinition>('esdsl', { | |||
size: body?.size, | |||
dsl: JSON.stringify({}), | |||
index: index?.id, | |||
index: typeof index === 'string' ? index : `${dataView?.id}`, |
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 one question here: if dataView
is undefined the index
value would be set to "undefined"
. Is that ok?
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 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
SearchRequest
type 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