在对象字段上应用分析器

Apply analyzer on Object fields

我有这个分析仪:

{
  "index": {
    "number_of_shards": 1,
    "analysis": {
      "filter": {
        "word_joiner": {
          "type": "word_delimiter",
          "catenate_all": true,
          "preserve_original": true
        }
      },
      "analyzer": {
        "word_join_analyzer": {
          "type": "custom",
          "filter": [
            "word_joiner"
          ],
          "tokenizer": "keyword"
        }
      }
    }
  }
}

我把它应用在这个领域:

@Field(type = FieldType.Object, analyzer = "word_join_analyzer")
private Description description;

这是描述 class:

public class Description {

       @JsonProperty("localizedDescriptions")
       private Map<String, String> descriptions = new HashMap<>();
}

这是为该字段生成的 Elasticsearch 映射:

{  
   "description":{  
      "properties":{  
         "localizedDescriptions":{  
            "properties":{  
               "en":{  
                  "type":"string"
               },
               "fr":{  
                  "type":"string"
               },
               "it":{  
                  "type":"string"
               }
            }
         }
      }
   }
}

如您所见,根本没有应用分析器。它适用于字符串字段,但我很难处理对象类型。有什么想法吗?
谢谢!

编辑:我尝试使用动态映射:

{
  "iam":{
    "properties":{
      "dynamic_templates":[
        {
          "localized_strings_values":{
            "path_match":"description.localizedDescriptions.*",
            "mapping":{
              "type":"string",
              "analyzer":"word_join_analyzer"
            }
          }
        }
      ]
    }
  }
}

但是我有这个错误:

Expected map for property [fields] on field [dynamic_templates] but got a class java.lang.String

为什么会出现此错误?

终于解决了。这是正确的映射:

{
  "cake": {
    "dynamic_templates": [
      {
        "localized_descriptions": {
          "path_match":   "description.localizedDescriptions.*",
          "mapping": {
            "type": "string",
            "analyzer": "word_join_analyzer"
          }
        }
      }
    ]
  }
}