# Trying to change a fields name

**URL:** <https://discuss.elastic.co/t/trying-to-change-a-fields-name/177773>\
**Category:** Elasticsearch\
**Created:** [April 21, 2019, 6:57pm UTC](https://discuss.elastic.co/t/trying-to-change-a-fields-name/177773 "2019-04-21T18:57:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![iukea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iukea/32/49083_2.png) [@iukea](https://discuss.elastic.co/u/iukea)\
**Post date:** [April 21, 2019, 6:57pm UTC](https://discuss.elastic.co/t/trying-to-change-a-fields-name/177773/1 "2019-04-21T18:57:43Z")

</div>

Hello I currently have in my elasticsearch index

"type": "NGINX",

how can I change it from

"type": "NGINX",  
to  
"type": "x",

in the current index.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 21, 2019, 7:22pm UTC](https://discuss.elastic.co/t/trying-to-change-a-fields-name/177773/2 "2019-04-21T19:22:03Z")

</div>

Types are going to be removed entirely anyway. So that should not really be a concern. Why do you want to change that?

If you want to do it, you need to reindex.

---

<div class="post-metadata">

**Author:** ![iukea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iukea/32/49083_2.png) [@iukea](https://discuss.elastic.co/u/iukea)\
**Post date:** [April 21, 2019, 7:34pm UTC](https://discuss.elastic.co/t/trying-to-change-a-fields-name/177773/3 "2019-04-21T19:34:50Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/6/8/682fe26d0dbc7bd06fbbf524055ece026dce4d48.png)

I am up for any suggestions. If you can please point me in the correct direction that would be much appreciated.

Also what do you mean "Types are going to be removed entirely"  
@dadoonet

---

<div class="post-metadata">

**Author:** ![iukea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iukea/32/49083_2.png) [@iukea](https://discuss.elastic.co/u/iukea)\
**Post date:** [April 21, 2019, 7:36pm UTC](https://discuss.elastic.co/t/trying-to-change-a-fields-name/177773/4 "2019-04-21T19:36:46Z")

</div>

attached is a picture the field "Type" which i want to change it from NGINX to X

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 22, 2019, 2:36am UTC](https://discuss.elastic.co/t/trying-to-change-a-fields-name/177773/5 "2019-04-22T02:36:45Z")

</div>

I meant [https://www.elastic.co/blog/removal-of-mapping-types-elasticsearch](https://www.elastic.co/blog/removal-of-mapping-types-elasticsearch)

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [April 22, 2019, 3:22am UTC](https://discuss.elastic.co/t/trying-to-change-a-fields-name/177773/6 "2019-04-22T03:22:38Z")

</div>

Hi,

What about update by query :

[https://www.elastic.co/guide/en/elasticsearch/reference/7.0/docs-update-by-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.0/docs-update-by-query.html)

something like:

```
POST my_index/_update_by_query
{
  "script": {
    "source": "ctx._source.type='X'",
    "lang": "painless"
  },
  "query": {
    "term": {
      "type": "NGINX"
    }
  }
} 

```

Also it's better to not call your field type as it can confuse with \_type meta field and depends on the language you use it can be a reserved word like in python.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 22, 2019, 6:10am UTC](https://discuss.elastic.co/t/trying-to-change-a-fields-name/177773/7 "2019-04-22T06:10:21Z")

</div>

lol. I have been confused by that name apparently 😂

---

<div class="post-metadata">

**Author:** ![iukea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iukea/32/49083_2.png) [@iukea](https://discuss.elastic.co/u/iukea)\
**Post date:** [April 22, 2019, 3:20pm UTC](https://discuss.elastic.co/t/trying-to-change-a-fields-name/177773/8 "2019-04-22T15:20:24Z")

</div>

@dadoonet @gabriel_tessier

Thank you for the quick reply!

I tried running that (changed the "my\_index/" to one of my indexes".

Got the following output.

```
 {
  "took" : 4,
  "timed_out" : false,
  "total" : 0,
  "updated" : 0,
  "deleted" : 0,
  "batches" : 0,
  "version_conflicts" : 0,
  "noops" : 0,
  "retries" : {
    "bulk" : 0,
    "search" : 0
  },
  "throttled_millis" : 0,
  "requests_per_second" : -1.0,
  "throttled_until_millis" : 0,
  "failures" : []
}

```

Any suggestions? I feel like I am missing something dumb here.

---

<div class="post-metadata">

**Author:** ![iukea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iukea/32/49083_2.png) [@iukea](https://discuss.elastic.co/u/iukea)\
**Post date:** [April 22, 2019, 3:24pm UTC](https://discuss.elastic.co/t/trying-to-change-a-fields-name/177773/9 "2019-04-22T15:24:13Z")

</div>

Fixed it!!!!!

```
POST logstash-*/_update_by_query
{
  "script": {
    "source": "ctx._source.type='x'",
    "lang": "painless"
  },
  "query": {
    "term": {
      "type.keyword": "NGINX"
    }
  }
} 

```

output  
{  
"took" : 4465,  
"timed\_out" : false,  
"total" : 27808,  
"updated" : 27808,  
"deleted" : 0,  
"batches" : 28,  
"version\_conflicts" : 0,  
"noops" : 0,  
"retries" : {  
"bulk" : 0,  
"search" : 0  
},  
"throttled\_millis" : 0,  
"requests\_per\_second" : -1.0,  
"throttled\_until\_millis" : 0,  
"failures" :   
}

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [April 23, 2019, 2:17am UTC](https://discuss.elastic.co/t/trying-to-change-a-fields-name/177773/10 "2019-04-23T02:17:45Z")

</div>

Hi,

According to the name of your index, if what you do is not a one time update maybe it's better to make the change directly in logstash to transform your data before indexing them or check about ingest for this.

[https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html)

You can set a default pipeline on the template so each time a new index "logstash-\*" is created it will assign the pipeline.

I don't find the documentation 😓

And in your pipeline definition you'll replace the "type" value if it's NGINX by X.

[https://www.elastic.co/guide/en/elasticsearch/reference/current/conditionals-with-multiple-pipelines.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/conditionals-with-multiple-pipelines.html)

---

<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:** [May 21, 2019, 2:17am UTC](https://discuss.elastic.co/t/trying-to-change-a-fields-name/177773/11 "2019-05-21T02:17:53Z")

</div>

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