Skip to content

Commit

Permalink
[Search] Set keep_alive parameter in async search
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasolson committed Jul 29, 2020
1 parent 2d8a41d commit e1b2d28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,19 @@ describe('ES search strategy', () => {
expect(method).toBe('POST');
expect(path).toBe('/foo-%E7%A8%8B/_rollup_search');
});

it('sets wait_for_completion_timeout and keep_alive in the request', async () => {
mockApiCaller.mockResolvedValueOnce(mockAsyncResponse);

const params = { index: 'foo-*', body: {} };
const esSearch = await enhancedEsSearchStrategyProvider(mockConfig$, mockLogger);

await esSearch.search((mockContext as unknown) as RequestHandlerContext, { params });

expect(mockApiCaller).toBeCalled();
expect(mockApiCaller.mock.calls[0][0]).toBe('transport.request');
const { query } = mockApiCaller.mock.calls[0][1];
expect(query).toHaveProperty('wait_for_completion_timeout');
expect(query).toHaveProperty('keep_alive');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async function asyncSearch(
const path = encodeURI(request.id ? `/_async_search/${request.id}` : `/${index}/_async_search`);

// Wait up to 1s for the response to return
const query = toSnakeCase({ waitForCompletionTimeout: '100ms', ...queryParams });
const query = toSnakeCase({ waitForCompletionTimeout: '1ms', keepAlive: '1m', ...queryParams });

const { id, response, is_partial, is_running } = (await caller(
'transport.request',
Expand Down

0 comments on commit e1b2d28

Please sign in to comment.