From 478aea02783acea2b33f15b69b34852c296db718 Mon Sep 17 00:00:00 2001 From: Yuliia Naumenko Date: Tue, 15 Dec 2020 12:20:51 -0800 Subject: [PATCH] Removed Alerting & Event Log deprecated fields that should not be using (#85652) (#85897) * Removed Alerting & Event Log deprecated fields that should not be using * fixed due to comments --- .../plugins/actions/server/usage/actions_telemetry.ts | 2 -- .../plugins/alerts/server/usage/alerts_telemetry.ts | 2 -- .../server/es/cluster_client_adapter.test.ts | 8 ++++---- .../event_log/server/es/cluster_client_adapter.ts | 11 +++++------ 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/actions/server/usage/actions_telemetry.ts b/x-pack/plugins/actions/server/usage/actions_telemetry.ts index 2815b5fbe6a5e..e3ff2552fed9c 100644 --- a/x-pack/plugins/actions/server/usage/actions_telemetry.ts +++ b/x-pack/plugins/actions/server/usage/actions_telemetry.ts @@ -35,7 +35,6 @@ export async function getTotalCount(callCluster: LegacyAPICaller, kibanaIndex: s const searchResult = await callCluster('search', { index: kibanaIndex, - rest_total_hits_as_int: true, body: { query: { bool: { @@ -104,7 +103,6 @@ export async function getInUseTotalCount(callCluster: LegacyAPICaller, kibanaInd const actionResults = await callCluster('search', { index: kibanaIndex, - rest_total_hits_as_int: true, body: { query: { bool: { diff --git a/x-pack/plugins/alerts/server/usage/alerts_telemetry.ts b/x-pack/plugins/alerts/server/usage/alerts_telemetry.ts index 389178de3e5d0..6edebb1decb61 100644 --- a/x-pack/plugins/alerts/server/usage/alerts_telemetry.ts +++ b/x-pack/plugins/alerts/server/usage/alerts_telemetry.ts @@ -215,7 +215,6 @@ export async function getTotalCountAggregations(callCluster: LegacyAPICaller, ki const results = await callCluster('search', { index: kibanaInex, - rest_total_hits_as_int: true, body: { query: { bool: { @@ -289,7 +288,6 @@ export async function getTotalCountAggregations(callCluster: LegacyAPICaller, ki export async function getTotalCountInUse(callCluster: LegacyAPICaller, kibanaInex: string) { const searchResult: SearchResponse = await callCluster('search', { index: kibanaInex, - rest_total_hits_as_int: true, body: { query: { bool: { diff --git a/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts b/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts index 57a6b1d3bb932..2b1d89f12be56 100644 --- a/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts +++ b/x-pack/plugins/event_log/server/es/cluster_client_adapter.test.ts @@ -394,7 +394,7 @@ describe('queryEventsBySavedObject', () => { }, }, "index": "index-name", - "rest_total_hits_as_int": true, + "track_total_hits": true, } `); }); @@ -475,7 +475,7 @@ describe('queryEventsBySavedObject', () => { }, }, "index": "index-name", - "rest_total_hits_as_int": true, + "track_total_hits": true, } `); }); @@ -589,7 +589,7 @@ describe('queryEventsBySavedObject', () => { }, }, "index": "index-name", - "rest_total_hits_as_int": true, + "track_total_hits": true, } `); }); @@ -686,7 +686,7 @@ describe('queryEventsBySavedObject', () => { }, }, "index": "index-name", - "rest_total_hits_as_int": true, + "track_total_hits": true, } `); }); diff --git a/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts b/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts index d1dcf621150a6..0ac1193998cef 100644 --- a/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts +++ b/x-pack/plugins/event_log/server/es/cluster_client_adapter.ts @@ -7,9 +7,10 @@ import { Subject } from 'rxjs'; import { bufferTime, filter, switchMap } from 'rxjs/operators'; import { reject, isUndefined } from 'lodash'; -import { SearchResponse, Client } from 'elasticsearch'; +import { Client } from 'elasticsearch'; import type { PublicMethodsOf } from '@kbn/utility-types'; import { Logger, LegacyClusterClient } from 'src/core/server'; +import { ESSearchResponse } from '../../../../typings/elasticsearch'; import { EsContext } from '.'; import { IEvent, IValidatedEvent, SAVED_OBJECT_REL_PRIMARY } from '../types'; import { FindOptionsType } from '../event_log_client'; @@ -284,17 +285,15 @@ export class ClusterClientAdapter { try { const { hits: { hits, total }, - }: SearchResponse = await this.callEs('search', { + }: ESSearchResponse = await this.callEs('search', { index, - // The SearchResponse type only supports total as an int, - // so we're forced to explicitly request that it return as an int - rest_total_hits_as_int: true, + track_total_hits: true, body, }); return { page, per_page: perPage, - total, + total: total.value, data: hits.map((hit) => hit._source) as IValidatedEvent[], }; } catch (err) {