mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Search] Expose data.search.asyncSearch.pollInterval
(#143508)
This commit is contained in:
parent
f61dec4c3d
commit
1ec2edf4f4
9 changed files with 41 additions and 3 deletions
|
@ -44,6 +44,7 @@ kibana_vars=(
|
|||
data.search.asyncSearch.waitForCompletion
|
||||
data.search.asyncSearch.keepAlive
|
||||
data.search.asyncSearch.batchedReduceSize
|
||||
data.search.asyncSearch.pollInterval
|
||||
data.search.sessions.defaultExpiration
|
||||
data.search.sessions.enabled
|
||||
data.search.sessions.maxUpdateRetries
|
||||
|
|
|
@ -47,10 +47,31 @@ export const searchSessionsConfigSchema = schema.object({
|
|||
});
|
||||
|
||||
export const searchConfigSchema = schema.object({
|
||||
/**
|
||||
* Config for search strategies that use async search based API underneath
|
||||
*/
|
||||
asyncSearch: schema.object({
|
||||
/**
|
||||
* Block and wait until the search is completed up to the timeout (see es async_search's `wait_for_completion_timeout`)
|
||||
* TODO: we should optimize this as 100ms is likely not optimal (https://github.com/elastic/kibana/issues/143277)
|
||||
*/
|
||||
waitForCompletion: schema.duration({ defaultValue: '100ms' }),
|
||||
/**
|
||||
* How long the async search needs to be available after each search poll. Ongoing async searches and any saved search results are deleted after this period.
|
||||
* (see es async_search's `keep_alive`)
|
||||
* Note: This is applicable to the searches before the search session is saved.
|
||||
* After search session is saved `keep_alive` is extended using `data.search.sessions.defaultExpiration` config
|
||||
*/
|
||||
keepAlive: schema.duration({ defaultValue: '1m' }),
|
||||
/**
|
||||
* Affects how often partial results become available, which happens whenever shard results are reduced (see es async_search's `batched_reduce_size`)
|
||||
*/
|
||||
batchedReduceSize: schema.number({ defaultValue: 64 }),
|
||||
/**
|
||||
* How long to wait before polling the async_search after the previous poll response.
|
||||
* If not provided, then default dynamic interval with backoff is used.
|
||||
*/
|
||||
pollInterval: schema.maybe(schema.number({ min: 1000 })),
|
||||
}),
|
||||
aggs: schema.object({
|
||||
shardDelay: schema.object({
|
||||
|
|
|
@ -34,6 +34,7 @@ jest.mock('../errors/search_session_incomplete_warning', () => ({
|
|||
}));
|
||||
|
||||
import { SearchSessionIncompleteWarning } from '../errors/search_session_incomplete_warning';
|
||||
import { getMockSearchConfig } from '../../../config.mock';
|
||||
|
||||
let searchInterceptor: SearchInterceptor;
|
||||
let mockCoreSetup: MockedKeys<CoreSetup>;
|
||||
|
@ -122,6 +123,7 @@ describe('SearchInterceptor', () => {
|
|||
executionContext: mockCoreSetup.executionContext,
|
||||
session: sessionService,
|
||||
theme: themeServiceMock.createSetupContract(),
|
||||
searchConfig: getMockSearchConfig({}),
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ import { ISessionService, SearchSessionState } from '../session';
|
|||
import { SearchResponseCache } from './search_response_cache';
|
||||
import { createRequestHash } from './utils';
|
||||
import { SearchAbortController } from './search_abort_controller';
|
||||
import { SearchConfigSchema } from '../../../config';
|
||||
|
||||
export interface SearchInterceptorDeps {
|
||||
bfetch: BfetchPublicSetup;
|
||||
|
@ -83,6 +84,7 @@ export interface SearchInterceptorDeps {
|
|||
usageCollector?: SearchUsageCollector;
|
||||
session: ISessionService;
|
||||
theme: ThemeServiceSetup;
|
||||
searchConfig: SearchConfigSchema;
|
||||
}
|
||||
|
||||
const MAX_CACHE_ITEMS = 50;
|
||||
|
@ -302,6 +304,7 @@ export class SearchInterceptor {
|
|||
});
|
||||
|
||||
return pollSearch(search, cancel, {
|
||||
pollInterval: this.deps.searchConfig.asyncSearch.pollInterval,
|
||||
...options,
|
||||
abortSignal: searchAbortController.getSignal(),
|
||||
}).pipe(
|
||||
|
|
|
@ -134,6 +134,7 @@ export class SearchService implements Plugin<ISearchSetup, ISearchStart> {
|
|||
usageCollector: this.usageCollector!,
|
||||
session: this.sessionService,
|
||||
theme,
|
||||
searchConfig: this.initializerContext.config.get().search,
|
||||
});
|
||||
|
||||
expressions.registerFunction(
|
||||
|
|
|
@ -86,7 +86,10 @@ export const eqlSearchStrategyProvider = (
|
|||
}
|
||||
};
|
||||
|
||||
return pollSearch(search, cancel, options).pipe(tap((response) => (id = response.id)));
|
||||
return pollSearch(search, cancel, {
|
||||
pollInterval: searchConfig.asyncSearch.pollInterval,
|
||||
...options,
|
||||
}).pipe(tap((response) => (id = response.id)));
|
||||
},
|
||||
|
||||
extend: async (id, keepAlive, options, { esClient }) => {
|
||||
|
|
|
@ -87,7 +87,10 @@ export const enhancedEsSearchStrategyProvider = (
|
|||
}
|
||||
};
|
||||
|
||||
return pollSearch(search, cancel, options).pipe(
|
||||
return pollSearch(search, cancel, {
|
||||
pollInterval: searchConfig.asyncSearch.pollInterval,
|
||||
...options,
|
||||
}).pipe(
|
||||
tap((response) => (id = response.id)),
|
||||
tap(searchUsageObserver(logger, usage)),
|
||||
catchError((e) => {
|
||||
|
|
|
@ -88,7 +88,10 @@ export const sqlSearchStrategyProvider = (
|
|||
}
|
||||
};
|
||||
|
||||
return pollSearch(search, cancel, options).pipe(
|
||||
return pollSearch(search, cancel, {
|
||||
pollInterval: searchConfig.asyncSearch.pollInterval,
|
||||
...options,
|
||||
}).pipe(
|
||||
tap((response) => (id = response.id)),
|
||||
catchError((e) => {
|
||||
throw getKbnServerError(e);
|
||||
|
|
|
@ -94,6 +94,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
|
|||
'data.search.asyncSearch.batchedReduceSize (number)',
|
||||
'data.search.asyncSearch.keepAlive (duration)',
|
||||
'data.search.asyncSearch.waitForCompletion (duration)',
|
||||
'data.search.asyncSearch.pollInterval (number)',
|
||||
'data.search.sessions.defaultExpiration (duration)',
|
||||
'data.search.sessions.enabled (boolean)',
|
||||
'data.search.sessions.management.expiresSoonWarning (duration)',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue