Skip to content

Commit

Permalink
[ML] fix ts
Browse files Browse the repository at this point in the history
  • Loading branch information
darnautov committed Jul 12, 2021
1 parent 13c47e1 commit b8e48ee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions x-pack/plugins/ml/common/types/anomalies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export interface Influencer {
influencer_field_values: string[];
}

export type MLAnomalyDoc = AnomalyRecordDoc;

export interface AnomalyRecordDoc {
[key: string]: any;
job_id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export function getScoresByRecord(
timestamp: {
gte: earliestMs,
lte: latestMs,
// @ts-ignore
format: 'epoch_millis',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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<object>({
return httpService.http<ESSearchResponse<MLAnomalyDoc>>({
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$<object>({
return httpService.http$<ESSearchResponse<MLAnomalyDoc>>({
path: `${basePath()}/results/anomaly_search`,
method: 'POST',
body,
Expand Down

0 comments on commit b8e48ee

Please sign in to comment.