Dynamic_templates

I want to create dynamic_template mapping for this document:

{
	"COUNT:integer":1,
	"one":{
		"COUNT:integer":1,
		"two":{
			"COUNT:integer":1,
			"three":{
				"COUNT:integer":1,
			}
		}
	}
}

My goal is to create something like:

"mappings" : {
	"dynamic_templates":[
		{
			"integer":{
				"match": "*:integer",
				"match_mapping_type": "*",   
				"mapping": {"type":"integer"}
			}
		}	
	]
}

My question:
will this mapping match all "COUNT:integer" values, including one.COUNT:integer, one.two.COUNT:integer and one.two.three.COUNT:integer?
(And how to test, witch attributes matches this expression?)

If not, how to change mapping to achieve this goal?

  • possible solution 1: match_pattern and Regex. Is regex testing whole path (one.two.three.COUNT:integer) or just attribute name COUNT:integer?
  • possible solution 2: path_match. In documentation is not specified, if "path_match":"*.*:integer" matches only one.COUNT:integer, or if it matches also COUNT:integer and one.two.COUNT:integer and one.two.three.COUNT:integer

Hey,

how about testing it by creating an index with the above dynamic template and then index a document?

DELETE my_index

PUT my_index
{
  "mappings": {
    "dynamic_templates": [
      {
        "integer": {
          "match": "*:integer",
          "mapping": {
            "type": "integer"
          }
        }
      }
    ]
  }
}

PUT my_index/_doc/1
{
	"COUNT:integer":1,
	"one":{
		"COUNT:integer":1,
		"two":{
			"COUNT:integer":1,
			"three":{
				"COUNT:integer":1
			}
		}
	}
}

GET my_index/_mapping

retrieving the mapping. You can play around with the type and set it to a double to see if that actually works despite sending an integer to Elasticsearch.

--Alex

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.