kibana/x-pack/plugins/global_search
Mikhail Shustov 99cd66f72d
[Core] Explicit typings for request handler context (#88718) (#88975)
* move context to server part. couple with RequestHandlerContext

Context implementation will be simplified in follow-up.

* adopt core code

* adopt bfetch code

* adopt data code

* adopt search examples

* adopt vis_type_timelion

* adopt vis_type_timeseries

* adopt plugin functional tests

* adopt actions

* adopt alerting plugin

* adopt APM plugin

* adopt beats_management

* adopt case plugin

* adopt cross_cluster_replication

* adopt data_enhanced

* adopt event_log

* adopt global_search

* adopt index_management

* adopt infra

* adopt licensing

* adopt lists

* adopt logstash

* adopt reporting

* adopt observability

* adopt monitoring

* adopt rollup

* adopt so tagging

* adopt security

* adopt security_solutions

* adopt watcher

* adopt uptime

* adopt spaces

* adopt snapshot_restore

* adopt features changes

* mute error when null used to extend context

* update docs

* small cleanup

* add type safety for return type

* refactor registerRouteHandlerContext type

* update docs

* update license header

* update docs

* fix type error. fetch body does not accept array of strings

* fix telemetry test

* remove unnecessary ts-ignore

* address comments

* update docs
# Conflicts:
#	docs/development/plugins/data/server/kibana-plugin-plugins-data-server.plugin.start.md
#	src/plugins/data/server/server.api.md
#	x-pack/plugins/monitoring/server/plugin.ts
2021-01-21 18:13:51 +01:00
..
common [7.x] [GS] add search syntax support (#83422) (#84186) 2020-11-24 16:18:12 +01:00
public [GS] add tag and dashboard suggestion results (#85144) (#85382) 2020-12-09 13:07:07 +01:00
server [Core] Explicit typings for request handler context (#88718) (#88975) 2021-01-21 18:13:51 +01:00
jest.config.js Jest multi-project configuration (#77894) (#84826) 2020-12-02 14:02:21 -08:00
kibana.json
README.md Fix link to RFC in GlobalSearch plugin README (#79407) (#79549) 2020-10-05 16:36:52 -05:00
tsconfig.json global search to ts refs (#79446) (#79462) 2020-10-05 17:32:36 +02:00

Kibana GlobalSearch plugin

The GlobalSearch plugin provides an easy way to search for various objects, such as applications or dashboards from the Kibana instance, from both server and client-side plugins

Consuming the globalSearch API

startDeps.globalSearch.find('some term').subscribe({
  next: ({ results }) => {
    addNewResultsToList(results);
  },
  error: () => {},
  complete: () => {
    showAsyncSearchIndicator(false);
  }
});

Registering custom result providers

The GlobalSearch API allows to extend provided results by registering your own provider.

setupDeps.globalSearch.registerResultProvider({
  id: 'my_provider',
  find: (term, options, context) => {
    const resultPromise = myService.search(term, context.core.savedObjects.client);
    return from(resultPromise).pipe(takeUntil(options.aborted$);
  },
});

Known limitations

Client-side registered providers

Results from providers registered from the client-side registerResultProvider API will not be available when performing a search from the server-side. For this reason, prefer registering providers using the server-side API when possible.

Refer to the RFC for more details

Search completion cause

There is currently no way to identify globalSearch.find observable completion cause: searches completing because all providers returned all their results and searches completing because the consumer aborted the search using the aborted$ option or because the internal timout period has been reaches will both complete the same way.