Skip to content

Add option to override template based on a hash #342

Open
@ycombinator

Description

@ycombinator

Problem

Often I will have a geo point field in my data that I’m indexing into Elasticsearch from Logstash, perhaps something like:

"location": {
    "lat": 51.5034070,
    "lon": -0.1275920
}

In order to give this field the correct mapping, I end up cloning https://github.com/logstash-plugins/logstash-output-elasticsearch/blob/master/lib/logstash/outputs/elasticsearch/elasticsearch-template.json and appending a new location property with the appropriate geo_point mapping to the properties object at the bottom of the template.

Proposal

Consider providing a top-level geo_point field in the template, similar to the geoip.location field, with the appropriate geo_point mapping

Pros

IMHO, this is a better experience for users who may have a geo point field in there data. They no longer need to clone and modify the template just to add the correct mapping for such a field.

Cons

By providing yet-another field in the template properties, we're increasing the chances that a field with the same name already exists in the user's data, but as a non-geo-point field. For example, if we named our field in the template as location and the user already had data like "location": "London, UK" we would be screwing up their expected mapping. We could possibly alleviate this by naming the field something special like '@location', which would also be consistent with the other @-fields in Logstash.

Alternatives

Instead of hardcoding a top-level @location field in the template properties, we could add a dynamic template like so:

{
  "location_geo_point_fields" : {
    "match" : "@location*",
    "match_mapping_type" : "geo_point",
    "mapping" : { "type" : "geo_point", "doc_values" : true }
  }
}

This way the user could specify multiple geo point fields in their data. As long as they started with @location, the correct mapping would be applied.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions