在现有索引的现有字段中添加带有分析器的多字段

Adding a multifield with analyzer in existing field in existing index

我在 elasticsearch(版本:5.1.1)中有一个现有索引,其中包含一些文档索引。 索引中的映射(比如硬件)有一个如下字段:

"biosSerialNumber" :{
     "type":"keyword"
}

我想用分析器给它添加一个字段,如下所示: "biosSerialNumber" :{ "type":"keyword", "fields":{ "suffix":{ "type":"text", "analyzer":"abc_analyzer" } } }

"abc_analyzer" 分析器已存在于索引设置中。 允许吗?我尝试使用 PUT 命令来执行此操作,我曾使用这些命令在索引中添加新字段。 但是好像不行。

出现此错误:

{ "error": { "root_cause": [ { "type": "mapper_parsing_exception", "reason": "Mapping definition for [fields] has unsupported parameters: [analyzer : suffix_match_analyzer]" } ], "type": "mapper_parsing_exception", "reason": "Mapping definition for [fields] has unsupported parameters: [analyzer : suffix_match_analyzer]" }, "status": 400 }

如评论中所述,错误是因为我试图将分析器添加到 'keyword' 字段,这是不允许的(显而易见的原因是关键字类型未被分析)!。这是一个样本试用。

此外,现在在 运行 PUT 请求之后:

<elshost>/<index-name>/_mapping/<doc-type>

请求正文:

{
    "properties":{
        "asset":{
            "properties" :{
            "biosSerialNumber":{
                "type":"keyword",
                "fields":{
                  "suffix":{
                    "type":"text",
                    "analyzer":"abc_analyzer"
                  }
                }
              }
            }
        }
    }
}

成功了。

我明白,要对字段中的现有数据生效,需要重新索引文档。