# New template doesn't works Geoip

**URL:** https://discuss.elastic.co/t/new-template-doesnt-works-geoip/266801
**Category:** Logstash
**Created:** [March 10, 2021, 11:40am UTC](https://discuss.elastic.co/t/new-template-doesnt-works-geoip/266801 "2021-03-10T11:40:36Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![hoff](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hoff/32/30963_2.png) [@hoff](https://discuss.elastic.co/u/hoff)
#### Post date: [March 10, 2021, 11:40am UTC](https://discuss.elastic.co/t/new-template-doesnt-works-geoip/266801/1 "2021-03-10T11:40:37Z")

</div>

Hi,  
I need to create geoip map but in my mapping field location is float type. I have some issue with create new template. I want to change field type from float to geo\_point. When I try to put new template and delete oldest index. My fields is still in the same type.

part to be replaced :

```auto
        "geoip": {
                      "properties": {
                        "city_name": {
                          "type": "text",
                          "fields": {
                            "keyword": {
                              "type": "keyword",
                              "ignore_above": 256
                            }
                          }
                        },
                        "continent_code": {
                          "type": "text",
                          "fields": {
                            "keyword": {
                              "type": "keyword",
                              "ignore_above": 256
                            }
                          }
                        },
                        "coordinates": {
                          "type": "float"
                        },
                        "country_code2": {
                          "type": "text",
                          "fields": {
                            "keyword": {
                              "type": "keyword",
                              "ignore_above": 256
                            }
                          }
                        },
                        "country_code3": {
                          "type": "text",
                          "fields": {
                            "keyword": {
                              "type": "keyword",
                              "ignore_above": 256
                            }
                          }
                        },
                        "country_name": {
                          "type": "text",
                          "fields": {
                            "keyword": {
                              "type": "keyword",
                              "ignore_above": 256
                            }
                          }
                        },
                        "dma_code": {
                          "type": "long"
                        },
                        "ip": {
                          "type": "text",
                          "fields": {
                            "keyword": {
                              "type": "keyword",
                              "ignore_above": 256
                            }
                          }
                        },
                        "latitude": {
                          "type": "float"
                        },
                        "location": {
                          "properties": {
                            "lat": {
                              "type": "float"
                            },
                            "lon": {
                              "type": "float"
                            }
                          }
                        },
                        "longitude": {
                          "type": "float"
                        },
                        "postal_code": {
                          "type": "text",
                          "fields": {
                            "keyword": {
                              "type": "keyword",
                              "ignore_above": 256
                            }
                          }
                        },
                        "region_code": {
                          "type": "text",
                          "fields": {
                            "keyword": {
                              "type": "keyword",
                              "ignore_above": 256
                            }
                          }
                        },
                        "region_name": {
                          "type": "text",
                          "fields": {
                            "keyword": {
                              "type": "keyword",
                              "ignore_above": 256
                            }
                          }
                        }`

```

```
this is how I want it to be after the change :

```

```auto
    "geoip": {
              "properties": {
                "city_name": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },
                "continent_code": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },
                "coordinates": {
                  "type": "float"
                },
                "country_code2": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },
                "country_code3": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },
                "country_name": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },
                "dma_code": {
                  "type": "long"
                },
                "ip": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "latitude": {
                    "type": "float"
                  },
                  "location": {
                    "type": "geo_point"
                  },
                  "longitude": {
                    "type": "float"
                  },
                "postal_code": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },

```

My logstash output :

```auto
     elasticsearch {
            hosts => "127.0.0.1:9200"
            manage_template => false
            index => "%{name}-%{+YYYY.MM.dd}"
            }

