-
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
Phase 1 of search services #46742
Phase 1 of search services #46742
Conversation
💔 Build Failed |
1ab0729
to
098cd69
Compare
💔 Build Failed |
098cd69
to
ddfed3f
Compare
ddfed3f
to
e9d62d2
Compare
NP search cleanup
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
await esArchiver.loadIfNeeded('../functional/fixtures/es_archiver/dashboard/current/data'); | ||
await esArchiver.load('../functional/fixtures/es_archiver/dashboard/current/kibana'); | ||
await kibanaServer.uiSettings.replace({ | ||
'dateFormat:tz': 'Australia/North', | ||
defaultIndex: 'logstash-*', | ||
}); |
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.
Do we need to revert these in an after
?
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.
yuuupppp, added another commit (and fixed the ts error that was killing ci)
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.
actually I reverted the data that was loaded. I don't think we need to change anything with the uiSettings, haven't seen that being "undone" before. Most tests set it explicitly.
Adding unit tests
…te, at least not yet.
💚 Build Succeeded |
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
@lukasolson and I pair programmed a bit on this so giving my official LGTM, and I think we only need one more in additional to Lukas's.
💚 Build Succeeded |
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.
Jest config changes 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.
can we add some documentation either to the README or to the pr description devdocs section ?
i see we have a demo showing how to register search strategy, but i am wondering how can i use this service if i just want to perform search ?
@@ -20,16 +20,22 @@ | |||
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../../core/public'; | |||
import { AutocompleteProviderRegister } from './autocomplete_provider'; | |||
import { DataPublicPluginSetup, DataPublicPluginStart } from './types'; | |||
import { searchService } from './search'; | |||
import { SearchService } from './search/search_service'; |
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 import both, or why even have searchService function, all it does is new SearchService(params)
?
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.
Copied the plugin
way of doing things (this was its own separate plugin so this was the index.ts
file, at the plugin level, this is export plugin...
, here I renamed it export searchService ...
). Not necessary except for conformity. It is pretty silly when you take it outside of the plugin level. I can remove.
src/plugins/data/public/plugin.ts
Outdated
|
||
constructor(initializerContext: PluginInitializerContext) {} | ||
constructor(initializerContext: PluginInitializerContext) { | ||
this.searchService = searchService(initializerContext); |
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.
do we need to create this in the constructor or could it be postponed till setup()
?
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.
We could but then we'd need to store the initializerContext and make searchService possibly undefined. Is there any benefit to postponing? It was my impression that constructor and setup are all run before Kibana loads up so it doesn't make a difference which it's in. If I'm wrong I can move it.
return api; | ||
} | ||
|
||
public start(core: CoreStart) {} |
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.
hmm, how does this work ? setup() contract includes registerSearchStrategyContext and registerSearchStrategyProvider ... that makes sense
what about start method ? (i was expecting search
function here)
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.
search
functionality is passed down via AppMountContext, or RouteHandlerContext. In NP land, I can't think of a situation they will need to be access via the start
contract. We exposed it in Setup
just for legacy land. We think we could expose in start too (or instead of). I don't think it really matters at that point.
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.
exposing search
in setup method means that who ever uses it has no idea if searchStrategies have been registered yet.
not exposing search
in start: how can i pass search to any other plugin then ? my plugin would want to register esaggs function to expressions function registry, esaggs requires search
, so we kind of need it in the contracts.
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.
also ... it doesn't seem we expose it in setup currently (at least not on the client side)
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.
Yea, I honestly couldn't think of a reason to expose it, but you just gave one example. It will be interesting though because esaggs will need to use it bound to the current user.
Mind if we punt on that for this PR and then we can work on adding it in for real to replace esaggs and make the adjustments needed that way?
data: DataPublicPluginSetup; | ||
} | ||
|
||
declare module '../../../../../src/plugins/data/public' { |
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.
whats this for ?
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.
adding a comment to the file:
/**
* Add the typescript mappings for our search strategy to the request and
* response types. This allows typescript to require the right shapes if
* making the call:
* const response = context.search.search(request, {}, DEMO_SEARCH_STRATEGY);
*
* If the caller does not pass in the right `request` shape, typescript will
* complain. The caller will also get a typed response.
*/
💔 Build Failed |
I don't really want to call this service out yet in devdocs given that it will likely go through so much change. The demos do have code for searching both the ES_SEARCH_STRATEGY and the DEMO_SEARCH_STRATEGY (they do actually perform the searches). I called out the specific sections in this presentation: https://docs.google.com/presentation/d/1_nKsMnRYRTDDz6n_U7XRMfKrSEYXiNjYLMJD5ttR78o/edit#slide=id.g61fddd3178_0_3217 starting on slide 25, |
💚 Build Succeeded |
a demo of how can i use it in my plugin would be nice (so a plugin that does not register an application) |
Yea, this would be good, do you mind if I punt on this for this PR though? I think I'm going to hit the context issues described here: #46483. And probably require some syncing with platform team. I actually would hit it when migrating to https://github.com/elastic/kibana/pull/47337/files ... since then the search_explorer would be registering a section to the living documentation plugin, which would be similar to what you are asking. Also it'd be cool to add some documentation for the interpreter using this system, and we can use it that way too.
This one I'm not sure is worth pointing out in the demo plugin since we are moving away from legacy. I just pushed another commit that exposes via start contract and confirmed it worked by using it inside |
💔 Build Failed |
💚 Build Succeeded |
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
* Phase 1 of search services * First review feedback * Start on tests * Add functional tests for search explorer * Add unload and fix ts error * Add index.test.ts files for coverage completeness * Adding unit tests * use internal route terminology. No reason this should be a public route, at least not yet. * Move search service into data plugin * App mount search context needs to be optional * Add more unit tests for server stuff * wip types fix * fix types for new context container stuff * put back all jest test coverage paths * address review comments * delete the two test files that just tested the instantiation of the search service * expose search fn on StartContract... tested locally only * update mocks to account for new startcontract
* Phase 1 of search services * First review feedback * Start on tests * Add functional tests for search explorer * Add unload and fix ts error * Add index.test.ts files for coverage completeness * Adding unit tests * use internal route terminology. No reason this should be a public route, at least not yet. * Move search service into data plugin * App mount search context needs to be optional * Add more unit tests for server stuff * wip types fix * fix types for new context container stuff * put back all jest test coverage paths * address review comments * delete the two test files that just tested the instantiation of the search service * expose search fn on StartContract... tested locally only * update mocks to account for new startcontract
💚 Build Succeeded |
Summary
Introduction of the new pluggable search service. There are no actual users of this system yet except for the sample plugin which showcases the api's, and is functionally tested.
Fixes #43371
Jest test coverage
Further exploration
The full exploration PR can be seen at #45058. This is just the first phase - the new client and server
search
extension points, as well as the ability to search Elasticsearch in a synchronous manner.The async version has been tested in the fuller exploration PR.
Overview
Search
service provides:Client side interaction
Client side + server side
Client and server side api's differ slightly. On the client side, the search function returns an observable to support progress reporting. On the server side it is always a promise since we don't have a use case yet for a server side component wanting to handle progress, and client side progress strategy will require the server to always immediately return, to the client, all partial results as they come in.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.- [ ] This was checked for cross-browser compatibility, including a check against IE11- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n supportyarn start --plugin-path test/plugin_functional/plugins/demo_search/ --plugin-path test/plugin_functional/plugins/search_explorer/
and navigate to the search explorer app to view documentation, links and working demos using the search services.- [ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers