From 7cd7abbefe0d10080e2da7f97c083487f43b28fb Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Thu, 20 Jan 2022 09:30:33 -0700 Subject: [PATCH] remove any --- x-pack/plugins/ml/public/maps/util.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/ml/public/maps/util.ts b/x-pack/plugins/ml/public/maps/util.ts index d6dd023c6dc896d..6a9d55ad64d3856 100644 --- a/x-pack/plugins/ml/public/maps/util.ts +++ b/x-pack/plugins/ml/public/maps/util.ts @@ -6,6 +6,7 @@ */ import { FeatureCollection, Feature, Geometry } from 'geojson'; +import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { ESSearchResponse } from '../../../../../src/core/types/elasticsearch'; import { formatHumanReadableDateTimeSeconds } from '../../common/util/date_utils'; import type { MlApiServices } from '../application/services/ml_api_service'; @@ -31,11 +32,17 @@ export async function getResultsForJobId( searchFilters: VectorSourceRequestMeta ): Promise { const { timeFilters } = searchFilters; + + const must: estypes.QueryDslQueryContainer[] = [ + { term: { job_id: jobId } }, + { term: { result_type: 'record' } }, + ]; + // Query to look for the highest scoring anomaly. - const body: any = { + const body: estypes.SearchRequest['body'] = { query: { bool: { - must: [{ term: { job_id: jobId } }, { term: { result_type: 'record' } }], + must, }, }, size: 1000, @@ -53,7 +60,7 @@ export async function getResultsForJobId( }, }, }; - body.query.bool.must.push(timerange); + must.push(timerange); } let resp: ESSearchResponse | null = null;