[Logs UI] Replace legacy es client usage in category examples (#100716)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Felix Stürmer 2021-06-01 15:48:40 +02:00 committed by GitHub
parent 151f5fdee1
commit 61a49c6119
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,7 @@
*/ */
import type { estypes } from '@elastic/elasticsearch'; import type { estypes } from '@elastic/elasticsearch';
import type { ILegacyScopedClusterClient } from 'src/core/server'; import type { ElasticsearchClient } from 'src/core/server';
import { import {
compareDatasetsByMaximumAnomalyScore, compareDatasetsByMaximumAnomalyScore,
getJobId, getJobId,
@ -136,7 +136,7 @@ export async function getLogEntryCategoryDatasets(
export async function getLogEntryCategoryExamples( export async function getLogEntryCategoryExamples(
context: { context: {
core: { elasticsearch: { legacy: { client: ILegacyScopedClusterClient } } }; core: { elasticsearch: { client: { asCurrentUser: ElasticsearchClient } } };
infra: { infra: {
mlAnomalyDetectors: MlAnomalyDetectors; mlAnomalyDetectors: MlAnomalyDetectors;
mlSystem: MlSystem; mlSystem: MlSystem;
@ -402,7 +402,7 @@ async function fetchTopLogEntryCategoryHistograms(
} }
async function fetchLogEntryCategoryExamples( async function fetchLogEntryCategoryExamples(
requestContext: { core: { elasticsearch: { legacy: { client: ILegacyScopedClusterClient } } } }, requestContext: { core: { elasticsearch: { client: { asCurrentUser: ElasticsearchClient } } } },
indices: string, indices: string,
runtimeMappings: estypes.RuntimeFields, runtimeMappings: estypes.RuntimeFields,
timestampField: string, timestampField: string,
@ -417,8 +417,8 @@ async function fetchLogEntryCategoryExamples(
const { const {
hits: { hits }, hits: { hits },
} = decodeOrThrow(logEntryCategoryExamplesResponseRT)( } = decodeOrThrow(logEntryCategoryExamplesResponseRT)(
await requestContext.core.elasticsearch.legacy.client.callAsCurrentUser( (
'search', await requestContext.core.elasticsearch.client.asCurrentUser.search(
createLogEntryCategoryExamplesQuery( createLogEntryCategoryExamplesQuery(
indices, indices,
runtimeMappings, runtimeMappings,
@ -430,6 +430,7 @@ async function fetchLogEntryCategoryExamples(
exampleCount exampleCount
) )
) )
).body
); );
const esSearchSpan = finalizeEsSearchSpan(); const esSearchSpan = finalizeEsSearchSpan();