mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
* Use new search strategy * Update jest test * fix painless error Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
66d3a81896
commit
42bf1222b6
3 changed files with 13 additions and 21 deletions
|
@ -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;
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue