Is it possible to delete a single mapping type from an index without deleting the entire index? https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-mapping.html says that this is not longer possible but I find this hard to believe. Can anyone explain why the functionality was removed? Seems like basic stuff.
I have an index with two mappings. I would like to be able to remove one mapping type (along with all documents of that type) without removing the other mapping type.
Thanks
You cannot delete the status field from this mapping. If you really need to get rid of this field, you'll have to create another mapping without status field and reindex your data.
You will have to install the Delete By Query plugin and run a query which will remove your documents but the mapping will still exist. So it will most likely better to reindex your documents in another index without the old type.
If the Elasticsearch security features are enabled, you must have the manage index privilege for the target data stream, index, or alias. [7.9] If the request targets an index or index alias, you can also update its mapping with the create , create_doc , index , or write index privilege.
You use DELETE to remove a document from an index. You must specify the index name and document ID. You cannot send deletion requests directly to a data stream. To delete a document in a data stream, you must target the backing index containing the document.
To answer your question, I believe it was yanked out for reliability and maybe performance optimizations when the mappings get shipped around the cluster.
The reason why it's hard to change anything in ES index is because the underlying storage is an inverted index, and any data that you have put in has been already indexed with those mapping rules.
Elasticsearch lowers the barrier of entry into search, but has some pretty complicated stuff going under the hood.
For latest version(above 2.0) of ES, 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. For more information you can see this in official document here. For the older versions(Below 2.0) of elasticsearch allow to delete a mapping (type) along with its data. The REST endpoints are
[DELETE] /{index}/{type} [DELETE] /{index}/{type}/_mapping [DELETE] /{index}/_mapping/{type}
An example of potential problem with deleting types/mapping and the explanation for disabling can be found in elasticsearch issue : 8877. Extract from issue description :
Currently, a user can delete a type entirely, which deletes the type, all documents of that type, and removes the associated fields. Unfortunately, if any documents of that type have already been indexed, then the fields are part of the index. Adding fields with the same name but a different data type will cause conflicts later on.
Currently reindex is the only option however to alleviate the problem of reindexing on client end seems like there maybe a possiblity of support for reindex api in future : see issue:16207 and issue:#15201 for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With