@Override
  protected void masterOperation(
      final TypesExistsRequest request,
      final ClusterState state,
      final ActionListener<TypesExistsResponse> listener) {
    String[] concreteIndices =
        indexNameExpressionResolver.concreteIndexNames(
            state, request.indicesOptions(), request.indices());
    if (concreteIndices.length == 0) {
      listener.onResponse(new TypesExistsResponse(false));
      return;
    }

    for (String concreteIndex : concreteIndices) {
      if (!state.metaData().hasConcreteIndex(concreteIndex)) {
        listener.onResponse(new TypesExistsResponse(false));
        return;
      }

      ImmutableOpenMap<String, MappingMetaData> mappings =
          state.metaData().getIndices().get(concreteIndex).getMappings();
      if (mappings.isEmpty()) {
        listener.onResponse(new TypesExistsResponse(false));
        return;
      }

      for (String type : request.types()) {
        if (!mappings.containsKey(type)) {
          listener.onResponse(new TypesExistsResponse(false));
          return;
        }
      }
    }

    listener.onResponse(new TypesExistsResponse(true));
  }