-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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] Add new geo_results.(actual_point|typical_point) fields for lat_long
results
#47050
[ML] Add new geo_results.(actual_point|typical_point) fields for lat_long
results
#47050
Conversation
Pinging @elastic/ml-core |
@elasticmachine update branch |
…o-mapping-for-anomaly-records
@alexfrancoeur Thought you would enjoy this. This PR adds geo_point mappings for anomaly detection jobs. Just needed to add a index pattern to include the |
@benwtrent your assumption was correct, I absolutely love this 😄❤️ ❤️ This type of functionality is the perfect way to bring in a streamlined approach for creating ML jobs from within the maps application. Ideally, our end users won't have to know anything about the Now I'm curious, would be it possible to support cc: @elastic/kibana-gis |
@alexfrancoeur the As for more detectors in the future that look at other geo data (shapes, lines, etc.) that is definitely within the realm of possibility, just not in the near future :) |
Thanks for the quick response! Agreed that points are more heavily used today. If we choose to introduce a streamlined UX for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ease of getting ML lat_long anomalies onto maps is great.
My main comment is about whether the fields should be generated in the C++ code. I think we should ask for more opinions about this.
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
private void writeDoublesAsGeoPoint(XContentBuilder builder, String fieldName, List<Double> doubles) throws IOException { | ||
if (doubles != null) { | ||
//TODO should we fail if `doubles` is not an array of length 2? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think an internal assertion as you've got it now is best. Throwing an exception here would mean it was impossible to get anything from the results endpoint.
However, see my main comment because that would render this a moot point as the whole method could be deleted.
.../plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsPersister.java
Outdated
Show resolved
Hide resolved
…o-mapping-for-anomaly-records
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the caveat that you should check with the ES core infra team about changing the method visibility in XContentBuilder
. (If they don't like it there's an easy change that can be made to this PR to avoid it.)
@@ -850,7 +850,7 @@ private XContentBuilder value(ToXContent value) throws IOException { | |||
return value(value, ToXContent.EMPTY_PARAMS); | |||
} | |||
|
|||
private XContentBuilder value(ToXContent value, ToXContent.Params params) throws IOException { | |||
public XContentBuilder value(ToXContent value, ToXContent.Params params) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really see why making this public would be a problem given what it does and the other public methods nearby. However, you should probably run this by somebody in the ES core infra team before merging.
There is a simple way to avoid making this public - see my next comment.
builder.field(CAUSES.getPreferredName(), causes); | ||
builder.startArray(CAUSES.getPreferredName()); | ||
for (AnomalyCause cause : causes) { | ||
builder.value(cause, params); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line could be changed to cause.toXContent(builder, params);
to avoid the need to change method visibility in the X-Content builder.
…o-mapping-for-anomaly-records
run elasticsearch-ci/2 |
lat_long
results
…_long` results (elastic#47050) [ML] Add new geo_results.(actual_point|typical_point) fields for `lat_long` results (elastic#47050) Related PR: elastic/ml-cpp#809
Adds new geo_point formatted fields for Java side consumption. These are only written if we have actual|typical values that have length of 2, and are using a lat_long function. This is my first PR against this repo, let me know if I missed something. related elastic/elasticsearch#47050
…r `lat_long` results (#47050) (#48958) * [ML] Add new geo_results.(actual_point|typical_point) fields for `lat_long` results (#47050) [ML] Add new geo_results.(actual_point|typical_point) fields for `lat_long` results (#47050) Related PR: elastic/ml-cpp#809 * adjusting bwc version
Adds new geo_point formatted fields for Java side consumption. These are only written if we have actual|typical values that have length of 2, and are using a lat_long function. This is my first PR against this repo, let me know if I missed something. related elastic/elasticsearch#47050
wooo! Nice one @benwtrent |
…_long` results (elastic#47050) [ML] Add new geo_results.(actual_point|typical_point) fields for `lat_long` results (elastic#47050) Related PR: elastic/ml-cpp#809
This PR adds a new
geo_results.*
field for actual/typical fields in the anomaly record storage, and the anomaly cause storage.I did not opt for these two items to be returned within the HLRC client and to have the HLRC have a helper method that transforms the two points to a GeoPoint if the function is
lat_long
.The purpose behind this change is so that
lan_long
anomaly records can be trivially visible within Kibana Maps. Additionally, helpful queries and inspections can be made against the records as well with the plethora of geo capabilities within the stack.