### Elasticsearch Version

7.17

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

Not relevant

### Problem Description

Creating a match all index template is bad and we know it.
I needed it for a test and I created a new index template with a `*` `index_pattern`.

I wanted to delete it after few minutes (so that it wouldn't picked up by any new index creation) and I couldn't, unless updating it to match no index.

It seems to deny the deletion because it reports being used by data streams.

### Steps to Reproduce

Create a Index Template matching all:
```
PUT _index_template/matchall
{
  "index_patterns": [
    "*"
  ],
  "priority": 1,
  "template": {
    "mappings": {
      "_meta": {
        "class": "lol"
      }
    }
  }
}
```

Try to delete it:
```
DELETE _index_template/matchall
```

You get:
```
{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "unable to remove composable templates [matchall] as they are in use by a data streams [.fleet-actions-results, .logs-deprecation.elasticsearch-default, .slm-history-5, ilm-history-5, logs-elastic_agent-default, logs-elastic_agent.endpoint_security-default, logs-elastic_agent.filebeat-default, logs-elastic_agent.metricbeat-default, logs-endpoint.events.file-default, logs-endpoint.events.library-default, logs-endpoint.events.network-default, logs-endpoint.events.process-default, logs-endpoint.events.registry-default, logs-endpoint.events.security-default, logs-generic-default, logs-windows.powershell-default, logs-windows.powershell_operational-default, logs-windows.sysmon_operational-default, metrics-elastic_agent.elastic_agent-default, metrics-elastic_agent.endpoint_security-default, metrics-elastic_agent.filebeat-default, metrics-elastic_agent.metricbeat-default, metrics-endpoint.metadata-default, metrics-endpoint.metrics-default, metrics-endpoint.policy-default, metrics-system.cpu-default, metrics-system.diskio-default, metrics-system.memory-default, metrics-system.network-default, metrics-system.process-default, metrics-system.process_summary-default, metrics-system.socket_summary-default, metrics-system.uptime-default, metrics-windows.perfmon-default, metrics-windows.service-default]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "unable to remove composable templates [matchall] as they are in use by a data streams [.fleet-actions-results, .logs-deprecation.elasticsearch-default, .slm-history-5, ilm-history-5, logs-elastic_agent-default, logs-elastic_agent.endpoint_security-default, logs-elastic_agent.filebeat-default, logs-elastic_agent.metricbeat-default, logs-endpoint.events.file-default, logs-endpoint.events.library-default, logs-endpoint.events.network-default, logs-endpoint.events.process-default, logs-endpoint.events.registry-default, logs-endpoint.events.security-default, logs-generic-default, logs-windows.powershell-default, logs-windows.powershell_operational-default, logs-windows.sysmon_operational-default, metrics-elastic_agent.elastic_agent-default, metrics-elastic_agent.endpoint_security-default, metrics-elastic_agent.filebeat-default, metrics-elastic_agent.metricbeat-default, metrics-endpoint.metadata-default, metrics-endpoint.metrics-default, metrics-endpoint.policy-default, metrics-system.cpu-default, metrics-system.diskio-default, metrics-system.memory-default, metrics-system.network-default, metrics-system.process-default, metrics-system.process_summary-default, metrics-system.socket_summary-default, metrics-system.uptime-default, metrics-windows.perfmon-default, metrics-windows.service-default]"
  },
  "status" : 400
}
```

The list seems to be composed by all the data streams.

## Workaround

Update the `index_patterns` to something non-existing.
```
PUT _index_template/matchall
{
  "index_patterns": [
    "none"
  ],
  "priority": 1,
  "template": {
    "mappings": {
      "_meta": {
        "class": "lol"
      }
    }
  }
}
```

Then delete it:
```
DELETE _index_template/matchall
```

### Logs (if relevant)

_No response_
server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java
PutRequest request = new PutRequest("api", templateName);
        request.patterns(singletonList("te*"));
        request.mappings(new CompressedXContent("{}"));
        Alias alias = new Alias(aliasName).filter(randomBoolean() ? null : "{\"term\":{\"user_id\":12}}")
            .indexRouting(randomBoolean() ? null : "route1")
            .searchRouting(randomBoolean() ? null : "route2")
            .isHidden(randomBoolean() ? null : randomBoolean())
            .writeIndex(randomBoolean() ? null : randomBoolean());
        Set<Alias> aliases = new HashSet<>();
        aliases.add(alias);
        request.aliases(aliases);
        List<Throwable> errors = putTemplateDetail(request);
        assertThat(errors, is(empty()));
        final Metadata metadata = client().admin().cluster().prepareState().get().getState().metadata();
        IndexTemplateMetadata template = metadata.templates().get(templateName);
        ImmutableOpenMap<String, AliasMetadata> aliasMap = template.getAliases();
        assertThat(aliasMap.size(), equalTo(1));
        AliasMetadata metaAlias = aliasMap.get(aliasName);
        String filterString = metaAlias.filter() == null ? null : metaAlias.filter().string();
        assertThat(filterString, equalTo(alias.filter()));
        assertThat(metaAlias.indexRouting(), equalTo(alias.indexRouting()));
        assertThat(metaAlias.searchRouting(), equalTo(alias.searchRouting()));
        assertThat(metaAlias.isHidden(), equalTo(alias.isHidden()));
        assertThat(metaAlias.writeIndex(), equalTo(alias.writeIndex()));
    }
    public void testFindTemplates() throws Exception {
        client().admin().indices().prepareDeleteTemplate("*").get(); 
        putTemplateDetail(new PutRequest("test", "foo-1").patterns(singletonList("foo-*")).order(1));
        putTemplateDetail(new PutRequest("test", "foo-2").patterns(singletonList("foo-*")).order(2));
        putTemplateDetail(new PutRequest("test", "bar").patterns(singletonList("bar-*")).order(between(0, 100)));