-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Logs UI] [skip-ci] Demonstrate blockers for writing custom search strategies effectively #67533
[Logs UI] [skip-ci] Demonstrate blockers for writing custom search strategies effectively #67533
Conversation
// Custom search strategies | ||
plugins.data.search.registerSearchStrategyContext( | ||
this.initializerContext.opaqueId, | ||
'logSources', |
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.
The compiler rejects this unless the ISearchContext
has been extended using declaration merging. But then it incorrectly leaks this key to other callers.
// something using data.search.search and payload | ||
const { firstTotal, firstLoaded, firstResults } = await somethingThatCallsAnotherSearchStrategy( | ||
payload | ||
); | ||
|
||
// something using data.search.search and the first results | ||
const { | ||
secondTotal, | ||
secondLoaded, | ||
secondResults, | ||
} = await somethingThatCallsAnotherSearchStrategy(firstResults); | ||
|
||
const total = mergeTotalsSomehow(firstTotal, secondTotal); | ||
const loaded = mergeLoadedSomehow(firstLoaded, secondLoaded); |
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 is meant to symbolize a sequential composition of two calls to other search strategies. Ideally parallel composition would also be possible.
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.
Supporting streaming results in the general case will also be tricky.
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.
After some more thought providing combinators for the general case is probably not feasible. Maybe thoroughly documenting the runtime semantics and response shape would be sufficient to enable devs to create specific composed strategies.
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.
💔 Build Failed
Failed CI StepsTo update your PR or re-run it, just comment with: |
Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui) |
The |
Summary
This tries to demonstrate some aspects of the data plugin's search strategy API that keep me from writing solution-specific search strategies:
data
plugin is not available inside of a search strategy handler.These points are further illustrated by inline comments below.