diff --git a/x-pack/plugins/data_enhanced/server/search/es_search_strategy.test.ts b/x-pack/plugins/data_enhanced/server/search/es_search_strategy.test.ts index 46aa7074fc6966..a287f72ca91619 100644 --- a/x-pack/plugins/data_enhanced/server/search/es_search_strategy.test.ts +++ b/x-pack/plugins/data_enhanced/server/search/es_search_strategy.test.ts @@ -91,9 +91,9 @@ describe('ES search strategy', () => { expect(mockGetCaller).toBeCalled(); const request = mockGetCaller.mock.calls[0][0]; - expect(request).toEqual({ - id: 'foo', - }); + expect(request.id).toEqual('foo'); + expect(request).toHaveProperty('wait_for_completion_timeout'); + expect(request).toHaveProperty('keep_alive'); }); it('calls the rollup API if the index is a rollup type', async () => { diff --git a/x-pack/plugins/data_enhanced/server/search/es_search_strategy.ts b/x-pack/plugins/data_enhanced/server/search/es_search_strategy.ts index 81e1549118277f..4ace1c4c5385be 100644 --- a/x-pack/plugins/data_enhanced/server/search/es_search_strategy.ts +++ b/x-pack/plugins/data_enhanced/server/search/es_search_strategy.ts @@ -84,13 +84,18 @@ async function asyncSearch( options?: ISearchOptions ): Promise { let esResponse; + + const asyncOptions = { + waitForCompletionTimeout: '100ms', // Wait up to 100ms for the response to return + keepAlive: '1m', // Extend the TTL for this search request by one minute + }; + // If we have an ID, then just poll for that ID, otherwise send the entire request body if (!request.id) { const submitOptions = toSnakeCase({ batchedReduceSize: 64, // Only report partial results every 64 shards; this should be reduced when we actually display partial results trackTotalHits: true, // Get the exact count of hits - waitForCompletionTimeout: '100ms', // Wait up to 100ms for the response to return - keepAlive: '1m', // Extend the TTL for this search request by one minute + ...asyncOptions, ...request.params, }); @@ -98,6 +103,7 @@ async function asyncSearch( } else { esResponse = await client.asyncSearch.get({ id: request.id, + ...toSnakeCase(asyncOptions), }); }