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

Use new search strategy service for search requests #58990

Merged
merged 5 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -23,9 +23,9 @@ import { get } from 'lodash';
export function getPainlessError(error: Error) {
const rootCause: Array<{ lang: string; script: string }> | undefined = get(
error,
'resp.error.root_cause'
'body.attributes.error.root_cause'
);
const message: string = get(error, 'message');
const message: string = get(error, 'body.message');

if (!rootCause) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ describe('defaultSearchStrategy', function() {
test('should call new search service', () => {
const config = getConfigStub();
search({ ...searchArgs, config });
expect(searchMock).toHaveBeenCalled();
expect(newSearchMock).toHaveBeenCalledTimes(0);
expect(newSearchMock).toHaveBeenCalledTimes(1);
});

test('should properly abort with new search service', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,17 @@ function search({
}: SearchStrategySearchParams) {
const abortController = new AbortController();
const searchParams = getSearchParams(config, esShardTimeout);
const es = searchService.__LEGACY.esClient;
const promises = searchRequests.map(({ index, body }) => {
const searching = es.search({ index: index.title || index, body, ...searchParams });
abortController.signal.addEventListener('abort', searching.abort);
return searching.catch(({ response }: any) => JSON.parse(response));
/*
* Once #44302 is resolved, replace the old implementation with this one -
* const params = {
* index: index.title || index,
* body,
* ...searchParams,
* };
* const { signal } = abortController;
* return searchService
* .search({ params }, { signal })
* .toPromise()
* .then(({ rawResponse }) => rawResponse);
*/
const params = {
index: index.title || index,
body,
...searchParams,
};
const { signal } = abortController;
return searchService
.search({ params }, { signal })
.toPromise()
.then(({ rawResponse }) => rawResponse);
});
return {
searching: Promise.all(promises),
Expand Down