我使用的是Elasticsearch
6.8。我想在我的索引中保存一些meta
数据。该索引已存在。我跟踪了这个https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html#add-field-mapping医生
curl "http://localhost:9200/idx_1/_mapping"
{
"idx_1": {
"mappings": {
"1": {
"properties": {
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
为了创建_meta
数据,我需要首先创建映射类型。
我运行以下代码为version
创建一个_meta
映射类型。
curl -X PUT -H 'Content-Type: application/json' "http://localhost:9200/idx_1/_mapping" -d '
{"_meta": { "version": {"type": "text"}}}'
我得到了以下错误:
{
"error": {
"root_cause": [
{
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: mapping type is missing;"
}
],
"type": "action_request_validation_exception",
"reason": "Validation Failed: 1: mapping type is missing;"
},
"status": 400
}
它说缺少映射类型。我已经将版本的type
指定为text
。为什么它显示为missing type
发布于 2019-10-21 03:10:44
结果是我看错了文档版本。根据Elasticsearch6的文档https://www.elastic.co/guide/en/elasticsearch/reference/6.3/mapping-meta-field.html,正确的请求是:
curl -X PUT "http://localhost:9200/idx1/_mapping/_doc" -H 'Content-Type: application/json' -d '{"_meta": {"version": "1235kljsdlkf"}}'
https://stackoverflow.com/questions/58479026
复制