### 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
final CyclicBarrier barrier = new CyclicBarrier(threadCount + 1);
        final AtomicBoolean running = new AtomicBoolean(true);
        Set<Thread> threads = IntStream.range(0, threadCount).mapToObj(i -> new Thread(() -> {
            try {
                logger.info("--> [{}] waiting for all the other threads before starting", i);
                barrier.await();
                while (running.get()) {
                    RolloverResponse resp = client().admin().indices().prepareRolloverIndex(dsName).addMaxIndexDocsCondition(2).get();
                    if (resp.isRolledOver()) {
                        logger.info("--> thread [{}] successfully rolled over: {}", i, Strings.toString(resp));
                        assertThat(resp.getOldIndex(), backingIndexEqualTo("potato-biscuit", 1));
                        assertThat(resp.getNewIndex(), backingIndexEqualTo("potato-biscuit", 2));
                    }
                }
            } catch (Exception e) {
                logger.error(new ParameterizedMessage("thread [{}] encountered unexpected exception", i), e);
                fail("we should not encounter unexpected exceptions");
            }
        }, "rollover-thread-" + i)).collect(Collectors.toSet());
        threads.forEach(Thread::start);
        indexDocs(dsName, 1);
        
        barrier.await();
        indexDocs(dsName, 1);
        assertBusy(() -> {
            try {
                client().admin().indices().prepareGetIndex().addIndices(DataStream.getDefaultBackingIndexName("potato-biscuit", 2)).get();
            } catch (Exception e) {
                logger.info("--> expecting second index to be created but it has not yet been created");
                fail("expecting second index to exist");