简体   繁体   中英

reindex a type on another one in ElasticSearch 2.x onward

I've updated to ElasticSearch 2.1. Deleting a mapping type is not supported anymore since 2.0 onward.

Before, it was very useful to simply remove a type, and created it again.

So, the question is waht should I do in order to reach it out on ElasticSearch 2.1?

Imagine I've an index idx with a type tp . I supose I shall use alias , however I don't know how to do it. Does exists alias for index-level ? Does exist alias for type-level ?

Oh,since 2.x,the elasticsearch cannot delete the mapping .It is no longer possible to delete the mapping for a type. Instead you should delete the index and recreate it with the new mappings.

[You can refer to the link as follow ! ]

https://www.elastic.co/guide/en/elasticsearch/reference/2.2/indices-delete-mapping.html

As mentioned in my answer to your other question , you can proceed in a similar way as before, just on a totally new index (which I called myindex below):

First create a new index with your mapping

curl -XPUT localhost:9200/myindex -d '{
   "mappings": {
       "mytype": {
           "properties": {
               ...
           }
       }
   }
}'

Then re-index your data in your new index

curl -XPUT localhost:9200/myindex/mytype/1 -d '{"field":"value"}'

Finally, you can run your queries on your new index myindex , you can also delete the previous index:

curl -XDELETE localhost:9200/oldindex

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM