# Simulate index results

**URL:** <https://discuss.elastic.co/t/simulate-index-results/340981>\
**Category:** Elasticsearch\
**Created:** [August 17, 2023, 8:08am UTC](https://discuss.elastic.co/t/simulate-index-results/340981 "2023-08-17T08:08:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![franck.valentin](https://avatars.discourse-cdn.com/v4/letter/f/d2c977/32.png) [@franck.valentin](https://discuss.elastic.co/u/franck.valentin)\
**Post date:** [August 17, 2023, 8:08am UTC](https://discuss.elastic.co/t/simulate-index-results/340981/1 "2023-08-17T08:08:24Z")

</div>

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:

```auto
/* ================= 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:

```auto
GET /_index_template/template*

```

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

```auto
/* ================= 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.

```auto
POST /_index_template/_simulate_index/coll-default_1-001

```

returns:

```auto
{
  "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](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/indices-simulate-index.html) 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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 14, 2023, 8:08am UTC](https://discuss.elastic.co/t/simulate-index-results/340981/2 "2023-09-14T08:08:48Z")

</div>

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