[英]Elasticsearch Delete Mapping Property
I am trying to figure out an approach to delete all entries for a specific property in an elasticsearch index and remove all type mappings for that property.我试图找出一种方法来删除 elasticsearch 索引中特定属性的所有条目并删除该属性的所有类型映射。
I have been looking at the following two doc pages: put mapping and delete mapping我一直在看以下两个文档页面: 放置映射和删除映射
From second link:从第二个链接:
"Allow to delete a mapping (type) along with its data. The REST endpoint is /{index}/{type} with DELETE method."
“允许删除映射(类型)及其数据。REST 端点是 /{index}/{type} 和 DELETE 方法。”
What I think I need is a /{index}/{type}/{property}
?我认为我需要的是
/{index}/{type}/{property}
?
Do I need to recreate the whole index to accomplish this, ie moving and manipulating data between types?我是否需要重新创建整个索引来完成此操作,即在类型之间移动和操作数据?
For Example, calling GET on the mapping:例如,在映射上调用 GET:
curl -XGET 'http://.../some_index/some_type/_mapping'
result:结果:
{
"some_type": {
"properties": {
"propVal1": {
"type": "double",
"index": "analyzed"
},
"propVal2": {
"type": "string",
"analyzer": "keyword"
},
"propVal3": {
"type": "string",
"analyzer": "keyword"
}
}
}
}
after this delete operation on propVal3
would return:对
propVal3
执行此删除操作后将返回:
curl -XGET 'http://.../some_index/some_type/_mapping'
result:结果:
{
"some_type": {
"properties": {
"propVal1": {
"type": "double",
"index": "analyzed"
},
"propVal2": {
"type": "string",
"analyzer": "keyword"
}
}
}
}
and all data for propVal3
would be removed through the index. propVal3
的所有数据都将通过索引删除。
You can not do that. 你不能这样做。 Just forget that this value exists... ;-) If you really need to remove it, you will have to reindex your documents.
只是忘记这个值存在... ;-)如果你真的需要删除它,你将不得不重新索引你的文档。
You can use the new _reindex
api for this, you could even PUT a new _mapping
to the dest index before running the reindex so you can change the properties of the fields in your index. 您可以使用新的
_reindex
api,甚至可以在运行reindex之前将新的_mapping
到dest索引,这样您就可以更改索引中字段的属性。
To do a reindex and removing a property, you can do this: 要执行重新索引并删除属性,您可以执行以下操作:
POST /_reindex
{
"source": {
"index": "twitter"
},
"dest": {
"index": "new_twitter",
},
"script": {
"inline": "ctx._source.remove('whatever')"
}
}
if you would use this in combination with the _aliases API you can modify indexes without having any 'downtime' 如果你将它与_aliases API结合使用,你可以修改索引而不会有任何“停机时间”
It's not currently possible to remove a property from a mapping. 目前无法从映射中删除属性。 In order to remove all values of a property from all records, you need to reindex all records with this property removed.
要从所有记录中删除属性的所有值,您需要重新索引删除了此属性的所有记录。
You can choose whats documents fields you will reindex to a new index.您可以选择要重新索引到新索引的文档字段。 For example:
例如:
POST _reindex { "source": { "index": "my-source-index", "_source": ["host.hostname", "host.ip", "another_field"] }, "dest": { "index": "my-dest-index" } } POST _reindex { "source": { "index": "my-source-index", "_source": ["host.hostname", "host.ip", "another_field"] }, "dest": { "index ": "我的目标索引" } }
Reference: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-filter-source参考: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-filter-source
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.