Simulate index results

Hi,

I was testing the Simulate index API on Elasticsearch 7.17 and didn't understand some of the results.
The requests below create separate component templates for the mappings and settings and then index templates composed of these templates:

/* =================  Mappings ======================= */

PUT /_component_template/mappings_default
{
  "template": {
    "mappings": {
	  "dynamic": "strict",
      "properties": {
        "default_1": {
          "type": "keyword"
        },
		"default_2": {
          "type": "date"
        }
      }
    }
  }
}

PUT /_component_template/mappings_1
{
  "template": {
    "mappings": {
	  "dynamic": "strict",
      "properties": {
        "prop1_1": {
          "type": "keyword"
        },
		"prop1_2": {
          "type": "date"
        }
      }
    }
  }
}

PUT /_component_template/mappings_2
{
  "template": {
    "mappings": {
	  "dynamic": "strict",
      "properties": {
        "prop2_1": {
          "type": "keyword"
        },
		"prop2_2": {
          "type": "date"
        }
      }
    }
  }
}

PUT /_component_template/mappings_3
{
  "template": {
    "mappings": {
	  "dynamic": "strict",
      "properties": {
        "prop3_1": {
          "type": "keyword"
        },
		"prop3_2": {
          "type": "date"
        }
      }
    }
  }
}

/* =================   Index settings ======================= */

PUT /_component_template/settings_default
{
  "template": {
    "settings": {
      "number_of_shards": 10,
      "number_of_replicas": 10
    }
  }
}

PUT /_component_template/settings_1
{
  "template": {
    "settings": {
      "number_of_shards": 1,
      "number_of_replicas": 1
    }
  }
}

PUT /_component_template/settings_2
{
  "template": {
    "settings": {
      "number_of_shards": 2,
      "number_of_replicas": 2
    }
  }
}

PUT /_component_template/settings_3
{
  "template": {
    "settings": {
      "number_of_shards": 3,
      "number_of_replicas": 3
    }
  }
}

/* =================   Index templates ======================= */

PUT /_index_template/template_default             
{
  "index_patterns": ["coll-*"],
  "composed_of": [
    "mappings_default", 
	"settings_default"
  ],
  "priority": 10
}


PUT /_index_template/template_template1            
{
  "index_patterns": ["coll-group*-collection1_1-*", "coll-group*-collection1_2-*"],
  "composed_of": [
    "mappings_default", 
    "settings_default",
    "mappings_1", 
    "settings_1"
  ],
  "priority": 20
}

PUT /_index_template/template_template2        
{
  "index_patterns": ["coll-group*-collection2_1-*", "coll-group*-collection2_2-*"],
  "composed_of": [
    "mappings_default", 
    "settings_default",
    "mappings_2", 
    "settings_2"
  ],
  "priority": 30
}

PUT /_index_template/template_template3        
{
  "index_patterns": ["coll-group3-collection3_1-*", "coll-group3-collection3_2-*"],
  "composed_of": [
    "mappings_default", 
    "settings_default",
    "mappings_3", 
    "settings_3"
  ],
  "priority": 40
}

The templates are correctly created:

GET /_index_template/template*

Then indices whose names match these templates are created with an alias:

/* =================  Create indices ======================= */

PUT /coll-default_1-001
{
  "aliases": {
    "coll-default_1": {}
  }
}

PUT /coll-default_1-002
{
  "aliases": {
    "coll-default_1": {}
  }
}

PUT /coll-groupa-collection1_1-001
{
  "aliases": {
    "coll-groupa-collection1_1": {}
  }
}

PUT /coll-groupb-collection1_2-001
{
  "aliases": {
    "coll-groupb-collection1_2": {}
  }
}

PUT /coll-groupc-collection2_1-001
{
  "aliases": {
    "coll-groupc-collection2_1": {}
  }
}

PUT /coll-groupd-collection2_2-001
{
  "aliases": {
    "coll-groupd-collection2_2": {}
  }
}

GET /coll-*

But the results from _simulate_index are strange to me. E.g.

POST /_index_template/_simulate_index/coll-default_1-001

returns:

{
  "template" : {
    "settings" : {
      "index" : {
        "number_of_shards" : "10",
        "number_of_replicas" : "10"
      }
    },
    "mappings" : {
      "dynamic" : "strict",
      "properties" : {
        "default_1" : {
          "type" : "keyword"
        },
        "default_2" : {
          "type" : "date"
        }
      }
    },
    "aliases" : { }
  },
  "overlapping" : [
    {
      "name" : "template_template3",
      "index_patterns" : [
        "coll-group3-collection3_1-*",
        "coll-group3-collection3_2-*"
      ]
    },
    {
      "name" : "template_template1",
      "index_patterns" : [
        "coll-group*-collection1_1-*",
        "coll-group*-collection1_2-*"
      ]
    },
    {
      "name" : "template_template2",
      "index_patterns" : [
        "coll-group*-collection2_1-*",
        "coll-group*-collection2_2-*"
      ]
    }
  ]
}
  • No alias is returned whereas the collection defines the alias coll-default_1.
  • Overlappings are returned but the documentation states

Any templates that also matched the index but were superseded by a higher-priority template. Response includes an empty array if there are no overlapping templates.

Which is not the case here.
Same issue for POST /_index_template/_simulate_index/coll-groupd-collection2_2-002 (settings and mappings are correct though).

Do I miss something or is there a bug?

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