diff --git a/x-pack/plugins/ml/common/types/anomalies.ts b/x-pack/plugins/ml/common/types/anomalies.ts index e84035aa50c8f8..2bf717067f7129 100644 --- a/x-pack/plugins/ml/common/types/anomalies.ts +++ b/x-pack/plugins/ml/common/types/anomalies.ts @@ -12,6 +12,8 @@ export interface Influencer { influencer_field_values: string[]; } +export type MLAnomalyDoc = AnomalyRecordDoc; + export interface AnomalyRecordDoc { [key: string]: any; job_id: string; diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/results_loader/searches.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/results_loader/searches.ts index e6e6b5305b1f83..65c0d30414eed2 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/results_loader/searches.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/results_loader/searches.ts @@ -74,6 +74,7 @@ export function getScoresByRecord( timestamp: { gte: earliestMs, lte: latestMs, + // @ts-ignore format: 'epoch_millis', }, }, diff --git a/x-pack/plugins/ml/public/application/services/ml_api_service/results.ts b/x-pack/plugins/ml/public/application/services/ml_api_service/results.ts index 1797fdb17669e1..a9f6dbb45f6e34 100644 --- a/x-pack/plugins/ml/public/application/services/ml_api_service/results.ts +++ b/x-pack/plugins/ml/public/application/services/ml_api_service/results.ts @@ -16,6 +16,11 @@ import { JobId } from '../../../../common/types/anomaly_detection_jobs'; import { JOB_ID, PARTITION_FIELD_VALUE } from '../../../../common/constants/anomalies'; import { PartitionFieldsDefinition } from '../results_service/result_service_rx'; import { PartitionFieldsConfig } from '../../../../common/types/storage'; +import { + ESSearchRequest, + ESSearchResponse, +} from '../../../../../../../src/core/types/elasticsearch'; +import { MLAnomalyDoc } from '../../../../common/types/anomalies'; export const resultsApiProvider = (httpService: HttpService) => ({ getAnomaliesTableData( @@ -112,18 +117,18 @@ export const resultsApiProvider = (httpService: HttpService) => ({ }); }, - anomalySearch(query: object, jobIds: string[]) { + anomalySearch(query: ESSearchRequest, jobIds: string[]) { const body = JSON.stringify({ query, jobIds }); - return httpService.http({ + return httpService.http>({ path: `${basePath()}/results/anomaly_search`, method: 'POST', body, }); }, - anomalySearch$(query: object, jobIds: string[]) { + anomalySearch$(query: ESSearchRequest, jobIds: string[]) { const body = JSON.stringify({ query, jobIds }); - return httpService.http$({ + return httpService.http$>({ path: `${basePath()}/results/anomaly_search`, method: 'POST', body,