Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
);
}