ElasticSearch 5.6 不接受“_doc”映射类型名称
"_doc" mapping type name not accepted in ElasticSearch 5.6
我正在查看 ElasticSearch 5.6 上的单一类型索引示例,为删除映射类型做准备。具体来说,我是 运行 来自 ElasticSearch page about the removal of types 的第一个示例,在 Docker 本地的新集群 运行 上使用 docker.elastic.co/elasticsearch/elasticsearch:5.6.5
图像
运行 我链接到的部分的第一个示例:
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
开始的特例,因为链接指南提到:
Indices created in 6.x only allow a single-type per index. Any name can be used for the type, but there can be only one. The preferred type name is _doc so that index APIs have the same path as they will have in 7.0
我是不是遗漏了什么,比如集群设置?
我链接的文档是master
版本。在同一文档的 6.1
或 5.6
版本中,没有提到 _doc
是首选名称;这可能意味着使用 _doc
作为映射类型名称的能力将在未来的 6.x
版本中出现。
我在主分支 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.6https://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
}
我正在查看 ElasticSearch 5.6 上的单一类型索引示例,为删除映射类型做准备。具体来说,我是 运行 来自 ElasticSearch page about the removal of types 的第一个示例,在 Docker 本地的新集群 运行 上使用 docker.elastic.co/elasticsearch/elasticsearch:5.6.5
图像
运行 我链接到的部分的第一个示例:
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
开始的特例,因为链接指南提到:
Indices created in 6.x only allow a single-type per index. Any name can be used for the type, but there can be only one. The preferred type name is _doc so that index APIs have the same path as they will have in 7.0
我是不是遗漏了什么,比如集群设置?
我链接的文档是master
版本。在同一文档的 6.1
或 5.6
版本中,没有提到 _doc
是首选名称;这可能意味着使用 _doc
作为映射类型名称的能力将在未来的 6.x
版本中出现。
我在主分支 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.6https://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
}