# How to change the field type ,and there are some question

**URL:** <https://discuss.elastic.co/t/how-to-change-the-field-type-and-there-are-some-question/109677>\
**Category:** Elasticsearch\
**Created:** [November 30, 2017, 3:02am UTC](https://discuss.elastic.co/t/how-to-change-the-field-type-and-there-are-some-question/109677 "2017-11-30T03:02:07Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![24a1128c2f2635cf61df](https://avatars.discourse-cdn.com/v4/letter/2/f19dbf/32.png) [@24a1128c2f2635cf61df](https://discuss.elastic.co/u/24a1128c2f2635cf61df)\
**Post date:** [November 30, 2017, 3:02am UTC](https://discuss.elastic.co/t/how-to-change-the-field-type-and-there-are-some-question/109677/1 "2017-11-30T03:02:07Z")

</div>

i have two fields ,and i want to show them on the Coordinate Map. i remeber someone said that we can't change the field type ,unless changing the index .  
those are my two fields ,  
"lonlat1" =\> {  
"lat" =\> "20",  
"lon" =\> "30"  
},  
"lonlat2" =\> [  
[0] "100",  
[1] "10"  
],  
my index is "pretest\*"  
yesterday ,they just are struct or array. today,for changing their type to geo\_point, i config a template ,and template's name is "pretest\*"  
"lonlat1": {  
"type": "geo\_point"  
},  
"lonlat2": {  
"type": "geo\_point"  
},  
and i haven't change the index name ,

and then i found the lonlat1's type has changed to geo\_point, but the lonlat2 is conflict ,and i check the past data ，the lonlat1‘s type is geo\_point, and lonlat2 is conflict.  
why? why the lonlat1 could change ,but lonlat2 couldn't?  
and some one said that if i want to change my field ,i should change change my index ,but i haven't change my index ,the lonlat1'type has been changed to geo\_point successfully. who to explain it ?  
sorry my english is not good , but the question has puzzled me long time ，thank you！！

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 30, 2017, 3:36am UTC](https://discuss.elastic.co/t/how-to-change-the-field-type-and-there-are-some-question/109677/2 "2017-11-30T03:36:27Z")

</div>

> [@24a1128c2f2635cf61df](#):
>
> but the lonlat2 is conflict

Where are you seeing this conflict?

---

<div class="post-metadata">

**Author:** ![24a1128c2f2635cf61df](https://avatars.discourse-cdn.com/v4/letter/2/f19dbf/32.png) [@24a1128c2f2635cf61df](https://discuss.elastic.co/u/24a1128c2f2635cf61df)\
**Post date:** [November 30, 2017, 3:43am UTC](https://discuss.elastic.co/t/how-to-change-the-field-type-and-there-are-some-question/109677/4 "2017-11-30T03:43:21Z")

</div>

kibana，the managemnet-\>index patterns

 ![WX20171130-114113@2x](https://us1.discourse-cdn.com/elastic/original/3X/6/a/6a8a070e21431070cf0d0cf778fff280eac1fc4c.png)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 30, 2017, 3:43am UTC](https://discuss.elastic.co/t/how-to-change-the-field-type-and-there-are-some-question/109677/5 "2017-11-30T03:43:49Z")

</div>

You will need to reindex that data or delete it to remove that warning. Otherwise just ignore it, it will still work.

---

<div class="post-metadata">

**Author:** ![24a1128c2f2635cf61df](https://avatars.discourse-cdn.com/v4/letter/2/f19dbf/32.png) [@24a1128c2f2635cf61df](https://discuss.elastic.co/u/24a1128c2f2635cf61df)\
**Post date:** [November 30, 2017, 3:49am UTC](https://discuss.elastic.co/t/how-to-change-the-field-type-and-there-are-some-question/109677/7 "2017-11-30T03:49:16Z")

</div>

thank you！but why the lonlat1's type was be changed to the GEO\_POINT ,but the lonlat2 couldn't?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 30, 2017, 7:57pm UTC](https://discuss.elastic.co/t/how-to-change-the-field-type-and-there-are-some-question/109677/8 "2017-11-30T19:57:46Z")

</div>

You would have to show your template and mapping to be able to comment on that.

---

<div class="post-metadata">

**Author:** ![24a1128c2f2635cf61df](https://avatars.discourse-cdn.com/v4/letter/2/f19dbf/32.png) [@24a1128c2f2635cf61df](https://discuss.elastic.co/u/24a1128c2f2635cf61df)\
**Post date:** [December 1, 2017, 1:37am UTC](https://discuss.elastic.co/t/how-to-change-the-field-type-and-there-are-some-question/109677/9 "2017-12-01T01:37:23Z")

</div>

ok！thanks for your reply，and this is my template：  
{  
"template": "pretest\*",  
"settings": {  
"number\_of\_shards": "1",  
"number\_of\_replicas": "0"  
},  
"mappings": {  
"_default_": {  
"dynamic\_templates": [  
{  
"string\_fields": {  
"mapping": {  
"index": "not\_analyzed",  
"omit\_norms": true,  
"type": "string"  
},  
"match\_mapping\_type": "string",  
"match": "\*"  
}  
}  
],  
"\_all": {  
"enabled": true  
},  
"properties": {  
"@timestamp": {  
"type": "date",  
"include\_in\_all": false  
},  
"@version": {  
"type": "keyword",  
"include\_in\_all": false  
},  
"lonlat1": {  
"type": "geo\_point"  
},  
"lonlat2": {  
"type": "geo\_point"  
}  
}  
}  
}  
}  
and the lonlat1's type is struct and lonlat2's type is array:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/2/c283977ae457b461a78f3330fe340e5375364055.png)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [December 1, 2017, 3:23am UTC](https://discuss.elastic.co/t/how-to-change-the-field-type-and-there-are-some-question/109677/10 "2017-12-01T03:23:37Z")

</div>

Please don't post pictures of text, they are difficult to read and some people may not be even able to see them.

Also you need to show the actual mapping please, not just a picture of the data.

---

<div class="post-metadata">

**Author:** ![24a1128c2f2635cf61df](https://avatars.discourse-cdn.com/v4/letter/2/f19dbf/32.png) [@24a1128c2f2635cf61df](https://discuss.elastic.co/u/24a1128c2f2635cf61df)\
**Post date:** [December 1, 2017, 5:00am UTC](https://discuss.elastic.co/t/how-to-change-the-field-type-and-there-are-some-question/109677/11 "2017-12-01T05:00:21Z")

</div>

ok!  
**the template:**  
{  
"template": "pretest\*",  
"settings": {  
"number\_of\_shards": "1",  
"number\_of\_replicas": "0"  
},  
"mappings": {  
"default": {  
"dynamic\_templates": [  
{  
"string\_fields": {  
"mapping": {  
"index": "not\_analyzed",  
"omit\_norms": true,  
"type": "string"  
},  
"match\_mapping\_type": "string",  
"match": "\*"  
}  
}  
],  
"\_all": {  
"enabled": true  
},  
"properties": {  
"@timestamp": {  
"type": "date",  
"include\_in\_all": false  
},  
"@version": {  
"type": "keyword",  
"include\_in\_all": false  
},  
"lonlat1": {  
"type": "geo\_point"  
},  
"lonlat2": {  
"type": "geo\_point"  
}  
}  
}  
}  
}

**and my logstash.conf:**

input {  
kafka{  
bootstrap\_servers =\> "127.0.0.1:19092,127.0.0.1:19093"  
topics =\> ["summer"]  
codec =\> "json"  
ssl =\> true  
}  
}

filter {  
if[type] == "latandlon\_data"{  
grok{  
match =\> {"message" =\> "%{DATA:lat},%{DATA:long}"}  
add\_field =\> ["[lonlat1][lat]", "%{[lat]}" ]  
add\_field =\> ["[lonlat1][lon]", "%{[long]}" ]  
add\_field =\> ["[lonlat2]", "%{[long]}"]  
add\_field =\> ["[lonlat2]", "%{[lat]}"]  
}  
}

}

output {  
if[type] =="latandlon\_data" {  
elasticsearch {  
hosts =\> "127.0.0.1:9200"  
manage\_template =\> true  
template\_overwrite =\> true  
template =\>"/usr/local/elk/logstash-5.6.2/templates/mytemplate2.json"  
template\_name =\> "pretest"  
index =\> "pretest-common-latandlon\_log-%{+YYYY.MM.dd}"  
document\_type =\> "%{[@metadata][type]}"  
}  
}  
}

**thanks!!**

---

<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 29, 2017, 5:00am UTC](https://discuss.elastic.co/t/how-to-change-the-field-type-and-there-are-some-question/109677/12 "2017-12-29T05:00:28Z")

</div>

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