kibana/x-pack/plugins/global_search
Tyler Smalley 4681a80317
[DX] Upgrade prettier to v2.4.0 (#112359)
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
2021-09-19 22:34:30 -07:00
..
common [Data cleanup] unify serializable state (#107745) 2021-08-10 13:03:48 +02:00
public [DX] Upgrade prettier to v2.4.0 (#112359) 2021-09-19 22:34:30 -07:00
server [DX] Upgrade prettier to v2.4.0 (#112359) 2021-09-19 22:34:30 -07:00
jest.config.js [jest] update config files to get coverage per plugin (#111299) 2021-09-09 08:14:56 +02:00
kibana.json Adds team details to core/telemetry/localization-owned plugins (#107843) 2021-08-09 20:45:25 -04:00
README.md
tsconfig.json [build_ts_refs] improve caches, allow building a subset of projects (#107981) 2021-08-10 22:12:45 -07: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.