# What's the best way to define both geo shape and geo point dynamic mapping

**URL:** <https://discuss.elastic.co/t/whats-the-best-way-to-define-both-geo-shape-and-geo-point-dynamic-mapping/143210>\
**Category:** Elasticsearch\
**Created:** [August 6, 2018, 7:19pm UTC](https://discuss.elastic.co/t/whats-the-best-way-to-define-both-geo-shape-and-geo-point-dynamic-mapping/143210 "2018-08-06T19:19:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikesparr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikesparr/32/4619_2.png) [@mikesparr](https://discuss.elastic.co/u/mikesparr)\
**Post date:** [August 6, 2018, 7:19pm UTC](https://discuss.elastic.co/t/whats-the-best-way-to-define-both-geo-shape-and-geo-point-dynamic-mapping/143210/1 "2018-08-06T19:19:05Z")

</div>

Using dynamic templates, I have a "locations" mapping for "location" field with mapping type "geo\_point". Some visualizations need this field to be a "geo\_shape", however. I would like to extend the mapping similar to how we'd add "fields": { "raw" ... } to support both but unsure how best to define a single mapping that can include both "geo\_shape" and "geo\_point".

Guess is something like:

```
"dynamic_templates": [
  {
     "locations": {
       "match": "location",
       "mapping": {
           ???
       }
     }
  }
]

```

I'm not sure if you can just set mapping type to "geo\_point" and have fields with both types or better to define two completely separate mappings and matches with different field naming.

I want both `point` and `shape`:

`"type": "geo_point"`

and

```
"type": "geo_shape",
"tree": "quadtree",
"precision": "50m"

```

Would something like this work or better yet, is there a way to use `copy_to` to copy the lat/lon to both on single insert?

```
  "dynamic_templates": [
    {
      "locations": {
        "match": "location",
        "mapping": {
          "type": "geo_shape",
          "tree": "quadtree",
          "precision": "50m",
          "fields": {
            "point": {
              "type": "geo_point"
            }
          }
        }
      }
    }
  ]

```

Appreciate tips on best practice here.

After some trial/error I learned the following so wonder if conclusion is you have to add different fields and types and populate them all redundantly on insert.

1. `copy_to` will not copy to a multi-field type (geo\_point)
2. `mapping` will not allow nested fields

So far I got this to work (all separate fields) but there has to be a more elegant way to store these without the redundant entry. [https://github.com/mikesparr/elasticsearch-geo-template](https://github.com/mikesparr/elasticsearch-geo-template)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 3, 2018, 7:19pm UTC](https://discuss.elastic.co/t/whats-the-best-way-to-define-both-geo-shape-and-geo-point-dynamic-mapping/143210/2 "2018-09-03T19:19:07Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
