How to change mapping and reindex to new index using mapping with Python Elasticsearch client API?

Hi I'd like to use the client API to do the following.

  1. Set mapping for new index to reindex data to. Let's call our new index "new-index"
  2. Reindex data from let's say "old-index" to new-index, but keep the mapping that
    we set for new-index.

How do I do this with the elasticsearch python client API?
I thought I would be able to do this by creating an index "new-index" with a mapping and then
just reindexing "old-index" to "new-index", but it doesn't seem to keep the mapping.

That being said from http://elasticsearch-py.readthedocs.io/en/master/helpers.html "This helper doesn’t transfer mappings, just the data."

Any idea how I can do this?
Thanks.

If you created the new index with a mapping for a specific type, the index kept it. If you indexed to that index and that type, then that mapping was applied.

What are you seeing that leads you to believe the mapping wasn't kept? Are you able to retrieve it and inspect it after creating new-index?

I created an index "new-index" with a mapping already set and then reindexed from old-index using:

elasticsearch.helpers.reindex(es, "old-index", "new-index")

but when I have a look at the mapping of new-index in Sense , then it has the mapping of the old index.
Not sure what I'm doing wrong.

Related thread: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/elasticsearch/1pquAkRyYrI/Qmi6T8t5vLMJ

Seems like the reindex method can't do this.