* [GS] add search syntax support (#83422) * add search syntax parsing logic * fix ts types * use type filter in providers * move search syntax logic to the searchbar * fix test plugin types * fix test plugin types again * use `onSearch` prop to disable internal component search * add tag filter support * add FTR tests * move away from CI group 7 * fix unit tests * add unit tests * remove the API test suite * Add icons to the SO results * add test for unknown type / tag * nits * ignore case for the `type` filter * Add syntax help text * remove unused import * hide icon for non-application results * add tsdoc on query utils * coerce known filter values to string Co-authored-by: Ryan Keairns <contactryank@gmail.com> * fix mappings for 7.x Co-authored-by: Ryan Keairns <contactryank@gmail.com>
114 lines
3.9 KiB
TypeScript
114 lines
3.9 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
*/
|
|
|
|
import { Observable } from 'rxjs';
|
|
import { Serializable } from 'src/core/types';
|
|
|
|
/**
|
|
* Options provided to {@link GlobalSearchResultProvider | a result provider}'s `find` method.
|
|
*/
|
|
export interface GlobalSearchProviderFindOptions {
|
|
/**
|
|
* A custom preference token associated with a search 'session' that should be used to get consistent scoring
|
|
* when performing calls to ES. Can also be used as a 'session' token for providers returning data from elsewhere
|
|
* than an elasticsearch cluster.
|
|
*/
|
|
preference: string;
|
|
/**
|
|
* Observable that emits once if and when the `find` call has been aborted, either manually by the consumer,
|
|
* or when the internal timeout period as been reached.
|
|
*
|
|
* When a `find` request is effectively aborted, the service will stop emitting any new result to the consumer anyway, but
|
|
* this can (and should) be used to cancel any pending asynchronous task and complete the result observable from within the provider.
|
|
*/
|
|
aborted$: Observable<void>;
|
|
/**
|
|
* The total maximum number of results (including all batches, not per emission) that should be returned by the provider for a given `find` request.
|
|
* Any result emitted exceeding this quota will be ignored by the service and not emitted to the consumer.
|
|
*/
|
|
maxResults: number;
|
|
}
|
|
|
|
/**
|
|
* Structured type for the {@link GlobalSearchProviderResult.url | provider result's url property}
|
|
*/
|
|
export type GlobalSearchProviderResultUrl = string | { path: string; prependBasePath: boolean };
|
|
|
|
/**
|
|
* Representation of a result returned by a {@link GlobalSearchResultProvider | result provider}
|
|
*/
|
|
export interface GlobalSearchProviderResult {
|
|
/** an id that should be unique for an individual provider's results */
|
|
id: string;
|
|
/** the title/label of the result */
|
|
title: string;
|
|
/** the type of result */
|
|
type: string;
|
|
/** an optional EUI icon name to associate with the search result */
|
|
icon?: string;
|
|
/**
|
|
* The url associated with this result.
|
|
* This can be either an absolute url, a path relative to the incoming request's basePath, or a structure specifying if the basePath should be prepended.
|
|
*
|
|
* @example
|
|
* `result.url = 'https://kibana-instance:8080/base-path/app/my-app/my-result-type/id';`
|
|
* `result.url = '/app/my-app/my-result-type/id';`
|
|
* `result.url = { path: '/base-path/s/my-other-space/app/my-app/my-result-type/id', prependBasePath: false };`
|
|
*/
|
|
url: GlobalSearchProviderResultUrl;
|
|
/** the score of the result, from 1 (lowest) to 100 (highest) */
|
|
score: number;
|
|
/** an optional record of metadata for this result */
|
|
meta?: Record<string, Serializable>;
|
|
}
|
|
|
|
/**
|
|
* Representation of a result returned by the {@link GlobalSearchPluginStart.find | `find` API}
|
|
*/
|
|
export type GlobalSearchResult = Omit<GlobalSearchProviderResult, 'url'> & {
|
|
/**
|
|
* The url associated with this result.
|
|
* This can be either an absolute url, or a relative path including the basePath
|
|
*/
|
|
url: string;
|
|
};
|
|
|
|
/**
|
|
* Response returned from the {@link GlobalSearchPluginStart | global search service}'s `find` API
|
|
*
|
|
* @public
|
|
*/
|
|
export interface GlobalSearchBatchedResults {
|
|
/**
|
|
* Results for this batch
|
|
*/
|
|
results: GlobalSearchResult[];
|
|
}
|
|
|
|
/**
|
|
* Search parameters for the {@link GlobalSearchPluginStart.find | `find` API}
|
|
*
|
|
* @public
|
|
*/
|
|
export interface GlobalSearchFindParams {
|
|
/**
|
|
* The term to search for. Can be undefined if searching by filters.
|
|
*/
|
|
term?: string;
|
|
/**
|
|
* The types of results to search for.
|
|
*/
|
|
types?: string[];
|
|
/**
|
|
* The tag ids to filter search by.
|
|
*/
|
|
tags?: string[];
|
|
}
|
|
|
|
/**
|
|
* @public
|
|
*/
|
|
export type GlobalSearchProviderFindParams = GlobalSearchFindParams;
|