kibana/x-pack/plugins/global_search
Mikhail Shustov ad7866592e
[7.x] Revert "TS Incremental build exclude test files (#95610)" (#96223) (#96281)
* Revert "TS Incremental build exclude test files (#95610)" (#96223)

This reverts commit b6e582c53e.

* code: use base tsconfig
2021-04-06 05:52:22 -04:00
..
common [7.x] Elastic License 2.0 (#90192) 2021-02-03 18:39:13 -08:00
public [7.x] Elastic License 2.0 (#90192) 2021-02-03 18:39:13 -08:00
server [7.x] Migrate most plugins to synchronous lifecycle (#89562) (#90579) 2021-02-08 13:16:05 +01:00
jest.config.js [7.x] Elastic License 2.0 (#90192) 2021-02-03 18:39:13 -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 [7.x] Revert "TS Incremental build exclude test files (#95610)" (#96223) (#96281) 2021-04-06 05:52:22 -04: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.