From 0d66d7166a964c6b47f2185b98fccca144db667c Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Wed, 15 Apr 2020 19:19:47 -0400 Subject: [PATCH] handle lucene queries --- .../data_frame_analytics/common/analytics.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/common/analytics.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/common/analytics.ts index a70b2ca884aed..3c959b827bb1c 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/common/analytics.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/common/analytics.ts @@ -267,6 +267,11 @@ export const isResultsSearchBoolQuery = (arg: any): arg is ResultsSearchBoolQuer return keys.length === 1 && keys[0] === 'bool'; }; +export const isQueryStringQuery = (arg: any): arg is QueryStringQuery => { + const keys = Object.keys(arg); + return keys.length === 1 && keys[0] === 'query_string'; +}; + export const isRegressionEvaluateResponse = (arg: any): arg is RegressionEvaluateResponse => { const keys = Object.keys(arg); return ( @@ -391,6 +396,10 @@ interface ResultsSearchTermQuery { term: Dictionary; } +interface QueryStringQuery { + query_string: Dictionary; +} + export type ResultsSearchQuery = ResultsSearchBoolQuery | ResultsSearchTermQuery | SavedSearchQuery; export function getEvalQueryBody({ @@ -419,8 +428,14 @@ export function getEvalQueryBody({ searchQueryClone.bool.must.push(trainingQuery); query = searchQueryClone; + } else if (isQueryStringQuery(searchQueryClone)) { + query = { + bool: { + must: [searchQueryClone, trainingQuery], + }, + }; } else { - // Not a bool query so we need to create it so can add the trainingQuery + // Not a bool or string query so we need to create it so can add the trainingQuery query = { bool: { must: [trainingQuery],