Skip to content
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

[Search] Unify search plugin step 1 #95811

Merged
merged 26 commits into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ Failure to have auth enabled in Kibana will make for a broken UI. UI-based error


|{kib-repo}blob/{branch}/x-pack/plugins/data_enhanced/README.md[dataEnhanced]
|The data_enhanced plugin is the x-pack counterpart to the OSS data plugin.
|The data_enhanced plugin is the x-pack counterpart to the src/plguins/data plugin.


|{kib-repo}blob/{branch}/x-pack/plugins/discover_enhanced/README.md[discoverEnhanced]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [AsyncSearchResponse](./kibana-plugin-plugins-data-server.asyncsearchresponse.md) &gt; [expiration\_time\_in\_millis](./kibana-plugin-plugins-data-server.asyncsearchresponse.expiration_time_in_millis.md)

## AsyncSearchResponse.expiration\_time\_in\_millis property

<b>Signature:</b>

```typescript
expiration_time_in_millis: number;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [AsyncSearchResponse](./kibana-plugin-plugins-data-server.asyncsearchresponse.md) &gt; [id](./kibana-plugin-plugins-data-server.asyncsearchresponse.id.md)

## AsyncSearchResponse.id property

<b>Signature:</b>

```typescript
id?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [AsyncSearchResponse](./kibana-plugin-plugins-data-server.asyncsearchresponse.md) &gt; [is\_partial](./kibana-plugin-plugins-data-server.asyncsearchresponse.is_partial.md)

## AsyncSearchResponse.is\_partial property

<b>Signature:</b>

```typescript
is_partial: boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [AsyncSearchResponse](./kibana-plugin-plugins-data-server.asyncsearchresponse.md) &gt; [is\_running](./kibana-plugin-plugins-data-server.asyncsearchresponse.is_running.md)

## AsyncSearchResponse.is\_running property

<b>Signature:</b>

```typescript
is_running: boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [AsyncSearchResponse](./kibana-plugin-plugins-data-server.asyncsearchresponse.md)

## AsyncSearchResponse interface

<b>Signature:</b>

```typescript
export interface AsyncSearchResponse<T = unknown>
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [expiration\_time\_in\_millis](./kibana-plugin-plugins-data-server.asyncsearchresponse.expiration_time_in_millis.md) | <code>number</code> | |
| [id](./kibana-plugin-plugins-data-server.asyncsearchresponse.id.md) | <code>string</code> | |
| [is\_partial](./kibana-plugin-plugins-data-server.asyncsearchresponse.is_partial.md) | <code>boolean</code> | |
| [is\_running](./kibana-plugin-plugins-data-server.asyncsearchresponse.is_running.md) | <code>boolean</code> | |
| [response](./kibana-plugin-plugins-data-server.asyncsearchresponse.response.md) | <code>estypes.SearchResponse&lt;T&gt;</code> | |
| [start\_time\_in\_millis](./kibana-plugin-plugins-data-server.asyncsearchresponse.start_time_in_millis.md) | <code>number</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [AsyncSearchResponse](./kibana-plugin-plugins-data-server.asyncsearchresponse.md) &gt; [response](./kibana-plugin-plugins-data-server.asyncsearchresponse.response.md)

## AsyncSearchResponse.response property

<b>Signature:</b>

```typescript
response: estypes.SearchResponse<T>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [AsyncSearchResponse](./kibana-plugin-plugins-data-server.asyncsearchresponse.md) &gt; [start\_time\_in\_millis](./kibana-plugin-plugins-data-server.asyncsearchresponse.start_time_in_millis.md)

## AsyncSearchResponse.start\_time\_in\_millis property

<b>Signature:</b>

```typescript
start_time_in_millis: number;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [AsyncSearchStatusResponse](./kibana-plugin-plugins-data-server.asyncsearchstatusresponse.md) &gt; [\_shards](./kibana-plugin-plugins-data-server.asyncsearchstatusresponse._shards.md)

## AsyncSearchStatusResponse.\_shards property

<b>Signature:</b>

```typescript
_shards: ShardsResponse;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [AsyncSearchStatusResponse](./kibana-plugin-plugins-data-server.asyncsearchstatusresponse.md) &gt; [completion\_status](./kibana-plugin-plugins-data-server.asyncsearchstatusresponse.completion_status.md)

## AsyncSearchStatusResponse.completion\_status property

<b>Signature:</b>

