예제 #1
0
 @Override
 public boolean hasIndex(@NotNull ValueTable valueTable) {
   ClusterStateResponse resp =
       opalSearchService.getClient().admin().cluster().prepareState().execute().actionGet();
   ImmutableOpenMap<String, MappingMetaData> mappings =
       resp.getState().metaData().index(getName()).mappings();
   return mappings.containsKey(getIndex(valueTable).getIndexName());
 }
 @Override
 public void deleteType(String index, String type) {
   ImmutableOpenMap<String, MappingMetaData> mappings =
       client
           .admin()
           .cluster()
           .prepareState()
           .execute()
           .actionGet()
           .getState()
           .metaData()
           .index(index)
           .mappings();
   if (mappings.containsKey(type)) {
     client
         .admin()
         .indices()
         .deleteMapping(new DeleteMappingRequest(index).types(type))
         .actionGet();
   }
 }
  @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));
  }
예제 #4
0
 public boolean hasIndex(String index) {
   return indices.containsKey(index);
 }