0

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?

Jordi
  • 20,868
  • 39
  • 149
  • 333
  • I did not understand your question. What is the end goal here? You want to delete all existing documents of type `tp` from index `idx` and index them again with the same type `tp`? – bittusarkar Dec 15 '15 at 12:01

2 Answers2

1

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

Community
  • 1
  • 1
Hatter Bush
  • 215
  • 1
  • 3
  • 15
  • Consider including any information needed to solve the question directly in your answer in case that link goes bad one day. – user3071284 Jan 21 '16 at 15:19
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). - [From Review](/review/low-quality-posts/10974009) – user3071284 Jan 21 '16 at 15:19
  • Ah,i think the answer is correct and easy . The doc has clearly tell the implements. first delete index ,then create it .The API is very easy ,U should also move your hands to look for the API .If you don't have a see,I can show you :`client.admin().indices() .delete(new DeleteIndexRequest(index)).actionGet().` `client.admin().indices() .preparePutMapping(index) .setType(type) .execute().actionGet();` – Hatter Bush Jan 22 '16 at 01:17
0

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
Community
  • 1
  • 1
Val
  • 207,596
  • 13
  • 358
  • 360