コード例 #1
0
ファイル: EsIndexManager.java プロジェクト: kazoompa/opal
 @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());
 }
コード例 #2
0
 @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();
   }
 }
コード例 #3
0
  @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);
 }