diff --git a/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts index aea946ae87e7..ee2441d59113 100644 --- a/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts +++ b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_categories_analysis.ts @@ -6,7 +6,7 @@ */ import type { estypes } from '@elastic/elasticsearch'; -import type { ILegacyScopedClusterClient } from 'src/core/server'; +import type { ElasticsearchClient } from 'src/core/server'; import { compareDatasetsByMaximumAnomalyScore, getJobId, @@ -136,7 +136,7 @@ export async function getLogEntryCategoryDatasets( export async function getLogEntryCategoryExamples( context: { - core: { elasticsearch: { legacy: { client: ILegacyScopedClusterClient } } }; + core: { elasticsearch: { client: { asCurrentUser: ElasticsearchClient } } }; infra: { mlAnomalyDetectors: MlAnomalyDetectors; mlSystem: MlSystem; @@ -402,7 +402,7 @@ async function fetchTopLogEntryCategoryHistograms( } async function fetchLogEntryCategoryExamples( - requestContext: { core: { elasticsearch: { legacy: { client: ILegacyScopedClusterClient } } } }, + requestContext: { core: { elasticsearch: { client: { asCurrentUser: ElasticsearchClient } } } }, indices: string, runtimeMappings: estypes.RuntimeFields, timestampField: string, @@ -417,19 +417,20 @@ async function fetchLogEntryCategoryExamples( const { hits: { hits }, } = decodeOrThrow(logEntryCategoryExamplesResponseRT)( - await requestContext.core.elasticsearch.legacy.client.callAsCurrentUser( - 'search', - createLogEntryCategoryExamplesQuery( - indices, - runtimeMappings, - timestampField, - tiebreakerField, - startTime, - endTime, - categoryQuery, - exampleCount + ( + await requestContext.core.elasticsearch.client.asCurrentUser.search( + createLogEntryCategoryExamplesQuery( + indices, + runtimeMappings, + timestampField, + tiebreakerField, + startTime, + endTime, + categoryQuery, + exampleCount + ) ) - ) + ).body ); const esSearchSpan = finalizeEsSearchSpan();