elasticsearch 多字段弹性搜索中的设置值,elasticsearch,elasticsearch" /> elasticsearch 多字段弹性搜索中的设置值,elasticsearch,elasticsearch" />

elasticsearch 多字段弹性搜索中的设置值

elasticsearch 多字段弹性搜索中的设置值,elasticsearch,elasticsearch,我在elastic中记录了以下结构: PUT /movies { "mappings": { "title": { "properties": { "title": { "type": "string", "fields": { "de": { "type": "string", "analyzer": "german

我在elastic中记录了以下结构:

    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
}

也许我做错了什么,因为我对弹性相当陌生。我的想法是创建一对一映射,当我搜索这些语言中的任何一种时,只返回英文结果,因为它们记录在数据库中。

您的映射表示映射类型“title”但是,当您创建文档时,您使用的
PUT movies/\u doc/2
指示映射类型
\u doc
,该类型不存在,因此ES将尝试自动创建它,并且在较新版本的ES中,禁止使用多个映射类型

您只需将其更改为:
PUT movies/title/2