```typescript
completion_status: number;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [AsyncSearchStatusResponse](./kibana-plugin-plugins-data-server.asyncsearchstatusresponse.md)

## AsyncSearchStatusResponse interface

<b>Signature:</b>

```typescript
export interface AsyncSearchStatusResponse extends Omit<AsyncSearchResponse, 'response'>
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [\_shards](./kibana-plugin-plugins-data-server.asyncsearchstatusresponse._shards.md) | <code>ShardsResponse</code> | |
| [completion\_status](./kibana-plugin-plugins-data-server.asyncsearchstatusresponse.completion_status.md) | <code>number</code> | |

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
| --- | --- |
| [AggFunctionsMapping](./kibana-plugin-plugins-data-server.aggfunctionsmapping.md) | A global list of the expression function definitions for each agg type function. |
| [AggParamOption](./kibana-plugin-plugins-data-server.aggparamoption.md) | |
| [AsyncSearchResponse](./kibana-plugin-plugins-data-server.asyncsearchresponse.md) | |
| [AsyncSearchStatusResponse](./kibana-plugin-plugins-data-server.asyncsearchstatusresponse.md) | |
| [EsQueryConfig](./kibana-plugin-plugins-data-server.esqueryconfig.md) | |
| [FieldDescriptor](./kibana-plugin-plugins-data-server.fielddescriptor.md) | |
| [FieldFormatConfig](./kibana-plugin-plugins-data-server.fieldformatconfig.md) | |
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/data/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,7 @@ The `SearchSource` API is a convenient way to construct and run an Elasticsearch

#### Default Search Strategy

One benefit of using the low-level search API, is partial response support in X-Pack, allowing for a better and more responsive user experience.
In OSS only the final result is returned.
One benefit of using the low-level search API, is partial response support, allowing for a better and more responsive user experience.