```

My template :

**PUT \_template/foobar**

```auto
 {
      "index_patterns": ["namefoobar-*"],
      "template": {
        "settings": {
          "number_of_shards": 1
        },
        "mappings": {
        "doc": {
          "properties": {
            "@timestamp": {
              "type": "date"
            },
            "@version": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "geoip": {
              "properties": {
                "city_name": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },
                "continent_code": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },
                "coordinates": {
                  "type": "float"
                },
                "country_code2": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },
                "country_code3": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },
                "country_name": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },
                "dma_code": {
                  "type": "long"
                },
                "ip": {
                    "type": "text",
                    "fields": {
                      "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                      }
                    }
                  },
                  "latitude": {
                    "type": "float"
                  },
                  "location": {
                    "type": "geo_point"
                  },
                  "longitude": {
                    "type": "float"
                  },
                "postal_code": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },
                "region_code": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },
                "region_name": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },
                "timezone": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                }
              }
            },
            "name": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "tags": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            }
          }
        }
      },
            "created_at": {
              "type": "date",
              "format": "EEE MMM dd HH:mm:ss Z yyyy"
           }
         }
    	}

```

Have I forgotten anything?

---

<div class="post-metadata">

### Author: ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)
#### Post date: [March 10, 2021, 12:40pm UTC](https://discuss.elastic.co/t/new-template-doesnt-works-geoip/266801/2 "2021-03-10T12:40:29Z")

</div>

Did you recreate the index after updating the template?

---

<div class="post-metadata">

### Author: ![hoff](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hoff/32/30963_2.png) [@hoff](https://discuss.elastic.co/u/hoff)
#### Post date: [March 10, 2021, 1:14pm UTC](https://discuss.elastic.co/t/new-template-doesnt-works-geoip/266801/3 "2021-03-10T13:14:40Z")

</div>

Yes, after recreating index I have still the same mapping.

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [March 10, 2021, 3:54pm UTC](https://discuss.elastic.co/t/new-template-doesnt-works-geoip/266801/4 "2021-03-10T15:54:45Z")

</div>

So you are saying that you updated a template in elasticsearch but when an index was created it was not applied? That would suggest that the index\_patterns value does not match the index name.

---

<div class="post-metadata">

### Author: ![hoff](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hoff/32/30963_2.png) [@hoff](https://discuss.elastic.co/u/hoff)
#### Post date: [March 11, 2021, 7:10am UTC](https://discuss.elastic.co/t/new-template-doesnt-works-geoip/266801/5 "2021-03-11T07:10:52Z")

</div>

> [@Badger](#):
>
> So you are saying that you updated a template in elasticsearch but when an index was created it was not applied? That would suggest that the index\_patterns value does not match the index name.

I have a few sources I'm sending data to logstash. Logstash creates an index based on the field "name". For example namefoobar-\* , namefoobar1-\* , namefoobar2-\* . I need to update template for one of them.

---

<div class="post-metadata">

### Author: ![hoff](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hoff/32/30963_2.png) [@hoff](https://discuss.elastic.co/u/hoff)
#### Post date: [March 11, 2021, 9:25am UTC](https://discuss.elastic.co/t/new-template-doesnt-works-geoip/266801/6 "2021-03-11T09:25:04Z")

</div>

It's works I guess. A field with a type geo\_point is available. Now I have info about Mapping conflict.

 ![mapping conflict](https://us1.discourse-cdn.com/elastic/original/3X/f/a/faa8cc891f4e394d4a28e2f883fbf2c2e0dee0b1.jpeg)  
 ![coordy](https://us1.discourse-cdn.com/elastic/original/3X/c/c/cc3c6d0b0a3b3f882da77d0da873f7c01ee721fc.jpeg)

that's the section of the mapping :

```auto
"geoip": {
          "properties": {
            "city_name": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "continent_code": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "coordinates": {
              "type": "geo_point"
            },
            "country_code2": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "country_code3": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "country_name": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "dma_code": {
              "type": "long"
            },
            "ip": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "latitude": {
              "type": "float"
            },
            "location": {
              "properties": {
                "lat": {
                  "type": "float"
                },
                "lon": {
                  "type": "float"
                }
              }
            },
            "longitude": {
              "type": "float"
            },
            "postal_code": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "region_code": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "region_name": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            },
            "timezone": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 256
                }
              }
            }
          }
        },

```

Problem solved after reindexing. Thank you for all the advice.

---

<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: [April 8, 2021, 9:25am UTC](https://discuss.elastic.co/t/new-template-doesnt-works-geoip/266801/7 "2021-04-08T09:25:11Z")

</div>

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