且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在弹性搜索中删除文档类型?

更新时间:2023-02-08 20:07:50

如果您真的删除了索引,则该索引中的映射不应该再存在了。
您的群集中有没有其他索引具有相似的类型名称?

If you really deleted the index, the mapping in this index should not exist anymore. Do you have any other index in your cluster with a similar type name?

要回答以下问题:如何删除文档在弹性搜索中使用类型?,请使用删除映射API

To answer to the question: How to delete document types in elasticsearch?, use Delete Mapping API:

curl -XDELETE http://localhost:9200/index/type

编辑:从elasticsearch 2.0开始,不可能再有。请参见映射更改。您必须安装按查询删除插件,并运行一个查询,将删除您的文档,但映射仍将存在。所以最有可能更好的是将您的文档重新编入另一个索引而不用旧的类型。

EDIT: From elasticsearch 2.0, it won't be possible anymore. See Mapping changes. 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.

但是,如@mguillemin和@javanna所说,当你删除索引时,附加到此索引也被删除:

But as @mguillemin and @javanna said, when you delete an index, every mapping attached to this index is deleted as well:

curl -XDELETE http://localhost:9200/index