elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.93k stars 24.73k forks source link

Multi-target syntax does not exclude indices of the first wildcard exclude #64752

Open HarushR opened 3 years ago

HarushR commented 3 years ago

Elasticsearch version (bin/elasticsearch --version): 7.9.3

Plugins installed: None.

JVM version (java -version): 14

OS version: CentOS 7.4

Description of the problem including expected versus actual behavior: When trying to query an index and excluding with wildcard, the first wildcard exclude is not excluded.

Given the indices tatiana, virginia and alina, the expected result of GET tatiana,-ta* is nothing, while the actual response includes the index tatiana. However, GET tatiana,-al*,-ta* will not include tatiana.

Steps to reproduce:

  1. Create an index:
    curl -XPUT localhost:9200/tatiana/1 -d '{
    "title": "test document"
    }'
  2. GET the index tatiana and remove (exclude) all indices that begin with ta* curl -XGET localhost:9200/tatiana,-ta*

Provide logs (if relevant): -

elasticmachine commented 3 years ago

Pinging @elastic/es-core-features (:Core/Features/Indices APIs)

probakowski commented 3 years ago

The problem is not that the first exclude is ignored but that we only apply excludes after first wildcard is seen. So GET tatiana,al*,-ta* will also exclude tatiana, GET tatiana,-tatiana fill fail with error no such index [-tatiana] and finally GET tatiana*,-tatiana will work just fine. That applies to every API that uses IndexNameExpressionResolver

Manikese commented 3 years ago

Thank you @probakowski! Your post allowed me to get my index input parameter working in a Logstash config file. Hopefully someone can update the "Multi-target syntax" documentation here: https://www.elastic.co/guide/en/elasticsearch/reference/7.10/multi-index.html It doesn't mention that exclusion only works if a wildcard is used.

jameswiggins commented 3 years ago

It would be great if exclude could be applied after an alias :)