-
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
Improve search typescript #69333
Improve search typescript #69333
Conversation
…-side-search-strategy
...evelopment/plugins/data/public/kibana-plugin-plugins-data-public.searchinterceptor.search.md
Outdated
Show resolved
Hide resolved
…-side-search-strategy
@elasticmachine merge upstream |
…-side-search-strategy
delete search explorer
…om/kibana into search/server-side-search-strategy
...request.params, | ||
}; | ||
|
||
params.trackTotalHits = true; // Get the exact count of hits | ||
|
||
// If we have an ID, then just poll for that ID, otherwise send the entire request body | ||
const { body = undefined, index = undefined, ...queryParams } = request.id ? {} : params; | ||
|
||
const method = request.id ? 'GET' : 'POST'; | ||
const path = encodeURI(request.id ? `/_async_search/${request.id}` : `/${index}/_async_search`); | ||
|
||
// Wait up to 1s for the response to return |
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.
delete comment
export function toPromise(signal: AbortSignal): Promise<never> { | ||
return new Promise((resolve, reject) => { | ||
if (signal.aborted) reject(new AbortError()); | ||
signal.addEventListener('abort', () => reject(new AbortError())); |
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 think every time we addEventListener
we also have to have removeEventListener
somewhere.
Otherwise we are spamming memory leaks.
Just double checked this is required, for example, fetch polyfill does this: https://github.com/github/fetch/blob/master/fetch.js#L534
I guess should be fixed in separate pr, since it isn't something new introduced with the refactor.
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.
Ahh, turns out I mentioned it here: #65051.
Added fetch example there in description
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.
Added a removeEventListener
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 won't always work. We also need to remove listener after corresponding request is successfully finished.
That is why they do it in finalise
callback. https://github.com/github/fetch/blob/master/fetch.js#L534
Should be tacked properly in scope of #65051
@elasticmachine merge upstream |
Could you explain how this changes the scope of the functionality that the data plugin offers? Does this remove the ability for plugins to register and use their own search strategies? Seeing how the examples were removed, will there be new documentation in their place to explain the usage? |
@elasticmachine merge upstream |
return new Promise((resolve, reject) => { | ||
esSearcher | ||
dataPlugin.search |
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.
Is there some documentation for how to interact with this API? How can I confirm that dataPlugin.search.search
is the correct API function etc?
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 docs are in the making.
Synced with @weltenwort to confirm the changes suit your needs.
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.
OK, in the meantime without docs, can you confirm that the API is definitely dataPlugin.search.search
vs dataPlugin.search
? And what are the list of available keys and methods on dataPlugin
?
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.
Data plugin contains several services
- query (everything that has to do with the search bar - time range, query string, filters)
- search (which contains the
search
function and theaggs
helpers - index patterns
- field formatting
- autocompletion
The method relevant to you is indeed dataStart.search.search()
@elasticmachine merge upstream |
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 thanks for the explanations
…-side-search-strategy
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 partially tested using flights dashboard (with x-pack)
Focused on 2 things:
- Cancelations are working as expected when clicking refresh fast. (this was flaky in that past)
- I set latency to 15s, and made sure I can cancel or run beyond timeout
With that didn't find any issues.
But this is just artificial client side tests and I didn't test with data to trigger proper async search flow.
…om/kibana into search/server-side-search-strategy
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
Saved Objects .kibana field count
History
To update your PR or re-run it, just comment with: |
* [search] Refactor the way search strategies are registered/retrieved on the server * Fix types and tests and update docs * Fix failing test * Fix build of example plugin * Fix functional test * Make server strategies sync * Move strategy name into options * docs * Remove FE strategies * TypeScript of hell delete search explorer * Fix search interceptor OSS tests * typos * test cleanup * Delete search example fix interceptor async tests to use fake timers * docs * fix * return search wrapper * Update search interceptor tests and abort utils * ts * jest test fix * code review * change how logs consume search API Co-authored-by: Lukas Olson <olson.lukas@gmail.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> # Conflicts: # src/plugins/data/public/public.api.md
* master: (36 commits) fixed api url in example plugin (elastic#70934) [data.search.aggs]: Remove remaining client dependencies (elastic#70251) [Security Solution][Endpoint] Fix base64 download bug and adopt new user artifact/manifest format (elastic#70998) [Security Solution][Exceptions] - Exception Modal Part I (elastic#70639) [SIEM][Detection Engine][Lists] Adds additional data types to value based lists [SIEM][Detection Engine][Lists] Removes feature flag for lists [APM] Show license callout in ML settings (elastic#70959) Migrate service settings test to jest (elastic#70992) [APM] Add cloud attributes to data telemetry (elastic#71008) Fix breadcrumb on panels for visibility / round corners (elastic#71010) Improve search typescript (elastic#69333) [savedObjects field count] run in baseline job (elastic#70999) [Security Solution] [Timeline] Timeline manager tweaks (elastic#69988) [Endpoint] Support redirect from Policy Details to Ingest when user initiates Edit Policy from Datasource Edit page (elastic#70874) [APM] Add API tests (elastic#70740) [Security Solution][Exceptions] - Tie server and client code together (elastic#70918) [Audit Logging] Add AuditTrail service (elastic#69278) [Usage Collection] Ensure no type duplicates (elastic#70946) [Security Solution] [Timeline] Bugfix for timeline row actions disappear sometimes (elastic#70958) [CI] Add pipeline task queue framework and merge workers into one (elastic#64011) ...
* Improve search typescript (#69333) * [search] Refactor the way search strategies are registered/retrieved on the server * Fix types and tests and update docs * Fix failing test * Fix build of example plugin * Fix functional test * Make server strategies sync * Move strategy name into options * docs * Remove FE strategies * TypeScript of hell delete search explorer * Fix search interceptor OSS tests * typos * test cleanup * Delete search example fix interceptor async tests to use fake timers * docs * fix * return search wrapper * Update search interceptor tests and abort utils * ts * jest test fix * code review * change how logs consume search API Co-authored-by: Lukas Olson <olson.lukas@gmail.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> # Conflicts: # src/plugins/data/public/public.api.md * docs * Fix merge Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Summary
This PR removes the concept of "Search Strategies" from the front end of Kibana.
Instead, it incorporates the search logic within the
search_interceptor
s.The OSS interceptor is responsible for synchronous querying, while the x-pack interceptor adds capabilities such as async queries, cancellation, running beyond timeout etc.
This PR also reduces the
waitForCompletion
timeout to100ms
(instead of 1s). This is especially important moving forward to async search, as this determins the earliest time we get theasyncID
from ES.Dev Docs
This PR deprecates the front end search strategy concept removes the following API methods from the
data.search
plugin:registerSearchStrategy
getSearchStrategy
Checklist
Delete any items that are not applicable to this PR.
For maintainers