Skip to content

Commit

Permalink
Use ES Client asyncSearch
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza K committed Sep 7, 2020
1 parent 68a9838 commit 7e73b45
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions x-pack/plugins/data_enhanced/server/search/es_search_strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ async function asyncSearch(

// If we have an ID, then just poll for that ID, otherwise send the entire request body
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`);

// Only report partial results every 64 shards; this should be reduced when we actually display partial results
const batchedReduceSize = request.id ? undefined : 64;

Expand All @@ -110,13 +106,17 @@ async function asyncSearch(
...queryParams,
});

// TODO: replace with async endpoints once https://github.com/elastic/elasticsearch-js/issues/1280 is resolved
const esResponse = await client.transport.request({
method,
path,
body,
querystring,
});
let esResponse;
if (!request.id) {
esResponse = await client.asyncSearch.submit({
body,
...querystring,
});
} else {
esResponse = await client.asyncSearch.get({
id: request.id,
});
}

const { id, response, is_partial: isPartial, is_running: isRunning } = esResponse.body;
return {
Expand Down

0 comments on commit 7e73b45

Please sign in to comment.