Remove TODO in IndexNameExpressionResolver (#52969)

This commit removes a TODO in the IndexNameExpressionResolver that
indicated the API should use a Set instead of a List. However, this
TODO was not completely correct since the ordering of arguments matters
due to negations when evaluating wildcards and since we also allow
a list of patterns like `*,-foo,*`, which would have a different
meaning even when using a Set with insertion ordering.

Relates #52788
Backport of #52963
This commit is contained in:
Jay Modi 2020-02-28 13:56:28 -07:00 committed by GitHub
parent 39de995740
commit 1cd0eee723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -684,8 +684,6 @@ public class IndexNameExpressionResolver {
return resolveEmptyOrTrivialWildcard(options, metaData); return resolveEmptyOrTrivialWildcard(options, metaData);
} }
// TODO: Fix API to work with sets rather than lists since we need to convert to sets
// internally anyway.
Set<String> result = innerResolve(context, expressions, options, metaData); Set<String> result = innerResolve(context, expressions, options, metaData);
if (result == null) { if (result == null) {

View File

@ -351,6 +351,10 @@ public class IndexNameExpressionResolverTests extends ESTestCase {
assertEquals(1, results.length); assertEquals(1, results.length);
assertEquals("bar", results[0]); assertEquals("bar", results[0]);
results = indexNameExpressionResolver.concreteIndexNames(context, "*", "-foo", "*");
assertEquals(3, results.length);
assertThat(results, arrayContainingInAnyOrder("bar", "foobar", "foo"));
results = indexNameExpressionResolver.concreteIndexNames(context, "-*"); results = indexNameExpressionResolver.concreteIndexNames(context, "-*");
assertEquals(0, results.length); assertEquals(0, results.length);