org.elasticsearch.indices.IndicesService.createIndexMapperService()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中org.elasticsearch.indices.IndicesService.createIndexMapperService()方法的一些代码示例,展示了IndicesService.createIndexMapperService()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IndicesService.createIndexMapperService()方法的具体详情如下:
包路径:org.elasticsearch.indices.IndicesService
类名称:IndicesService
方法名:createIndexMapperService

IndicesService.createIndexMapperService介绍

[英]creates a new mapper service for the given index, in order to do administrative work like mapping updates. This should not be used for document parsing. Doing so will result in an exception. Note: the returned MapperService should be closed when unneeded.
[中]为给定索引创建新的映射器服务,以便执行映射更新之类的管理工作。此不应用于文档解析。这样做将导致异常。注意:当不需要时,应关闭返回的MapperService。

代码示例

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public ClusterTasksResult<PutMappingClusterStateUpdateRequest>
execute(ClusterState currentState, List<PutMappingClusterStateUpdateRequest> tasks) throws Exception {
  Map<Index, MapperService> indexMapperServices = new HashMap<>();
  ClusterTasksResult.Builder<PutMappingClusterStateUpdateRequest> builder = ClusterTasksResult.builder();
  try {
    for (PutMappingClusterStateUpdateRequest request : tasks) {
      try {
        for (Index index : request.indices()) {
          final IndexMetaData indexMetaData = currentState.metaData().getIndexSafe(index);
          if (indexMapperServices.containsKey(indexMetaData.getIndex()) == false) {
            MapperService mapperService = indicesService.createIndexMapperService(indexMetaData);
            indexMapperServices.put(index, mapperService);
            // add mappings for all types, we need them for cross-type validation
            mapperService.merge(indexMetaData, MergeReason.MAPPING_RECOVERY, request.updateAllTypes());
          }
        }
        currentState = applyRequest(currentState, request, indexMapperServices);
        builder.success(request);
      } catch (Exception e) {
        builder.failure(request, e);
      }
    }
    return builder.build(currentState);
  } finally {
    IOUtils.close(indexMapperServices.values());
  }
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

@Override
public ClusterTasksResult<PutMappingClusterStateUpdateRequest> execute(ClusterState currentState,
                                    List<PutMappingClusterStateUpdateRequest> tasks) throws Exception {
  Map<Index, MapperService> indexMapperServices = new HashMap<>();
  ClusterTasksResult.Builder<PutMappingClusterStateUpdateRequest> builder = ClusterTasksResult.builder();
  try {
    for (PutMappingClusterStateUpdateRequest request : tasks) {
      try {
        for (Index index : request.indices()) {
          final IndexMetaData indexMetaData = currentState.metaData().getIndexSafe(index);
          if (indexMapperServices.containsKey(indexMetaData.getIndex()) == false) {
            MapperService mapperService = indicesService.createIndexMapperService(indexMetaData);
            indexMapperServices.put(index, mapperService);
            // add mappings for all types, we need them for cross-type validation
            mapperService.merge(indexMetaData, MergeReason.MAPPING_RECOVERY, request.updateAllTypes());
          }
        }
        currentState = applyRequest(currentState, request, indexMapperServices);
        builder.success(request);
      } catch (Exception e) {
        builder.failure(request, e);
      }
    }
    return builder.build(currentState, true);
  } finally {
    IOUtils.close(indexMapperServices.values());
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

@Override
public ClusterTasksResult<PutMappingClusterStateUpdateRequest> execute(ClusterState currentState,
                                    List<PutMappingClusterStateUpdateRequest> tasks) throws Exception {
  Map<Index, MapperService> indexMapperServices = new HashMap<>();
  ClusterTasksResult.Builder<PutMappingClusterStateUpdateRequest> builder = ClusterTasksResult.builder();
  try {
    for (PutMappingClusterStateUpdateRequest request : tasks) {
      try {
        for (Index index : request.indices()) {
          final IndexMetaData indexMetaData = currentState.metaData().getIndexSafe(index);
          if (indexMapperServices.containsKey(indexMetaData.getIndex()) == false) {
            MapperService mapperService = indicesService.createIndexMapperService(indexMetaData);
            indexMapperServices.put(index, mapperService);
            // add mappings for all types, we need them for cross-type validation
            mapperService.merge(indexMetaData, MergeReason.MAPPING_RECOVERY, request.updateAllTypes());
          }
        }
        currentState = applyRequest(currentState, request, indexMapperServices);
        builder.success(request);
      } catch (Exception e) {
        builder.failure(request, e);
      }
    }
    return builder.build(currentState);
  } finally {
    IOUtils.close(indexMapperServices.values());
  }
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public ClusterTasksResult<PutMappingClusterStateUpdateRequest> execute(ClusterState currentState,
                                    List<PutMappingClusterStateUpdateRequest> tasks) throws Exception {
  Map<Index, MapperService> indexMapperServices = new HashMap<>();
  ClusterTasksResult.Builder<PutMappingClusterStateUpdateRequest> builder = ClusterTasksResult.builder();
  try {
    for (PutMappingClusterStateUpdateRequest request : tasks) {
      try {
        for (Index index : request.indices()) {
          final IndexMetaData indexMetaData = currentState.metaData().getIndexSafe(index);
          if (indexMapperServices.containsKey(indexMetaData.getIndex()) == false) {
            MapperService mapperService = indicesService.createIndexMapperService(indexMetaData);
            indexMapperServices.put(index, mapperService);
            // add mappings for all types, we need them for cross-type validation
            mapperService.merge(indexMetaData, MergeReason.MAPPING_RECOVERY, request.updateAllTypes());
          }
        }
        currentState = applyRequest(currentState, request, indexMapperServices);
        builder.success(request);
      } catch (Exception e) {
        builder.failure(request, e);
      }
    }
    return builder.build(currentState);
  } finally {
    IOUtils.close(indexMapperServices.values());
  }
}

相关文章

微信公众号

最新文章

更多