Skip to content

Commit

Permalink
[Logs UI] Replace legacy es client usage in category examples (#100716)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
weltenwort and kibanamachine committed Jun 1, 2021
1 parent 151f5fd commit 61a49c6
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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();
Expand Down

0 comments on commit 61a49c6

Please sign in to comment.