Skip to content

Commit

Permalink
shim inside strategies
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza K committed Nov 24, 2020
1 parent 09eaaac commit 2ba358f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/plugins/data/server/search/es_search/response_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { SearchResponse } from 'elasticsearch';
import { shimHitsTotal } from '..';

/**
* Get the `total`/`loaded` for this response (see `IKibanaSearchResponse`). Note that `skipped` is
Expand All @@ -36,7 +37,7 @@ export function getTotalLoaded(response: SearchResponse<unknown>) {
*/
export function toKibanaSearchResponse(rawResponse: SearchResponse<unknown>) {
return {
rawResponse,
rawResponse: shimHitsTotal(rawResponse),
isPartial: false,
isRunning: false,
...getTotalLoaded(rawResponse),
Expand Down
8 changes: 1 addition & 7 deletions src/plugins/data/server/search/routes/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { first } from 'rxjs/operators';
import { schema } from '@kbn/config-schema';
import type { IRouter } from 'src/core/server';
import { getRequestAbortedSignal } from '../../lib';
import { shimHitsTotal } from './shim_hits_total';

export function registerSearchRoute(router: IRouter): void {
router.post(
Expand Down Expand Up @@ -66,12 +65,7 @@ export function registerSearchRoute(router: IRouter): void {
.toPromise();

return res.ok({
body: {
...response,
...{
rawResponse: shimHitsTotal(response.rawResponse),
},
},
body: response,
});
} catch (err) {
return res.customError({
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/server/search/search_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { AggsService } from './aggs';

import { FieldFormatsStart } from '../field_formats';
import { IndexPatternsServiceStart } from '../index_patterns';
import { getCallMsearch, registerMsearchRoute, registerSearchRoute, shimHitsTotal } from './routes';
import { getCallMsearch, registerMsearchRoute, registerSearchRoute } from './routes';
import { ES_SEARCH_STRATEGY, esSearchStrategyProvider } from './es_search';
import { DataPluginStart } from '../plugin';
import { UsageCollectionSetup } from '../../../usage_collection/server';
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/data_enhanced/server/search/response_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { ApiResponse } from '@elastic/elasticsearch';
import { getTotalLoaded } from '../../../../../src/plugins/data/server';
import { getTotalLoaded, shimHitsTotal } from '../../../../../src/plugins/data/server';
import { AsyncSearchResponse, EqlSearchResponse } from './types';
import { EqlSearchStrategyResponse } from '../../common/search';

Expand All @@ -15,7 +15,7 @@ import { EqlSearchStrategyResponse } from '../../common/search';
export function toAsyncKibanaSearchResponse(response: AsyncSearchResponse) {
return {
id: response.id,
rawResponse: response.response,
rawResponse: shimHitsTotal(response.response),
isPartial: response.is_partial,
isRunning: response.is_running,
...getTotalLoaded(response.response),
Expand All @@ -31,7 +31,7 @@ export function toEqlKibanaSearchResponse(
): EqlSearchStrategyResponse {
return {
id: response.body.id,
rawResponse: response,
rawResponse: shimHitsTotal(response.response),
isPartial: response.body.is_partial,
isRunning: response.body.is_running,
};
Expand Down

0 comments on commit 2ba358f

Please sign in to comment.