# Reindexing Tweets changing a field type in Elasticsearch using Logstash

**URL:** <https://discuss.elastic.co/t/reindexing-tweets-changing-a-field-type-in-elasticsearch-using-logstash/65991>\
**Category:** Logstash\
**Created:** [November 14, 2016, 2:10pm UTC](https://discuss.elastic.co/t/reindexing-tweets-changing-a-field-type-in-elasticsearch-using-logstash/65991 "2016-11-14T14:10:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luzcka](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@Luzcka](https://discuss.elastic.co/u/Luzcka)\
**Post date:** [November 14, 2016, 2:10pm UTC](https://discuss.elastic.co/t/reindexing-tweets-changing-a-field-type-in-elasticsearch-using-logstash/65991/1 "2016-11-14T14:10:14Z")

</div>

Hi guys,

I know twitter / tweets are a type of subject with many doubts and answers, but I don't find the solution. Well, the problem is the same than others guys find: coordinates isn't a geo\_poin type.

I want to use the tweets that are already in elasticsearch, so I believe that I can reindex using logstash applying a "mutate", is it correct? I try the following conf file:

```
input {
   elasticsearch {
       hosts => ["localhost:9200"]
       index => "twitter_fln"
       size => 1000
       scroll => "5m"
       docinfo => true
       scan => true
   }
}

filter {
    mutate {
        update => {"coordinates.type" => "geo_point"}
    }
}

output {
    elasticsearch {
        hosts => ["localhost:9200"]
        index => "twitter_re"
        document_type => "twitter"
    }
    stdout {
        codec => "dots"
    } 
}

```

The index is created and the documents are saved, but the field "coordinates.type" persist as "double" and not as "geo\_point", I believe that the name that I'm using is wrong, possibly the structure (coordinates.type). How I change this field type using logstash?

Logstash version: 2.4.0  
Elasticsearch version: 2.4.1

Sorry my English.  
Any help is welcome!

Regards!

---

<div class="post-metadata">

**Author:** ![jsvd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsvd/32/6203_2.png) [@jsvd](https://discuss.elastic.co/u/jsvd)\
**Post date:** [November 14, 2016, 3:42pm UTC](https://discuss.elastic.co/t/reindexing-tweets-changing-a-field-type-in-elasticsearch-using-logstash/65991/2 "2016-11-14T15:42:18Z")

</div>

you have to state in the elasticsearch mapping that the field `coordinates.type` will be of type geo\_point.

so either you can install a custom elasticsearch template and turn off logstash's template management `manage_template => false`, or tell logstash to install your custom template that describes that field as a geo\_point. The option is `template => "/file/path"`

See more in [https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-template](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-template)

and logstash default templates:

for es 2.x: [https://github.com/logstash-plugins/logstash-output-elasticsearch/blob/v5.3.3/lib/logstash/outputs/elasticsearch/elasticsearch-template-es2x.json](https://github.com/logstash-plugins/logstash-output-elasticsearch/blob/v5.3.3/lib/logstash/outputs/elasticsearch/elasticsearch-template-es2x.json)  
for es 5.x: [https://github.com/logstash-plugins/logstash-output-elasticsearch/blob/v5.3.3/lib/logstash/outputs/elasticsearch/elasticsearch-template-es5x.json](https://github.com/logstash-plugins/logstash-output-elasticsearch/blob/v5.3.3/lib/logstash/outputs/elasticsearch/elasticsearch-template-es5x.json)

---

<div class="post-metadata">

**Author:** ![Luzcka](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@Luzcka](https://discuss.elastic.co/u/Luzcka)\
**Post date:** [November 14, 2016, 4:09pm UTC](https://discuss.elastic.co/t/reindexing-tweets-changing-a-field-type-in-elasticsearch-using-logstash/65991/3 "2016-11-14T16:09:10Z")

</div>

Hi João,

Thank you for the answer, but I have a dude... Is really necessary to change the mapping / template for a re-indexing using Logstash with "mutate" ? Obviously the field "coordinates.type" from the "input" is a Float, but using "mutate" the "output" is typed to geo\_point... or is it incorrect? Only to understand the correct behavior of Logstash.

I know that I need to create a new "twitter.json" mapping with "coordinates.type" as a geo\_type, and use a template to use it in a new "import" / "extraction" from Twitter, but I was understand that it is no necessary to a re-indexing...

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 18, 2016, 6:38am UTC](https://discuss.elastic.co/t/reindexing-tweets-changing-a-field-type-in-elasticsearch-using-logstash/65991/4 "2016-11-18T06:38:41Z")

</div>

> Obviously the field "coordinates.type" from the "input" is a Float, but using "mutate" the "output" is typed to geo\_point... or is it incorrect?

The mutate filter's `update` option changes an existing _value_ of a field. It doesn't change its type (that's what the `convert` option does). Secondly, you should think of an event inside Logstash as a JSON object. Values in JSON objects are strings, bools, numbers, arrays, or objects. There is no geo point type in JSON. Consequently, it's impossible to change a field's type to geo point using any kind of filter. Mapping a field as a geo point is all done by Elasticsearch.

---

<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:** [December 16, 2016, 6:38am UTC](https://discuss.elastic.co/t/reindexing-tweets-changing-a-field-type-in-elasticsearch-using-logstash/65991/5 "2016-12-16T06:38:57Z")

</div>

Closed on December 16, 2016, 6:38am UTC

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