Reindex api and date field

Dear all,

I've used _reindex and all the date fields were changed to "type": "text". In the source index, they are all declared as follow:

my_date_field": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss" }

The reindex json was:

  "source": {
    "index": "my_source_index"
  "dest": {
    "index": "my_dest_index"
  "script": {
    "inline": "ctx._source.remove('another_field')"

My elastic version is 6.2.1.

Does anybody know why that happened?

Thanks a lot,


Make sure you set up your (empty) destination index including mappings first. Else it is left for ES to guess the mapping for each field which it seems to do incorrectly in your case.

Thank you, @cdekker, but I couldn't find this option in the _reindex documentation page (

However, according to the "Important note", if I want to duplicate the source index settings, it's supposed to run the index creation prior to the _reindex execution, isn't it?



Actually, the mappings and settings replication should be default for the _reindex. Why would you want to reindex (copy) an index without the source settings???

It is literally in the first paragraph of the documentation you linked :slight_smile:

Reindex does not attempt to set up the destination index. It does not copy the settings of the source index. You should set up the destination index prior to running a _reindex action, including setting up mappings, shard counts, replicas, etc.

Reindex gives you complete freedom over the destination index, which is why it doesn't set up the destination index for you. For example, we use it when a field mapping changes. In those cases you actually want to manually set up a different destination index mapping before copying over all data.

Other 'cloning' operations such as _shrink and _split do set up the destination index for you. But in those cases it is also clearly documented.

EDIT: For our use case we have also disabled dynamic index creation and dynamic mapping (adding fields automatically). It saved us a lot of confusing situations by throwing an error instead of magically creating unknown fields :slight_smile:

Thank you, @cdekker

I didn't know those operations. Maybe I'll try them in the next time.

It makes sense.



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