### Elasticsearch Version

7.x, 8.x

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

Darwin 

### Problem Description

A data stream must have an index template that matches it in order to exist.
When managing index templates we want to make sure we don't leave a
data stream without a [corresponding index template](https://github.com/elastic/elasticsearch/blob/acf9968f9d397d755d5ad9fcf815cca23bbeda61/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateService.java#L918).

The `dataStreamsUsingTemplate` check uses the index pattern of the index 
templates to conclude if a template is used by a data stream, however it should
be enhanced to check the priority too as there can only be only one index template
that matches a data stream and it's the one with the highest priority.

### Steps to Reproduce

Create an ILM policy
```
PUT _ilm/policy/testing_yo
{
  "policy": {
    "phases": {
      "warm": {
	"actions": {
	  "shrink": {
          "number_of_shards": 1
	  }
        }
      }
    } 
  }
}
```

Create an index template with the `data_stream` option:
```
PUT _index_template/logs_data_stream
{
	"index_patterns": [ "logs*", "te*", "bar*" ],
	"data_stream": {},
        "priority": 100,
	"template" : {
	  "settings": {
            "index.number_of_shards": 3,
	    "index.lifecycle.name": "testing"
	  }
	}
}
```

Create the data stream
```
POST logs_test/_doc 
{
  "message": "testing",
  "@timestamp": "1591890611"
}
```

Create a new index template that would match this data stream with a higher priority
```
PUT _index_template/higher_logs_data_stream
{
	"index_patterns": [ "logs*", "te*", "bar*" ],
	"data_stream": {},
        "priority": 500,
	"template" : {
	  "settings": {
            "index.number_of_shards": 3,
	    "index.lifecycle.name": "testing"
	  }
	}
}
```

Attempt to delete the previous, lower priority index template:
```
DELETE _index_template/logs_data_stream
```

### Logs (if relevant)

_No response_
modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java
indexDocs("metrics-foo", numDocs2); 
        int numDocs3 = randomIntBetween(2, 10);
        indexDocs("metrics-foo", numDocs3); 
        int totalDocs = numDocs1 + numDocs2 + numDocs3;
        SearchSourceBuilder source = new SearchSourceBuilder();
        source.fetchField(new FieldAndFormat(DEFAULT_TIMESTAMP_FIELD, "epoch_millis"));
        source.size(totalDocs);
        SearchRequest searchRequest = new SearchRequest(new String[] { "metrics-foo" }, source);
        SearchResponse searchResponse = client().search(searchRequest).actionGet();
        assertEquals(totalDocs, searchResponse.getHits().getTotalHits().value);
        SearchHit[] hits = searchResponse.getHits().getHits();
        assertEquals(totalDocs, hits.length);
        
        long timestamp1 = Long.valueOf(hits[0].field(DEFAULT_TIMESTAMP_FIELD).getValue()); 
        long timestamp2 = Long.valueOf(hits[0 + numDocs3].field(DEFAULT_TIMESTAMP_FIELD).getValue()); 
        long timestamp3 = Long.valueOf(hits[0 + numDocs3 + numDocs2].field(DEFAULT_TIMESTAMP_FIELD).getValue());  
        assertTrue(timestamp1 > timestamp2);
        assertTrue(timestamp2 > timestamp3);
    }
    public void testCreateDataStreamWithSameNameAsIndexAlias() throws Exception {
        CreateIndexRequest createIndexRequest = new CreateIndexRequest("my-index").alias(new Alias("my-alias"));
        assertAcked(client().admin().indices().create(createIndexRequest).actionGet());
        
        DataStreamIT.putComposableIndexTemplate("my-template", List.of("my-*"));
        var request = new CreateDataStreamAction.Request("my-alias");
        var e = expectThrows(IllegalStateException.class, () -> client().execute(CreateDataStreamAction.INSTANCE, request).actionGet());
        assertThat(e.getMessage(), containsString("[my-alias (alias of ["));
        assertThat(e.getMessage(), containsString("]) conflicts with data stream"));
    }
    public void testCreateDataStreamWithSameNameAsIndex() throws Exception {