-
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
[data.search] Add request handler context and asScoped pattern #80775
Conversation
Pinging @elastic/kibana-app-arch (Team:AppArch) |
@@ -22,17 +22,6 @@ import { IKibanaSearchRequest, IKibanaSearchResponse } from '../types'; | |||
|
|||
export const ES_SEARCH_STRATEGY = 'es'; | |||
|
|||
export interface ISearchOptions { |
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.
Moved up to common/search/types
218d5be
to
36b8fcb
Compare
Skipping CI for now since we know it won't pass until #80116 is merged. |
const indexPatternsFetcher = new IndexPatternsFetcher( | ||
elasticsearch.legacy.client.callAsCurrentUser | ||
); | ||
const indexPatternsFetcher = new IndexPatternsFetcher(esClient.asCurrentUser); |
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 the portion that relies on #80116.
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.
Overall approach makes sense to me! In particular I like the addition of SearchStrategyDependencies
, this feels like a good way to limit the use of implicit dependencies in strategies to a known quantity.
Still need to do some testing, but in general this LGTM
return { | ||
aggs: this.aggsService.start({ fieldFormats, uiSettings }), | ||
getSearchStrategy: this.getSearchStrategy, | ||
search: this.search.bind(this), | ||
asScoped: getSearchClientAsScoped, |
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.
<tangent>
I was thinking about whether this should be async, but I guess it doesn't have to be.
Was trying to remember why I made SearchSource.asScoped
async -- turns out it is because index patterns contract is async, because field formats contract is async, because it calls await uiSettings.getAll()
</tangent>
const fakeRequestHandlerContext = { | ||
core: { | ||
elasticsearch: { | ||
client: esClient, | ||
}, | ||
uiSettings: { | ||
client: uiSettingsClient, | ||
}, | ||
}, | ||
} as RequestHandlerContext; |
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.
🙌
@elasticmachine merge master |
Yep, I've fixed this now. @XavierM we should sync up about how the |
pinging @elastic/endpoint-app-team and @elastic/kibana-app for codeowner review, please and thank 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.
LGTM
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
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.
KibanaApp changes LGTM
💚 Build SucceededMetrics [docs]page load bundle size
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.
Everything is working as expected on the security solutions! Thanks a lot
…ic#80775) * [Search] Add request context and asScoped pattern * Update docs * Unify interface for getting search client * Update examples/search_examples/server/my_strategy.ts Co-authored-by: Anton Dosov <dosantappdev@gmail.com> * Review feedback * Fix checks * Fix CI * Fix security search * Fix test * Fix test for reals * Fix types Co-authored-by: Anton Dosov <dosantappdev@gmail.com>
… (#82648) * [Search] Add request context and asScoped pattern * Update docs * Unify interface for getting search client * Update examples/search_examples/server/my_strategy.ts Co-authored-by: Anton Dosov <dosantappdev@gmail.com> * Review feedback * Fix checks * Fix CI * Fix security search * Fix test * Fix test for reals * Fix types Co-authored-by: Anton Dosov <dosantappdev@gmail.com> Co-authored-by: Anton Dosov <dosantappdev@gmail.com>
* master: (127 commits) [ILM] Fix breadcrumbs (elastic#82594) [UX]Swap env filter with percentile (elastic#82246) Add platform's missing READMEs (elastic#82268) [Discover] Adding uiMetric to track Visualize link click (elastic#82344) [Search] Add used index pattern name to the search agg error field (elastic#82604) improve client-side SO client get pooling (elastic#82603) [Security Solution] Unskips Overview tests (elastic#82459) Embeddables/migrations (elastic#82296) [Enterprise Search] Refactor product server route registrations to their own files/folders (elastic#82663) Moving reinstall function outside of promise.all (elastic#82672) Load choropleth layer correctly (elastic#82628) Master backport elastic#81233 (elastic#82642) [Fleet] Allow snake cased Kibana assets (elastic#77515) Reduce saved objects authorization checks (elastic#82204) [data.search] Add request handler context and asScoped pattern (elastic#80775) [ML] Fixes formatting of fields in index data visualizer (elastic#82593) Usage collector readme (elastic#82548) [Lens] Visualization validation and better error messages (elastic#81439) [ML] Add annotation markers to time series brush area to indicate annotations exist outside of selected range (elastic#81490) chore(NA): install microdnf in UBI docker build only (elastic#82611) ...
Summary
Depends on #80116.
Addresses #78461.
This PR changes the APIs we expose from our server-side
data
pluginsearch
service. Before this PR, we were exposing a singlesearch
function from thestart
contract:Passing
context
around was problematic because of two reasons:RequestContext
to implementers of search strategiesThis PR attempts to address these by providing two mechanisms of accessing the
search
method:asScoped
method in thedata
pluginstart
contract:It also updates the way we register custom search strategies. Instead of accepting a
context
inside of thesearch
/cancel
functions, you now receiveSearchStrategyDependencies
:In this way, we can control which dependencies are being passed/used in custom search strategies. If we need to add more along the way, we can, instead of relying implicitly on what's inside
context
.Checklist
Delete any items that are not applicable to this PR.
For maintainers