docs: @SuppressWarnings("rawtypes")
      private boolean getOrReplaceAllIndices(final Object request, final IndicesProvider provider, boolean allowEmptyIndices) {
  
          if(log.isTraceEnabled()) {
              log.trace("getOrReplaceAllIndices() for "+request.getClass());
          }
  
          boolean result = true;
  
          if (request instanceof BulkRequest) {
  
              for (DocWriteRequest ar : ((BulkRequest) request).requests()) {
                  result = getOrReplaceAllIndices(ar, provider, false) && result;
              }
  
          } else if (request instanceof MultiGetRequest) {
  
              for (ListIterator<Item> it = ((MultiGetRequest) request).getItems().listIterator(); it.hasNext();){
                  Item item = it.next();
                  result = getOrReplaceAllIndices(item, provider, false) && result;
                  /*if(item.index() == null || item.indices() == null || item.indices().length == 0) {
                      it.remove();
                  }*/
              }
  
          } else if (request instanceof MultiSearchRequest) {
  
              for (ListIterator<SearchRequest> it = ((MultiSearchRequest) request).requests().listIterator(); it.hasNext();) {
                  SearchRequest ar = it.next();
                  result = getOrReplaceAllIndices(ar, provider, false) && result;
                  /*if(ar.indices() == null || ar.indices().length == 0) {
                      it.remove();
                  }*/
              }
  
          } else if (request instanceof MultiTermVectorsRequest) {
  
              for (ActionRequest ar : (Iterable<TermVectorsRequest>) () -> ((MultiTermVectorsRequest) request).iterator()) {
                  result = getOrReplaceAllIndices(ar, provider, false) && result;
              }
  
          } else if(request instanceof PutMappingRequest) {
              PutMappingRequest pmr = (PutMappingRequest) request;
              Index concreteIndex = pmr.getConcreteIndex();
              if(concreteIndex != null && (pmr.indices() == null || pmr.indices().length == 0)) {
                  String[] newIndices = provider.provide(new String[]{concreteIndex.getName()}, request, true);
                  if(checkIndices(request, newIndices, true, allowEmptyIndices) == false) {
                      return false;
                  }
                  
                  ((PutMappingRequest) request).indices(newIndices);
                  ((PutMappingRequest) request).setConcreteIndex(null);
              } else {
                  String[] newIndices = provider.provide(((PutMappingRequest) request).indices(), request, true);
                  if(checkIndices(request, newIndices, false, allowEmptyIndices) == false) {
                      return false;
                  }
                  ((PutMappingRequest) request).indices(newIndices);
              }
          } else if(request instanceof RestoreSnapshotRequest) {
              
                  if(clusterInfoHolder.isLocalNodeElectedMaster() == Boolean.FALSE) {
                      return true;
                  }      
  
                  final RestoreSnapshotRequest restoreRequest = (RestoreSnapshotRequest) request;
                  final SnapshotInfo snapshotInfo = SnapshotRestoreHelper.getSnapshotInfo(restoreRequest);
  
                  if (snapshotInfo == null) {
                      log.warn("snapshot repository '" + restoreRequest.repository() + "', snapshot '" + restoreRequest.snapshot() + "' not found");
                      provider.provide(new String[]{"*"}, request, false);
                  } else {
                      final List<String> requestedResolvedIndices = SnapshotUtils.filterIndices(snapshotInfo.indices(), restoreRequest.indices(), restoreRequest.indicesOptions());
                      final List<String> renamedTargetIndices = renamedIndices(restoreRequest, requestedResolvedIndices);
                      //final Set<String> indices = new HashSet<>(requestedResolvedIndices);
                      //indices.addAll(renamedTargetIndices);
                      if(log.isDebugEnabled()) {
                          log.debug("snapshot: {} contains this indices: {}", snapshotInfo.snapshotId().getName(), renamedTargetIndices);
                      }
                      provider.provide(renamedTargetIndices.toArray(new String[0]), request, false);
                  }
  
          } else if (request instanceof IndicesAliasesRequest) {
              for(AliasActions ar: ((IndicesAliasesRequest) request).getAliasActions()) {
                  result = getOrReplaceAllIndices(ar, provider, false) && result;
              }
          } else if (request instanceof DeleteRequest) {
              String[] newIndices = provider.provide(((DeleteRequest) request).indices(), request, true);
              if(checkIndices(request, newIndices, true, allowEmptyIndices) == false) {
                  return false;
              }
              ((DeleteRequest) request).index(newIndices.length!=1?null:newIndices[0]);
          } else if (request instanceof UpdateRequest) {
              String[] newIndices = provider.provide(((UpdateRequest) request).indices(), request, true);
              if(checkIndices(request, newIndices, true, allowEmptyIndices) == false) {
                  return false;
              }
              ((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) == false) {
                  return false;
              }
              ((SingleShardRequest) request).index(newIndices.length!=1?null:newIndices[0]);
          } else if (request instanceof IndexRequest) {
              String[] newIndices = provider.provide(((IndexRequest) request).indices(), request, true);
              if(checkIndices(request, newIndices, true, allowEmptyIndices) == false) {
                  return false;
              }
              ((IndexRequest) request).index(newIndices.length!=1?null:newIndices[0]);
          } else if (request instanceof Replaceable) {
              String[] newIndices = provider.provide(((Replaceable) request).indices(), request, true);
              if(checkIndices(request, newIndices, false, allowEmptyIndices) == false) {
                  return false;
              }
              ((Replaceable) request).indices(newIndices);
          } else if (request instanceof BulkShardRequest) {
              provider.provide(((ReplicationRequest) request).indices(), request, false);
              //replace not supported?
          } else if (request instanceof ReplicationRequest) {
              String[] newIndices = provider.provide(((ReplicationRequest) request).indices(), request, true);
              if(checkIndices(request, newIndices, true, allowEmptyIndices) == false) {
                  return false;
              }
              ((ReplicationRequest) request).index(newIndices.length!=1?null:newIndices[0]);
          } else if (request instanceof MultiGetRequest.Item) {
              String[] newIndices = provider.provide(((MultiGetRequest.Item) request).indices(), request, true);
              if(checkIndices(request, newIndices, true, allowEmptyIndices) == false) {
                  return false;
              }
              ((MultiGetRequest.Item) request).index(newIndices.length!=1?null:newIndices[0]);
          } else if (request instanceof CreateIndexRequest) {
              String[] newIndices = provider.provide(((CreateIndexRequest) request).indices(), request, true);
              if(checkIndices(request, newIndices, true, allowEmptyIndices) == false) {
                  return false;
              }
              ((CreateIndexRequest) request).index(newIndices.length!=1?null:newIndices[0]);
          } else if (request instanceof ReindexRequest) {
              result = getOrReplaceAllIndices(((ReindexRequest) request).getDestination(), provider, false) && result;
              result = getOrReplaceAllIndices(((ReindexRequest) request).getSearchRequest(), provider, false) && result;
          } else if (request instanceof BaseNodesRequest) {
              //do nothing
          } else if (request instanceof MainRequest) {
              //do nothing
          } else if (request instanceof ClearScrollRequest) {
              //do nothing
          } else if (request instanceof SearchScrollRequest) {
              //do nothing
          } else {
              if(log.isDebugEnabled()) {
                  log.debug(request.getClass() + " not supported (It is likely not a indices related request)");
              }
              result = false;
          }
  
          return result;
      }