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] Set keep_alive parameter in async search #73712

Merged
merged 5 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
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: '100ms', keepAlive: '1m', ...queryParams });
Copy link

Choose a reason for hiding this comment

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

Unrelated but it would be good to set the batched_reduce_size to a value greater than the default (5). I am saying this because we don't use partial results in Kibana at the moment so we don't need to create a partial results every 5 shards. Something like 32 or 64 should make the query faster and we can restore the default value when partial results are handled in Kibana ? It's also outside of the scope of this PR so I can open a new one if you like.

Copy link
Member Author

Choose a reason for hiding this comment

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

Are there any risks associated with increasing this value?

Copy link

Choose a reason for hiding this comment

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

Nope, in blocking search the value is set to 512 so I think it's the other way around, 5 is too low and can have a negative impact on queries in terms of memory and speed. The only advantage to set a low value is for partial results so we should set it higher until we expose partial results in Kibana.


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