Skip to content

Commit 2ba358f

Browse files
author
Liza K
committed
shim inside strategies
1 parent 09eaaac commit 2ba358f

4 files changed

Lines changed: 7 additions & 12 deletions

File tree

src/plugins/data/server/search/es_search/response_utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
import { SearchResponse } from 'elasticsearch';
21+
import { shimHitsTotal } from '..';
2122

2223
/**
2324
* Get the `total`/`loaded` for this response (see `IKibanaSearchResponse`). Note that `skipped` is
@@ -36,7 +37,7 @@ export function getTotalLoaded(response: SearchResponse<unknown>) {
3637
*/
3738
export function toKibanaSearchResponse(rawResponse: SearchResponse<unknown>) {
3839
return {
39-
rawResponse,
40+
rawResponse: shimHitsTotal(rawResponse),
4041
isPartial: false,
4142
isRunning: false,
4243
...getTotalLoaded(rawResponse),

src/plugins/data/server/search/routes/search.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { first } from 'rxjs/operators';
2121
import { schema } from '@kbn/config-schema';
2222
import type { IRouter } from 'src/core/server';
2323
import { getRequestAbortedSignal } from '../../lib';
24-
import { shimHitsTotal } from './shim_hits_total';
2524

2625
export function registerSearchRoute(router: IRouter): void {
2726
router.post(
@@ -66,12 +65,7 @@ export function registerSearchRoute(router: IRouter): void {
6665
.toPromise();
6766

6867
return res.ok({
69-
body: {
70-
...response,
71-
...{
72-
rawResponse: shimHitsTotal(response.rawResponse),
73-
},
74-
},
68+
body: response,
7569
});
7670
} catch (err) {
7771
return res.customError({

src/plugins/data/server/search/search_service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import { AggsService } from './aggs';
4343

4444
import { FieldFormatsStart } from '../field_formats';
4545
import { IndexPatternsServiceStart } from '../index_patterns';
46-
import { getCallMsearch, registerMsearchRoute, registerSearchRoute, shimHitsTotal } from './routes';
46+
import { getCallMsearch, registerMsearchRoute, registerSearchRoute } from './routes';
4747
import { ES_SEARCH_STRATEGY, esSearchStrategyProvider } from './es_search';
4848
import { DataPluginStart } from '../plugin';
4949
import { UsageCollectionSetup } from '../../../usage_collection/server';

x-pack/plugins/data_enhanced/server/search/response_utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { ApiResponse } from '@elastic/elasticsearch';
8-
import { getTotalLoaded } from '../../../../../src/plugins/data/server';
8+
import { getTotalLoaded, shimHitsTotal } from '../../../../../src/plugins/data/server';
99
import { AsyncSearchResponse, EqlSearchResponse } from './types';
1010
import { EqlSearchStrategyResponse } from '../../common/search';
1111

@@ -15,7 +15,7 @@ import { EqlSearchStrategyResponse } from '../../common/search';
1515
export function toAsyncKibanaSearchResponse(response: AsyncSearchResponse) {
1616
return {
1717
id: response.id,
18-
rawResponse: response.response,
18+
rawResponse: shimHitsTotal(response.response),
1919
isPartial: response.is_partial,
2020
isRunning: response.is_running,
2121
...getTotalLoaded(response.response),
@@ -31,7 +31,7 @@ export function toEqlKibanaSearchResponse(
3131
): EqlSearchStrategyResponse {
3232
return {
3333
id: response.body.id,
34-
rawResponse: response,
34+
rawResponse: shimHitsTotal(response.response),
3535
isPartial: response.body.is_partial,
3636
isRunning: response.body.is_running,
3737
};

0 commit comments

Comments
 (0)