# Changing \_type field using elasticsearch RESTAPI commands

**URL:** <https://discuss.elastic.co/t/changing--type-field-using-elasticsearch-restapi-commands/92623>\
**Category:** Elasticsearch\
**Created:** [July 11, 2017, 10:26am UTC](https://discuss.elastic.co/t/changing--type-field-using-elasticsearch-restapi-commands/92623 "2017-07-11T10:26:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Passerby](https://avatars.discourse-cdn.com/v4/letter/p/a88e57/32.png) [@Passerby](https://discuss.elastic.co/u/Passerby)\
**Post date:** [July 11, 2017, 10:26am UTC](https://discuss.elastic.co/t/changing--type-field-using-elasticsearch-restapi-commands/92623/1 "2017-07-11T10:26:56Z")

</div>

Hi!  
Could anyone give some advice about it?  
So i'm trying to copy doc into another \_type, for right now i want to have a function at python script that changes type by reindexing doc twice ( 1-st one is changing index and \_type, 2-nd is changing index back to original with new \_type & then deletes the new index ) Right now i'm trying to understand how to use python lib or some REST API commands to make it real. That's what i was doing:

```
POST _reindex
{
  "source": {
    "index": "logstash-",
    "type": "new_type",
    "query": {
      "match": {
        "_id": "cws-prd-prox-f-04.mia2.comWARNING"
      }
    }
  },
  "dest": {
    "index": "logstash2-",
    "type": "new_type2"
  }
}

POST _reindex
{
  "source": {
    "index": "logstash2-",
    "type": "new_type2",
    "query": {
      "match": {
        "_id": "cws-prd-prox-f-04.mia2.comWARNING"
      }
    }
  },
  "dest": {
    "index": "logstash-",
    "type": "new_type2"
  }
}

DELETE /logstash2-/new_type2/cws-prd-prox-f-04.mia2.comWARNING

```

So basically i'm searching for some equivalent to reindex - retype or smth like that. Any ideas?  
Hope not to use [elasticsearch-dump](https://github.com/taskrabbit/elasticsearch-dump) .

---

<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 8, 2017, 10:27am UTC](https://discuss.elastic.co/t/changing--type-field-using-elasticsearch-restapi-commands/92623/2 "2017-08-08T10:27:15Z")

</div>

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