[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 { 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();