Skip to content

Commit

Permalink
Cleanup single shard request index check (opensearch-project#993)
Browse files Browse the repository at this point in the history
  • Loading branch information
sujithvm authored Feb 1, 2021
1 parent 1328a6a commit 02a181a
Showing 1 changed file with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -647,25 +647,13 @@ private boolean getOrReplaceAllIndices(final Object request, final IndicesProvid
}
((UpdateRequest) request).index(newIndices.length!=1?null:newIndices[0]);
} else if (request instanceof SingleShardRequest) {
final SingleShardRequest<?> gr = (SingleShardRequest<?>) request;
final String[] indices = gr.indices();
final String index = gr.index();

final List<String> indicesL = new ArrayList<String>();

if (index != null) {
indicesL.add(index);
}

if (indices != null && indices.length > 0) {
indicesL.addAll(Arrays.asList(indices));
}

String[] newIndices = provider.provide(indicesL.toArray(new String[0]), request, true);
if (!checkIndices(request, newIndices, true, allowEmptyIndices)) {
final SingleShardRequest<?> singleShardRequest = (SingleShardRequest<?>) request;
final String index = singleShardRequest.index();
String[] indices = provider.provide(index == null ? null : new String[]{index}, request, true);
if (!checkIndices(request, indices, true, allowEmptyIndices)) {
return false;
}
((SingleShardRequest) request).index(newIndices.length!=1?null:newIndices[0]);
singleShardRequest.index(indices.length != 1? null : indices[0]);
} else if (request instanceof FieldCapabilitiesIndexRequest) {
// FieldCapabilitiesIndexRequest does not support replacing the indexes.
// However, the indexes are always determined by FieldCapabilitiesRequest which will be reduced below
Expand Down

0 comments on commit 02a181a

Please sign in to comment.