Reindex API does not work as expected

I am trying to use the reindex api for elasticsearch

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.

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.

What did you intend?

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.

does reindex increase size of data on disk?

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

Ought to do that.

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.