```.ts
import { isCompleteResponse } from '../plugins/data/public';
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/data/common/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
*/

export * from './aggs';
export * from './es_search';
export * from './expressions';
export * from './search_source';
export * from './tabify';
export * from './types';
export * from './utils';
export * from './session';
export * from './poll_search';
export * from './strategies/es_search';
export * from './strategies/eql_search';
export * from './strategies/ese_search';
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { pollSearch } from './poll_search';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { from, Observable, timer, defer, fromEvent, EMPTY } from 'rxjs';
import { expand, map, switchMap, takeUntil, takeWhile, tap } from 'rxjs/operators';
import type { IKibanaSearchResponse } from '../../../../../src/plugins/data/common';
import type {
IAsyncSearchOptions,
IKibanaSearchResponse,
} from '../../../../../src/plugins/data/common';
import { isErrorResponse, isPartialResponse } from '../../../../../src/plugins/data/common';
import { AbortError } from '../../../../../src/plugins/kibana_utils/common';
import type { IAsyncSearchOptions } from './types';

export const pollSearch = <Response extends IKibanaSearchResponse>(
search: () => Promise<Response>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { EqlSearch } from '@elastic/elasticsearch/api/requestParams';
import { ApiResponse, TransportRequestOptions } from '@elastic/elasticsearch/lib/Transport';

import {
ISearchOptions,
IKibanaSearchRequest,
IKibanaSearchResponse,
} from '../../../../../src/plugins/data/common';

export const ENHANCED_ES_SEARCH_STRATEGY = 'ese';
import { IKibanaSearchRequest, IKibanaSearchResponse } from '../../types';

export const EQL_SEARCH_STRATEGY = 'eql';

Expand All @@ -25,10 +20,3 @@ export interface EqlSearchStrategyRequest extends IKibanaSearchRequest<EqlReques
}

export type EqlSearchStrategyResponse<T = unknown> = IKibanaSearchResponse<ApiResponse<T>>;

export interface IAsyncSearchOptions extends ISearchOptions {
/**
* The number of milliseconds to wait between receiving a response and sending another request
*/
pollInterval?: number;
}
9 changes: 9 additions & 0 deletions src/plugins/data/common/search/strategies/es_search/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export * from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import type { estypes } from '@elastic/elasticsearch';

import { IKibanaSearchRequest, IKibanaSearchResponse } from '../types';
import { IKibanaSearchRequest, IKibanaSearchResponse } from '../../types';

export const ES_SEARCH_STRATEGY = 'es';

Expand Down
9 changes: 9 additions & 0 deletions src/plugins/data/common/search/strategies/ese_search/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export * from './types';
18 changes: 18 additions & 0 deletions src/plugins/data/common/search/strategies/ese_search/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { ISearchOptions } from '../../types';

export const ENHANCED_ES_SEARCH_STRATEGY = 'ese';

export interface IAsyncSearchOptions extends ISearchOptions {
/**
* The number of milliseconds to wait between receiving a response and sending another request
*/
pollInterval?: number;
}
3 changes: 1 addition & 2 deletions src/plugins/data/common/search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
*/

import { Observable } from 'rxjs';
import { IEsSearchRequest, IEsSearchResponse } from './es_search';
import { IndexPattern } from '..';
import { IEsSearchRequest, IEsSearchResponse, IndexPattern } from '..';
import type { RequestAdapter } from '../../../inspector/common';

export type ISearchGeneric = <
Expand Down
59 changes: 59 additions & 0 deletions src/plugins/data/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,62 @@ export const configSchema = schema.object({
});

export type ConfigSchema = TypeOf<typeof configSchema>;

export const searchSessionsConfigSchema = schema.object({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to move the schema now to src/ because ese strategy uses defaultExpiration from it.
This schema is still registered by x-pack/ code

/**
* Turns the feature on \ off (incl. removing indicator and management screens)
*/
enabled: schema.boolean({ defaultValue: true }),
/**
* pageSize controls how many search session objects we load at once while monitoring
* session completion
*/
pageSize: schema.number({ defaultValue: 100 }),
/**
* trackingInterval controls how often we track search session objects progress
*/
trackingInterval: schema.duration({ defaultValue: '10s' }),

/**
* monitoringTaskTimeout controls for how long task manager waits for search session monitoring task to complete before considering it timed out,
* If tasks timeouts it receives cancel signal and next task starts in "trackingInterval" time
*/
monitoringTaskTimeout: schema.duration({ defaultValue: '5m' }),

/**
* notTouchedTimeout controls how long do we store unpersisted search session results,
* after the last search in the session has completed
*/
notTouchedTimeout: schema.duration({ defaultValue: '5m' }),
/**
* notTouchedInProgressTimeout controls how long do allow a search session to run after
* a user has navigated away without persisting
*/
notTouchedInProgressTimeout: schema.duration({ defaultValue: '1m' }),
/**
* maxUpdateRetries controls how many retries we perform while attempting to save a search session
*/
maxUpdateRetries: schema.number({ defaultValue: 3 }),

/**
* defaultExpiration controls how long search sessions are valid for, until they are expired.
*/
defaultExpiration: schema.duration({ defaultValue: '7d' }),
management: schema.object({
/**
* maxSessions controls how many saved search sessions we display per page on the management screen.
*/
maxSessions: schema.number({ defaultValue: 10000 }),
/**
* refreshInterval controls how often we refresh the management screen.
*/
refreshInterval: schema.duration({ defaultValue: '10s' }),
/**
* refreshTimeout controls how often we refresh the management screen.
*/
refreshTimeout: schema.duration({ defaultValue: '1m' }),
expiresSoonWarning: schema.duration({ defaultValue: '1d' }),
}),
});

export type SearchSessionsConfigSchema = TypeOf<typeof searchSessionsConfigSchema>;
4 changes: 2 additions & 2 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2354,8 +2354,8 @@ export const SEARCH_SESSIONS_MANAGEMENT_ID = "search_sessions";
// Warning: (ae-missing-release-tag) "SearchBar" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const SearchBar: React.ComponentClass<Pick<Pick<SearchBarProps, "query" | "placeholder" | "isLoading" | "iconType" | "indexPatterns" | "filters" | "dataTestSubj" | "isClearable" | "intl" | "refreshInterval" | "nonKqlMode" | "nonKqlModeHelpText" | "screenTitle" | "onRefresh" | "onRefreshChange" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated">, "query" | "placeholder" | "isLoading" | "iconType" | "indexPatterns" | "filters" | "dataTestSubj" | "isClearable" | "refreshInterval" | "nonKqlMode" | "nonKqlModeHelpText" | "screenTitle" | "onRefresh" | "onRefreshChange" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated">, any> & {
WrappedComponent: React.ComponentType<Pick<SearchBarProps, "query" | "placeholder" | "isLoading" | "iconType" | "indexPatterns" | "filters" | "dataTestSubj" | "isClearable" | "intl" | "refreshInterval" | "nonKqlMode" | "nonKqlModeHelpText" | "screenTitle" | "onRefresh" | "onRefreshChange" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated"> & ReactIntl.InjectedIntlProps>;
export const SearchBar: React.ComponentClass<Pick<Pick<SearchBarProps, "query" | "placeholder" | "isLoading" | "iconType" | "indexPatterns" | "filters" | "dataTestSubj" | "refreshInterval" | "isClearable" | "intl" | "nonKqlMode" | "nonKqlModeHelpText" | "screenTitle" | "onRefresh" | "onRefreshChange" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated">, "query" | "placeholder" | "isLoading" | "iconType" | "indexPatterns" | "filters" | "dataTestSubj" | "refreshInterval" | "isClearable" | "nonKqlMode" | "nonKqlModeHelpText" | "screenTitle" | "onRefresh" | "onRefreshChange" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated">, any> & {
WrappedComponent: React.ComponentType<Pick<SearchBarProps, "query" | "placeholder" | "isLoading" | "iconType" | "indexPatterns" | "filters" | "dataTestSubj" | "refreshInterval" | "isClearable" | "intl" | "nonKqlMode" | "nonKqlModeHelpText" | "screenTitle" | "onRefresh" | "onRefreshChange" | "showQueryInput" | "showDatePicker" | "showAutoRefreshOnly" | "dateRangeFrom" | "dateRangeTo" | "isRefreshPaused" | "customSubmitButton" | "timeHistory" | "indicateNoData" | "onFiltersUpdated" | "savedQuery" | "showSaveQuery" | "onClearSavedQuery" | "showQueryBar" | "showFilterBar" | "onQueryChange" | "onQuerySubmit" | "onSaved" | "onSavedQueryUpdated"> & ReactIntl.InjectedIntlProps>;
};

// Warning: (ae-forgotten-export) The symbol "SearchBarOwnProps" needs to be exported by the entry point index.d.ts
Expand Down
Loading