[英]“_doc” mapping type name not accepted in ElasticSearch 5.6
我正在查看 ElasticSearch 5.6 上的单类型索引示例,以准备删除映射类型。 具体来说,我正在使用docker.elastic.co/elasticsearch/elasticsearch:5.6.5
图像在 Docker 本地运行的新集群上运行 ElasticSearch 页面中关于删除类型的第一个示例
运行我链接到的部分中的第一个示例:
PUT localhost:9200/users
{
"settings": {
"index.mapping.single_type": true
},
"mappings": {
"_doc": {
"properties": {
"name": {
"type": "text"
},
"user_name": {
"type": "keyword"
},
"email": {
"type": "keyword"
}
}
}
}
}
我收到以下错误:
{
"error": {
"root_cause": [
{
"type": "invalid_type_name_exception",
"reason": "mapping type name [_doc] can't start with '_'"
}
],
"type": "invalid_type_name_exception",
"reason": "mapping type name [_doc] can't start with '_'"
},
"status": 400
}
我知道名称中带有前导下划线的字段通常被认为是为 ES 内部保留的; 但我假设_doc
将被视为从版本5.6
开始的特殊情况,因为链接指南提到:
在 6.x 中创建的索引只允许每个索引有一个类型。 该类型可以使用任何名称,但只能有一个。 首选类型名称是 _doc,以便索引 API 具有与 7.0 中相同的路径
我是否缺少某些东西,例如集群设置?
我链接的文档是master
版本。 在同一文档的6.1
或5.6
版本中,没有提到_doc
是首选名称; 这可能意味着使用_doc
作为映射类型名称的能力将在未来的6.x
版本中提供。
我在尝试来自 master 分支https://github.com/elastic/elasticsearch/tree/master的自述文件中的示例时遇到了同样的问题。
$ curl -XPUT 'elastic:@localhost:9200/twitter/_doc/1?pretty' -H 'Content-Type: application/json' -d '
{
"user": "kimchy",
"post_date": "2009-11-15T13:12:00",
"message": "Trying out Elasticsearch, so far so good?"
}'
{
"error" : {
"root_cause" : [
{
"type" : "invalid_type_name_exception",
"reason" : "Document mapping type name can't start with '_', found: [_doc]"
}
],
"type" : "invalid_type_name_exception",
"reason" : "Document mapping type name can't start with '_', found: [_doc]"
},
"status" : 400
}
只需结帐到版本 5.6 https://github.com/elastic/elasticsearch/tree/5.6的分支,看起来一切都很好。
$ curl -XPUT 'http://localhost:9200/twitter/user/kimchy?pretty' -H 'Content-Type: application/json' -d '{ "name" : "Shay Banon" }'
{
"_index" : "twitter",
"_type" : "user",
"_id" : "kimchy",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"created" : true
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.