[ML] Enabling lat_long detector function in advanced wizard (#50787) (#52180)

* [ML] Enabling lat_long agg in advanced wizard

* fixing tests
This commit is contained in:
James Gowdy 2019-12-04 15:43:13 +00:00 committed by GitHub
parent 76662c1669
commit f24be43b68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 11 deletions

View file

@ -460,9 +460,7 @@
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
"fieldIds": []
}
],
"fields": [
@ -513,8 +511,7 @@
"low_non_null_sum",
"info_content",
"high_info_content",
"low_info_content",
"lat_long"
"low_info_content"
]
}
]

View file

@ -31,6 +31,8 @@ const supportedTypes: string[] = [
ES_FIELD_TYPES.SCALED_FLOAT,
ES_FIELD_TYPES.SHORT,
ES_FIELD_TYPES.IP,
ES_FIELD_TYPES.GEO_POINT,
ES_FIELD_TYPES.GEO_SHAPE,
];
export function fieldServiceProvider(
@ -135,6 +137,7 @@ async function combineFieldsAndAggs(
const keywordFields = getKeywordFields(fields);
const numericalFields = getNumericalFields(fields);
const ipFields = getIpFields(fields);
const geoFields = getGeoFields(fields);
const isRollup = Object.keys(rollupFields).length > 0;
const mix = mixFactory(isRollup, rollupFields);
@ -142,17 +145,16 @@ async function combineFieldsAndAggs(
aggs.forEach(a => {
if (a.type === METRIC_AGG_TYPE && a.fields !== undefined) {
switch (a.id) {
case ML_JOB_AGGREGATION.LAT_LONG:
geoFields.forEach(f => mix(f, a));
break;
case ML_JOB_AGGREGATION.DISTINCT_COUNT:
case ML_JOB_AGGREGATION.HIGH_DISTINCT_COUNT:
case ML_JOB_AGGREGATION.LOW_DISTINCT_COUNT:
// distinct count (i.e. cardinality) takes keywords, ips
// as well as numerical fields
keywordFields.forEach(f => {
mix(f, a);
});
ipFields.forEach(f => {
mix(f, a);
});
keywordFields.forEach(f => mix(f, a));
ipFields.forEach(f => mix(f, a));
// note, no break to fall through to add numerical fields.
default:
// all other aggs take numerical fields
@ -235,3 +237,9 @@ function getNumericalFields(fields: Field[]): Field[] {
f.type === ES_FIELD_TYPES.SCALED_FLOAT
);
}
function getGeoFields(fields: Field[]): Field[] {
return fields.filter(
f => f.type === ES_FIELD_TYPES.GEO_POINT || f.type === ES_FIELD_TYPES.GEO_SHAPE
);
}