gpt4 book ai didi

elasticsearch - 创建索引映射时未找到分析器

转载 作者:行者123 更新时间:2023-12-04 06:16:44 25 4
gpt4 key购买 nike

创建索引时,添加了新的分析器analyzer_keyword-参见下面的创建索引

curl -XPUT 'http://mycluster/dsi2' -d '{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"analyzer_keyword": {
"tokenizer": "keyword",
"filter": "lowercase"
}
}
}
}
}
}

运行 _settings端点可确认以下内容
http GET http://mycluster/dsi2/_settings
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 267
Content-Type: application/json; charset=UTF-8

{
"dsi2": {
"settings": {
"index": {
"analysis": {
"analyzer": {
"analyzer_keyword": {
"filter": "lowercase",
"tokenizer": "keyword"
}
}
},
"creation_date": "1484088347598",
"number_of_replicas": "1",
"number_of_shards": "1",
"uuid": "Lu98fn6gRiOe3Q1y8fU6tQ",
"version": {
"created": "2030299"
}
}
}
}
}

但是现在创建 mapping时-(以下是带有相关字段的部分映射json)
curl -XPUT 'http://mycluster/_mapping/dsi2' -d '{
"_all": {
"enabled": true
},
"properties": {
"mainId" : {
"type" : "integer"
},

"instance": {
"properties": {
"id": {
"type": "integer",
"fields": {
"raw": {
"type": "integer",
"index": "not_analyzed"
}

它抛出
[{"error":{"root_cause": [{"type":"mapper_parsing_exception","reason":"analyzer [analyzer_keyword] not found for field [raw]"}],"type":"mapper_parsing_exception","reason":"analyzer [analyzer_keyword] not found for field [raw]"},"status":400}

知道为什么它无法找到在索引中创建的 analyzer_keyword映射吗?这是针对具有 flex 版本2.3的Amazon EC2 ElasticService实例

编辑-
感谢Val的回复。

@Val-感谢您的回复。正如您所指出的那样,在重新创建索引后-创建映射时仍然出现相同的错误。
当我运行GET http://mycluster/dsi2/_settings时,显示以下内容
{
"dsi2": {
"settings": {
"index": {
"analysis": {
"analyzer": {
"analyzer_keyword": {
"filter": "lowercase",
"tokenizer": "keyword"
}
}
},
"creation_date": "1484146006348",
"number_of_replicas": "1",
"number_of_shards": "1",
"uuid": "HzjQjZXmS8SPF6yUFZanEQ",
"version": {
"created": "2030299"
}
}
}
}
}

最佳答案

那是因为analysis部分直接位于settings之下,而不是settings > index之下。

您可以像这样重新创建索引,它将起作用:

curl -XPUT 'http://mycluster/dsi2' -d '{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"analysis": {
"analyzer": {
"analyzer_keyword": {
"tokenizer": "keyword",
"filter": "lowercase"
}
}
}
}
}

关于elasticsearch - 创建索引映射时未找到分析器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41593352/

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