Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Elasticsearch 'match' doesn't work with Dynamic Templates

I am trying to create a dynamic template based on some matching criteria but when I am using "match" attribute it’s not working. More specific , I want to create a dynamic template with the standard_analyzer (already imported in settings) when field ends with _analyze.

Desired results on Mapping:

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

currently mapping i am doing:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  "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
                }
            }
          }
        }
      }
    ]
  }
}

with result:

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

>Solution :

You just need to move the strings_analz template before the strings one, because the first one that matches is the one that is picked.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading