Elasticsearch 'match'不能与动态模板一起使用

ddrv8njm  于 2022-11-02  发布在  ElasticSearch
关注(0)|答案(1)|浏览(128)

我尝试根据某些匹配条件创建动态模板,但当我使用“match”属性时,它不起作用。更具体地说,当字段以_analyze结尾时,我想创建一个带有standard_analyzer(已导入设置中)的动态模板。
预期的标测结果:

{
       "count" : {
          "type" : "integer"
        },
        "is_top" : {
          "type" : "boolean"
        },
       "keywords_analyze":{
          "type":"text",
          "fields":{
             "std_analyzer":{
             "type":"text",
             "term_vector":"yes",
             "analyzer":"standard_analyzer"
         }
      }
   }
}

我正在做的事情:

"mappings": {
    "dynamic_templates": [
      {
        "integers": {
          "match_mapping_type": "long",
          "mapping": {
            "type": "integer"
          }
        }
      },
        {
        "strings": {
          "match_mapping_type": "string",
          "mapping": {
            "type": "text"
          }
        }
      },
      {
        "strings_analz": {
          "match": "*_analyze",
          "mapping": {
            "type": "text",
            "analyzer" : "standard_analyzer"
            "fields": {
                "keyword": {
                  "type":  "keyword",
                  "ignore_above": 256
                }
            }
          }
        }
      }
    ]
  }
}

结果是:

"count" : {
          "type" : "integer"
        },
        "is_top" : {
          "type" : "boolean"
        },
        "keywords_analyze" : {
          "type" : "text"
        },
        "count" : {
          "type" : "integer"
        }
ssm49v7z

ssm49v7z1#

您只需要将strings_analz模板移到strings模板之前,因为第一个匹配的模板就是拾取的模板。

相关问题