Skip to content

Commit

Permalink
[ML] Enabling lat_long detector function in advanced wizard (elastic#…
Browse files Browse the repository at this point in the history
…50787)

* [ML] Enabling lat_long agg in advanced wizard

* fixing tests
  • Loading branch information
jgowdyelastic committed Nov 18, 2019
1 parent a5b3efa commit 3407f4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,7 @@
"max": "max",
"min": "min"
},
"fieldIds": [
"responsetime"
]
"fieldIds": []
}
],
"fields": [
Expand Down Expand Up @@ -513,8 +511,7 @@
"low_non_null_sum",
"info_content",
"high_info_content",
"low_info_content",
"lat_long"
"low_info_content"
]
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -135,24 +137,24 @@ 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);

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
Expand Down Expand Up @@ -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
);
}

0 comments on commit 3407f4f

Please sign in to comment.