gpt4 book ai didi

elasticsearch - 在多字段 Elasticsearch 中设置值

转载 作者:行者123 更新时间:2023-12-03 01:37:05 25 4
gpt4 key购买 nike

我用 flex 记录了以下结构:

    PUT /movies
{
"mappings": {
"title": {
"properties": {
"title": {
"type": "string",
"fields": {
"de": {
"type": "string",
"analyzer": "german"
},
"en": {
"type": "string",
"analyzer": "english"
},
"fr": {
"type": "string",
"analyzer": "french"
},
"es": {
"type": "string",
"analyzer": "spanish"
}
}
}
}
}
}
}

但是当我尝试记录这样的值时:
PUT movies/_doc/2
{
"title": "fox",
"field": "en"
}

我收到以下错误:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [movies] as the final mapping would have more than 1 type: [_doc, title]"
}
],
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [movies] as the final mapping would have more than 1 type: [_doc, title]"
},
"status": 400
}

也许我做错了,因为我刚接触 flex 。我的想法是创建一对一的映射,并且当我以任何一种语言搜索Fox时,由于它们都记录在数据库中,因此仅以英语返回结果。

最佳答案

您的映射表示映射类型为“标题”,但是在创建文档时,您使用PUT movies/_doc/2表示不存在的映射类型_doc,因此ES会尝试自动创建它,并且在较新版本的ES中,禁止使用多种映射类型。

您应该将其更改为:PUT movies/title/2

关于elasticsearch - 在多字段 Elasticsearch 中设置值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51579891/

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