Skip to content
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 @@ -71,7 +71,7 @@ describe('ES search strategy', () => {
expect(mockApiCaller.mock.calls[0][0]).toBe('transport.request');
const { method, path, body } = mockApiCaller.mock.calls[0][1];
expect(method).toBe('POST');
expect(path).toBe('logstash-*/_async_search');
expect(path).toBe('/logstash-*/_async_search');
expect(body).toEqual({ query: {} });
});

Expand All @@ -94,7 +94,7 @@ describe('ES search strategy', () => {
expect(mockApiCaller.mock.calls[0][0]).toBe('transport.request');
const { method, path, body } = mockApiCaller.mock.calls[0][1];
expect(method).toBe('GET');
expect(path).toBe('_async_search/foo');
expect(path).toBe('/_async_search/foo');
expect(body).toEqual(undefined);
});

Expand All @@ -117,7 +117,7 @@ describe('ES search strategy', () => {
expect(mockApiCaller.mock.calls[0][0]).toBe('transport.request');
const { method, path } = mockApiCaller.mock.calls[0][1];
expect(method).toBe('POST');
expect(path).toBe('foo-%E7%A8%8B/_async_search');
expect(path).toBe('/foo-%E7%A8%8B/_async_search');
});

it('calls the rollup API if the index is a rollup type', async () => {
Expand All @@ -139,6 +139,6 @@ describe('ES search strategy', () => {
expect(mockApiCaller.mock.calls[0][0]).toBe('transport.request');
const { method, path } = mockApiCaller.mock.calls[0][1];
expect(method).toBe('POST');
expect(path).toBe('foo-%E7%A8%8B/_rollup_search');
expect(path).toBe('/foo-%E7%A8%8B/_rollup_search');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const enhancedEsSearchStrategyProvider: TSearchStrategyProvider<typeof ES

const cancel: ISearchCancel<typeof ES_SEARCH_STRATEGY> = async id => {
const method = 'DELETE';
const path = encodeURI(`_async_search/${id}`);
const path = encodeURI(`/_async_search/${id}`);
await caller('transport.request', { method, path });
};

Expand All @@ -66,7 +66,7 @@ async function asyncSearch(
const { body = undefined, index = undefined, ...queryParams } = request.id ? {} : params;

const method = request.id ? 'GET' : 'POST';
const path = encodeURI(request.id ? `_async_search/${request.id}` : `${index}/_async_search`);
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: '1s', ...queryParams });
Expand All @@ -87,7 +87,7 @@ async function rollupSearch(
) {
const { body, index, ...params } = request.params;
const method = 'POST';
const path = encodeURI(`${index}/_rollup_search`);
const path = encodeURI(`/${index}/_rollup_search`);
const query = toSnakeCase(params);

const rawResponse = await ((caller(
Expand Down