org.elasticsearch.cluster.metadata.IndexMetaData.mapping()方法的使用及代码示例

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

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

IndexMetaData.mapping介绍

[英]Sometimes, the default mapping exists and an actual mapping is not created yet (introduced), in this case, we want to return the default mapping in case it has some default mapping definitions.

Note, once the mapping type is introduced, the default mapping is applied on the actual typed MappingMetaData, setting its routing, timestamp, and so on if needed.
[中]有时,默认映射存在,而实际映射尚未创建(引入),在这种情况下,我们希望返回默认映射,以防它具有一些默认映射定义。
注意,一旦引入映射类型,默认映射将应用于实际类型化的MappingMetaData,并根据需要设置其路由、时间戳等。

代码示例

代码示例来源:origin: floragunncom/search-guard

if(clusterService.state().metaData().index(this.searchguardIndex).mapping("config") != null) {

代码示例来源:origin: karussell/elasticsearch-reindex

/**
 * Creates a new index out of the settings from the old index.
 */
private void createIdenticalIndex(String oldIndex, String type,
    String newIndex, int newIndexShards, Client client) throws IOException {
  IndexMetaData indexData = client.admin().cluster().state(new ClusterStateRequest()).
      actionGet().getState().metaData().indices().get(oldIndex);
  Settings searchIndexSettings = indexData.settings();
  ImmutableSettings.Builder settingBuilder = ImmutableSettings.settingsBuilder().put(searchIndexSettings);
  if (newIndexShards > 0)
    settingBuilder.put("index.number_of_shards", newIndexShards);
    
  CreateIndexRequest createReq;
  
  if(type.equals("*")) {
    createReq = new CreateIndexRequest(newIndex);
    for(ObjectObjectCursor<String, MappingMetaData> mapCursor : indexData.mappings()) {
      createReq.mapping(mapCursor.key, mapCursor.value.sourceAsMap());
    }
    createReq.settings(settingBuilder.build());
  }
  else {
    MappingMetaData mappingMeta = indexData.mapping(type);
    createReq = new CreateIndexRequest(newIndex).
      mapping(type, mappingMeta.sourceAsMap()).
      settings(settingBuilder.build());
  }
  client.admin().indices().create(createReq).actionGet();
}

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

CompressedXContent incomingMappingSource = newIndexMetaData.mapping(mappingType).source();

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

final CompressedXContent currentSource = currentIndexMetaData.mapping(mapping.value.type()).source();
  final CompressedXContent newSource = mapping.value.source();
  assert currentSource.equals(newSource) :
assert updatedEntries.isEmpty() == false;
for (final DocumentMapper documentMapper : updatedEntries.values()) {
  final MappingMetaData currentMapping = currentIndexMetaData.mapping(documentMapper.type());
  if (currentMapping != null) {
    final CompressedXContent currentSource = currentMapping.source();

代码示例来源:origin: stackoverflow.com

public String getMapping(String index, String type) throws EsuException {
  ClusterState cs = getClient().admin().cluster().prepareState().setFilterIndices(index).execute().actionGet().getState();
  IndexMetaData imd = cs.getMetaData().index(index);

  if (imd == null) {
    throw new EsuIndexDoesNotExistException(index);
  }

  MappingMetaData mmd = imd.mapping(type);

  if (mmd == null) {
    throw new EsuTypeDoesNotExistException(index, type);
  }

  String mapping = "";
  try {
    mapping = mmd.source().string();
  } catch (IOException e) {
    mapping = "{ \"" + e.toString() + "\"}";
  }
  return mapping;
}

代码示例来源:origin: com.floragunn/search-guard-6

if(clusterService.state().metaData().index(this.searchguardIndex).mapping("config") != null) {

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

IndexMetaData indexMetaData = cursor.value;
if (indexMetaData.keyspace().equals(this.baseCfs.metadata.ksName) && 
  indexMetaData.mapping(ClusterService.cfNameToType(this.baseCfs.name)) != null &&
  !indexMetaData.equals(event.previousState().metaData().index(indexMetaData.getIndex().getName()))) {
  updateMapping = true;

代码示例来源:origin: lbroudoux/es-amazon-s3-river

/**
* Check if a mapping already exists in an index
* @param index Index name
* @param type Mapping name
* @return true if mapping exists
*/
private boolean isMappingExist(String index, String type) {
 ClusterState cs = client.admin().cluster().prepareState()
    .setIndices(index).execute().actionGet()
    .getState();
 // Check index metadata existence.
 IndexMetaData imd = cs.getMetaData().index(index);
 if (imd == null){
   return false;
 }
 // Check mapping metadata existence.
 MappingMetaData mdd = imd.mapping(type);
 if (mdd != null){
   return true;
 }
 return false;
}

代码示例来源:origin: fujitsu-pio/io

/**
 * Mapping定義を取得する.
 * @param index インデックス名
 * @param type タイプ名
 * @return Mapping定義
 */
public MappingMetaData getMapping(String index, String type) {
  ClusterState cs = esTransportClient.admin().cluster().prepareState().
      setIndices(index).execute().actionGet().getState();
  return cs.getMetaData().index(index).mapping(type);
}

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

CompressedXContent incomingMappingSource = indexMetaData.mapping(mappingType).source();

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

CompressedXContent incomingMappingSource = indexMetaData.mapping(mappingType).source();

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

if (ElasticSecondaryIndex.this.baseCfs.metadata.ksName.equals(indexMetaData.keyspace()) && (mappingMetaData = indexMetaData.mapping(typeName)) != null) {
  try {
    Map<String,Object> mappingMap = (Map<String,Object>)mappingMetaData.getSourceAsMap();

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

CompressedXContent incomingMappingSource = newIndexMetaData.mapping(mappingType).source();

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

final CompressedXContent currentSource = currentIndexMetaData.mapping(mapping.value.type()).source();
  final CompressedXContent newSource = mapping.value.source();
  assert currentSource.equals(newSource) :
assert updatedEntries.isEmpty() == false;
for (final DocumentMapper documentMapper : updatedEntries.values()) {
  final MappingMetaData currentMapping = currentIndexMetaData.mapping(documentMapper.type());
  if (currentMapping != null) {
    final CompressedXContent currentSource = currentMapping.source();

代码示例来源:origin: tlrx/elasticsearch-view-plugin

MappingMetaData mappingMetaData = clusterService.state().metaData().index(request.index()).mapping(request.type());
if (mappingMetaData != null) {
  try {

代码示例来源:origin: com.github.tlrx/elasticsearch-view-plugin

MappingMetaData mappingMetaData = clusterService.state().metaData().index(request.index()).mapping(request.type());
if (mappingMetaData != null) {
  try {

相关文章

微信公众号

最新文章

更多

IndexMetaData类方法