# Reindex API does not work as expected

**URL:** <https://discuss.elastic.co/t/reindex-api-does-not-work-as-expected/48602>\
**Category:** Elasticsearch\
**Created:** [April 27, 2016, 9:36pm UTC](https://discuss.elastic.co/t/reindex-api-does-not-work-as-expected/48602 "2016-04-27T21:36:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![apt275](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@apt275](https://discuss.elastic.co/u/apt275)\
**Post date:** [April 27, 2016, 9:36pm UTC](https://discuss.elastic.co/t/reindex-api-does-not-work-as-expected/48602/1 "2016-04-27T21:36:54Z")

</div>

I am trying to use the reindex api for elasticsearch

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

the old index has some data. so i tried to reindex that as

```
POST /_reindex
{
  "source": {
    "index": "oldindex",
    "type": ["testtype"]
  },
  "dest": {
    "index": "newindex"
  }
}

```

after i do this, i see that the new data was just auto indexed! This is not what i intended at all.

i even tried

POST /\_reindex  
{  
"source": {  
"index": "oldindex",  
"type": ["testtype"]  
},  
"dest": {  
"index": "newindex",  
"type": ["test"]  
}  
}

but now i get

```
{
   "error": "org.elasticsearch.ElasticsearchParseException: Unknown array field [type]"
}

```

what am i doing wrong? I cant use elasticdump or knapsack as they are 3rd party plugins.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [April 27, 2016, 9:54pm UTC](https://discuss.elastic.co/t/reindex-api-does-not-work-as-expected/48602/2 "2016-04-27T21:54:31Z")

</div>

`dest`'s `type` can only a string, not an array. So if that is the second error you got. We should totally change the error message there to be something like `[type] must be a value, not an array`.

> [@apt275](#):
>
> This is not what i intended at all.

What did you intend?

---

<div class="post-metadata">

**Author:** ![apt275](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@apt275](https://discuss.elastic.co/u/apt275)\
**Post date:** [April 28, 2016, 12:46pm UTC](https://discuss.elastic.co/t/reindex-api-does-not-work-as-expected/48602/3 "2016-04-28T12:46:17Z")

</div>

I want to copy all data from the old index to the new one. the data should go to the `test` type in the new index, not autoindexed.

---

<div class="post-metadata">

**Author:** ![apt275](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@apt275](https://discuss.elastic.co/u/apt275)\
**Post date:** [April 28, 2016, 5:28pm UTC](https://discuss.elastic.co/t/reindex-api-does-not-work-as-expected/48602/4 "2016-04-28T17:28:24Z")

</div>

does reindex increase size of data on disk?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [April 28, 2016, 5:44pm UTC](https://discuss.elastic.co/t/reindex-api-does-not-work-as-expected/48602/5 "2016-04-28T17:44:43Z")

</div>

> [@apt275](#):
>
> the data should go to the test type in the new index, not autoindexed.

```js
POST /_reindex
{
  "source": {
    "index": "oldindex"
  },
  "dest": {
    "index": "newindex",
    "type": "test"
  }
}

```

Ought to do that.

> [@apt275](#):
>
> does reindex increase size of data on disk?

It makes a copy but I expect the new copy will have a similar size if the new index has the same mapping. Reindex doesn't copy the mapping from the old index. You have to do that. Indexing is pretty non-deterministic so the size is going to be different. If the source index had lots of deleted documents in the index (cause by deletes or updates) then the new index will be smaller. If the source index was squished up by `_force_merge` then the copy will likely be larger.

---

<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:** [July 5, 2017, 10:55pm UTC](https://discuss.elastic.co/t/reindex-api-does-not-work-as-expected/48602/6 "2017-07-05T22:55:29Z")

</div>


