diff --git a/src/plugins/data/common/search/search_source/fetch/get_search_params.ts b/src/plugins/data/common/search/search_source/fetch/get_search_params.ts index 33617cf92fea..f32a7f593e6d 100644 --- a/src/plugins/data/common/search/search_source/fetch/get_search_params.ts +++ b/src/plugins/data/common/search/search_source/fetch/get_search_params.ts @@ -60,10 +60,13 @@ export function getSearchParamsFromRequest( ): ISearchRequestParams { const { getConfig } = dependencies; const searchParams = getSearchParams(getConfig); + // eslint-disable-next-line @typescript-eslint/naming-convention + const { track_total_hits, ...body } = searchRequest.body; return { index: searchRequest.index.title || searchRequest.index, - body: searchRequest.body, + body, + track_total_hits, ...searchParams, }; } diff --git a/src/plugins/data/common/search/search_source/search_source.ts b/src/plugins/data/common/search/search_source/search_source.ts index ea5d98670a66..e2516456f2b6 100644 --- a/src/plugins/data/common/search/search_source/search_source.ts +++ b/src/plugins/data/common/search/search_source/search_source.ts @@ -428,6 +428,8 @@ export class SearchSource { case 'type': case 'highlightAll': return key && data[key] == null && addToRoot(key, val); + case 'trackTotalHits': + return addToBody('track_total_hits', val); case 'searchAfter': return addToBody('search_after', val); case 'source': diff --git a/src/plugins/data/common/search/search_source/types.ts b/src/plugins/data/common/search/search_source/types.ts index 2ec4a31d94d8..c5bb4b5619be 100644 --- a/src/plugins/data/common/search/search_source/types.ts +++ b/src/plugins/data/common/search/search_source/types.ts @@ -89,6 +89,7 @@ export interface SearchSourceFields { sort?: OpenSearchQuerySortValue | OpenSearchQuerySortValue[]; highlight?: any; highlightAll?: boolean; + trackTotalHits?: boolean | number; /** * {@link AggConfigs} */