gpt4 book ai didi

elasticsearch - 如何在 `Elasticsearch`上创建元数据?

转载 作者:行者123 更新时间:2023-12-03 02:37:54 26 4
gpt4 key购买 nike

我正在使用Elasticsearch 6.8。而且我想在索引上保存一些meta数据。该索引已经存在。我遵循了这个doc 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数据,我需要首先创建映射类型。

然后运行以下代码为 _meta创建 version映射类型。
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

最佳答案

原来,我看错了文档版本。根据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"}}'

关于elasticsearch - 如何在 `Elasticsearch`上创建元数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58479026/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com