Skip to content

Commit

Permalink
Avoid redundant available indices check (#76540)
Browse files Browse the repository at this point in the history
The resolved indices list contains name elements that either:
- are concrete names that been explicitly mentioned in the original request, or
- are authorized indices that are referred to by a date math expression from the request, or
- are authorized indices that are covered by a wildcard from the request

If the request option `ignoreUnavailable` is set to true the resolved indices list overall
must silently ignore the names that are not in the authorized set.
Consequently, only the names in the first category mentioned above must be verified;
the check for the other names is redundant.
  • Loading branch information
albertzaharovits authored Oct 20, 2021
1 parent 0318758 commit ec81466
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public List<String> resolveIndexAbstractions(Iterable<String> indices, IndicesOp
} else if (dateMathName.equals(indexAbstraction)) {
if (minus) {
finalIndices.remove(indexAbstraction);
} else {
} else if (indicesOptions.ignoreUnavailable() == false || availableIndexAbstractions.contains(indexAbstraction)) {
finalIndices.add(indexAbstraction);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ ResolvedIndices resolveIndicesAndAliases(String action, IndicesRequest indicesRe
}
List<String> replaced = indexAbstractionResolver.resolveIndexAbstractions(split.getLocal(), indicesOptions, metadata,
authorizedIndices, replaceWildcards, indicesRequest.includeDataStreams());
if (indicesOptions.ignoreUnavailable()) {
//out of all the explicit names (expanded from wildcards and original ones that were left untouched)
//remove all the ones that the current user is not authorized for and ignore them
replaced = replaced.stream().filter(authorizedIndices::contains).collect(Collectors.toList());
}
resolvedIndicesBuilder.addLocal(replaced);
resolvedIndicesBuilder.addRemote(split.getRemote());
}
Expand Down

0 comments on commit ec81466

Please sign in to comment.