### 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
+ "templates [foo] with patterns (foo => [egg*, baz]) that have the same priority [0], multiple "
                        + "index templates may not match during index creation, please use a different priority"
                )
            );
        }
    }
    public void testFindV2Templates() throws Exception {
        final MetadataIndexTemplateService service = getMetadataIndexTemplateService();
        ClusterState state = ClusterState.EMPTY_STATE;
        assertNull(MetadataIndexTemplateService.findV2Template(state.metadata(), "index", randomBoolean()));
        ComponentTemplate ct = ComponentTemplateTests.randomInstance();
        state = service.addComponentTemplate(state, true, "ct", ct);
        ComposableIndexTemplate it = new ComposableIndexTemplate(List.of("i*"), null, List.of("ct"), null, 1L, null, null, null);
        state = service.addIndexTemplateV2(state, true, "my-template", it);
        ComposableIndexTemplate it2 = new ComposableIndexTemplate(List.of("in*"), null, List.of("ct"), 10L, 2L, null, null, null);
        state = service.addIndexTemplateV2(state, true, "my-template2", it2);
        String result = MetadataIndexTemplateService.findV2Template(state.metadata(), "index", randomBoolean());
        assertThat(result, equalTo("my-template2"));
    }
    public void testFindV2TemplatesForHiddenIndex() throws Exception {
        final MetadataIndexTemplateService service = getMetadataIndexTemplateService();
        ClusterState state = ClusterState.EMPTY_STATE;
        assertNull(MetadataIndexTemplateService.findV2Template(state.metadata(), "index", true));
        ComponentTemplate ct = ComponentTemplateTests.randomInstance();
        state = service.addComponentTemplate(state, true, "ct", ct);
        ComposableIndexTemplate it = new ComposableIndexTemplate(List.of("i*"), null, List.of("ct"), 0L, 1L, null, null, null);
        state = service.addIndexTemplateV2(state, true, "my-template", it);
        ComposableIndexTemplate it2 = new ComposableIndexTemplate(List.of("*"), null, List.of("ct"), 10L, 2L, null, null, null);
        state = service.addIndexTemplateV2(state, true, "my-template2", it2);
        String result = MetadataIndexTemplateService.findV2Template(state.metadata(), "index", true);