Skip to content

Commit

Permalink
Removed Alerting & Event Log deprecated fields that should not be usi…
Browse files Browse the repository at this point in the history
…ng (#85652) (#85897)

* Removed Alerting & Event Log deprecated fields that should not be using

* fixed due to comments
  • Loading branch information
YulNaumenko authored Dec 15, 2020
1 parent 602410e commit 478aea0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
2 changes: 0 additions & 2 deletions x-pack/plugins/actions/server/usage/actions_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/alerts/server/usage/alerts_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -289,7 +288,6 @@ export async function getTotalCountAggregations(callCluster: LegacyAPICaller, ki
export async function getTotalCountInUse(callCluster: LegacyAPICaller, kibanaInex: string) {
const searchResult: SearchResponse<unknown> = await callCluster('search', {
index: kibanaInex,
rest_total_hits_as_int: true,
body: {
query: {
bool: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ describe('queryEventsBySavedObject', () => {
},
},
"index": "index-name",
"rest_total_hits_as_int": true,
"track_total_hits": true,
}
`);
});
Expand Down Expand Up @@ -475,7 +475,7 @@ describe('queryEventsBySavedObject', () => {
},
},
"index": "index-name",
"rest_total_hits_as_int": true,
"track_total_hits": true,
}
`);
});
Expand Down Expand Up @@ -589,7 +589,7 @@ describe('queryEventsBySavedObject', () => {
},
},
"index": "index-name",
"rest_total_hits_as_int": true,
"track_total_hits": true,
}
`);
});
Expand Down Expand Up @@ -686,7 +686,7 @@ describe('queryEventsBySavedObject', () => {
},
},
"index": "index-name",
"rest_total_hits_as_int": true,
"track_total_hits": true,
}
`);
});
Expand Down
11 changes: 5 additions & 6 deletions x-pack/plugins/event_log/server/es/cluster_client_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -284,17 +285,15 @@ export class ClusterClientAdapter {
try {
const {
hits: { hits, total },
}: SearchResponse<unknown> = await this.callEs('search', {
}: ESSearchResponse<unknown, {}> = 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) {
Expand Down

0 comments on commit 478aea0

Please sign in to comment.