} else {
concreteIndices = concreteAllClosedIndices();
}
if (!indicesOptions.allowNoIndices() && concreteIndices.length == 0) {
throw new IndexMissingException(new Index("_all"));
}
return concreteIndices;
}
aliasesOrIndices = convertFromWildcards(aliasesOrIndices, indicesOptions);
}
boolean failClosed = indicesOptions.forbidClosedIndices() && !indicesOptions.ignoreUnavailable();
// optimize for single element index (common case)
if (aliasesOrIndices.length == 1) {
return concreteIndices(aliasesOrIndices[0], indicesOptions.allowNoIndices(), failClosed, indicesOptions.allowAliasesToMultipleIndices());
}
// check if its a possible aliased index, if not, just return the passed array
boolean possiblyAliased = false;
boolean closedIndices = false;
for (String index : aliasesOrIndices) {
IndexMetaData indexMetaData = indices.get(index);
if (indexMetaData == null) {
possiblyAliased = true;
break;
} else {
if (indicesOptions.forbidClosedIndices() && indexMetaData.getState() == IndexMetaData.State.CLOSE) {
if (failClosed) {
throw new IndexClosedException(new Index(index));
} else {
closedIndices = true;
}
}
}
}
if (!possiblyAliased) {
if (closedIndices) {
Set<String> actualIndices = new HashSet<>(Arrays.asList(aliasesOrIndices));
actualIndices.retainAll(new HashSet<Object>(Arrays.asList(allOpenIndices)));
return actualIndices.toArray(new String[actualIndices.size()]);
} else {
return aliasesOrIndices;
}
}
Set<String> actualIndices = new HashSet<>();
for (String aliasOrIndex : aliasesOrIndices) {
String[] indices = concreteIndices(aliasOrIndex, indicesOptions.ignoreUnavailable(), failClosed, indicesOptions.allowAliasesToMultipleIndices());
Collections.addAll(actualIndices, indices);
}
if (!indicesOptions.allowNoIndices() && actualIndices.isEmpty()) {
throw new IndexMissingException(new Index(Arrays.toString(aliasesOrIndices)));
}
return actualIndices.toArray(new String[actualIndices.size()]);
}