# Mapping based on template not working

**URL:** <https://discuss.elastic.co/t/mapping-based-on-template-not-working/138702>\
**Category:** Logstash\
**Created:** [July 5, 2018, 11:12am UTC](https://discuss.elastic.co/t/mapping-based-on-template-not-working/138702 "2018-07-05T11:12:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkaramol](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pkaramol/32/22610_2.png) [@pkaramol](https://discuss.elastic.co/u/pkaramol)\
**Post date:** [July 5, 2018, 11:12am UTC](https://discuss.elastic.co/t/mapping-based-on-template-not-working/138702/1 "2018-07-05T11:12:18Z")

</div>

I am importing some data to `elasticsearch` after passing it through some `lostash` pipelinening.

I am declaring in the template (snippet below) some fields e.g. as `ip` and some others as `integer`

```auto
        "src": {"type": "ip"},
        "dst": {"type":"ip"},
        "src_port": {"type": "integer", "index":false},
        "dst_port": {"type": "integer"},

```

However, in my `elasticsearch` instance they end up as `string`

![dst](https://us1.discourse-cdn.com/elastic/original/3X/d/f/dfb5c0c7236a7af9cd371b39178d0ff269bc84d5.png) ![src](https://us1.discourse-cdn.com/elastic/original/3X/1/b/1bb294602cc77d9927e3dbec245214678fa87110.png)

What is more, when retrieving the templates from `kibana` the seem to have the appropriate types:

(this from the `kibana` dev tools after executing `GET /_template/*`

```auto
          "src": {
            "type": "ip"
          },
          "dst": {
            "type": "ip"
          },
          "src_port": {
            "type": "integer",
            "index": false
          },
          "dst_port": {
            "type": "integer"
          },

```

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 5, 2018, 11:16am UTC](https://discuss.elastic.co/t/mapping-based-on-template-not-working/138702/2 "2018-07-05T11:16:51Z")

</div>

What does the rest of the template look like? Does it match your index name?

---

<div class="post-metadata">

**Author:** ![pkaramol](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pkaramol/32/22610_2.png) [@pkaramol](https://discuss.elastic.co/u/pkaramol)\
**Post date:** [July 5, 2018, 11:18am UTC](https://discuss.elastic.co/t/mapping-based-on-template-not-working/138702/3 "2018-07-05T11:18:00Z")

</div>

Yes by typing the question I just noticed I had erroneous index matching in the template, i.e. the `index_patterns` field of my template did not match the actual indices I wanted mapped.

thx

---

<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:** [August 2, 2018, 11:18am UTC](https://discuss.elastic.co/t/mapping-based-on-template-not-working/138702/4 "2018-08-02T11:18:05Z")

</div>

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