场景是这样的,put test 建立了一个 index,以及一个 mapping,然后吧 index delete 了,想着 index 下面的 mapping 也就没了,确实用 get test/_mapping 报错了。不过重新 put test 这个 index 之后,get test/_mapping 又出现了。如何才能干净得删除一个 index 以及下面所有的 mapping 呢?
1
jahan OP 6.2 的 elasticsearch
|
2
jahan OP {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [tYGi6U7cTsO_0YXJvN_W2g] as the final mapping would have more than 1 type: [t_gx_jgxx, t_kh_grjcxx]"}],"type":"illegal_argument_exception","reason":"Rejecting mapping update to [tYGi6U7cTsO_0YXJvN_W2g] as the final mapping would have more than 1 type: [t_gx_jgxx, t_kh_grjcxx]"},"status":400}
|
3
Terenc3 2018-03-06 00:10:34 +08:00
GET _template
找到相应的模板名称,删除即可。 |
4
jahan OP 查到并且用 curl xdelete 给删除了,然后重新建 test index,get test/_mapping 神奇的 mapping 又出现了。
我做错了什么? |
5
jahan OP 做了一个模版是这样的,打算手工加载,
{ "index_patterns": ["tes*"], "settings" : { "index" : { "number_of_shards" : 3, "number_of_replicas" : 2 } }, "mappings" : { "t_df_dfxx" : { "properties" : { "ydaxj" : { "type" : "text" }, "nbddh" : { "type" : "text" }, "ajrds" : { "type" : "text" }, } }, "t_kd_grdfd" : { "properties" : { "kk" : { "type" : "text" }, "zjdd" : { "type" : "text" }, "yxjdf" : { "type" : "text" }, } } } } 查了文档,看的十分困惑,有的说这个不支持多个 type,说 7.0 就完全支持。有的例子就完全一样,说 6.0 支持这种写法。 |
6
jahan OP https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html
这里讲 6.0 和以后的版本都不支持多个 mapping,文档给出了这么一个解决方案。 PUT twitter { "mappings": { "_doc": { "properties": { "type": { "type": "keyword" }, "name": { "type": "text" }, "user_name": { "type": "keyword" }, "email": { "type": "keyword" }, "content": { "type": "text" }, "tweeted_at": { "type": "date" } } } } } PUT twitter/_doc/user-kimchy { "type": "user", "name": "Shay Banon", "user_name": "kimchy", "email": "[email protected]" } PUT twitter/_doc/tweet-1 { "type": "tweet", "user_name": "kimchy", "tweeted_at": "2017-10-24T09:00:00Z", "content": "Types are going away" } GET twitter/_search { "query": { "bool": { "must": { "match": { "user_name": "kimchy" } }, "filter": { "match": { "type": "tweet" } } } } } 我的理解是这个把所有的字段混在一起,并不区分 mapping (传统意义上的表)或设置了一个虚拟的 mapping,然后在填充的时候确定 type。单个的例子容易实现,put 就可以了。我从 filebeat-》 logstash-〉 es 就有些理解不了了,加载 template 的时候,还是免不了出 mapping 下的 type 不能多余一个的错误。 |
7
mzbb 2020-06-12 15:26:36 +08:00
# 找到索引对应的模版
GET _template # 删除相关模版 DELETE /_template/target_template |