private void writeMappings(ImmutableOpenMap<String, MappingMetaData> mappings, XContentBuilder builder, ToXContent.Params params) throws IOException { builder.startObject(Fields.MAPPINGS); if (mappings != null) { for (ObjectObjectCursor<String, MappingMetaData> typeEntry : mappings) { builder.field(typeEntry.key); builder.map(typeEntry.value.sourceAsMap()); } } builder.endObject(); }
/** * Converts the serialized compressed form of the mappings into a parsed map. */ public Map<String, Object> getSourceAsMap() throws ElasticsearchParseException { return sourceAsMap(); }
private int getTaskResultMappingVersion(IndexMetaData metaData) { MappingMetaData mappingMetaData = metaData.getMappings().get(TASK_TYPE); if (mappingMetaData == null) { return 0; } @SuppressWarnings("unchecked") Map<String, Object> meta = (Map<String, Object>) mappingMetaData.sourceAsMap().get("_meta"); if (meta == null || meta.containsKey(TASK_RESULT_MAPPING_VERSION_META_FIELD) == false) { return 1; // The mapping was created before meta field was introduced } return (int) meta.get(TASK_RESULT_MAPPING_VERSION_META_FIELD); }
builder.field(MAPPINGS.getPreferredName(), mappings.sourceAsMap()); builder.field(typeEntry.key, typeEntry.value.sourceAsMap());
for (final ObjectObjectCursor<String, MappingMetaData> typeEntry : indexMappings) { builder.field(typeEntry.key); builder.map(typeEntry.value.sourceAsMap());
/** * Converts the serialized compressed form of the mappings into a parsed map. */ public Map<String, Object> getSourceAsMap() throws IOException { return sourceAsMap(); }
/** * Converts the serialized compressed form of the mappings into a parsed map. */ public Map<String, Object> getSourceAsMap() throws ElasticsearchParseException { return sourceAsMap(); }
/** * Converts the serialized compressed form of the mappings into a parsed map. */ public Map<String, Object> getSourceAsMap() throws ElasticsearchParseException { return sourceAsMap(); }
/** * Converts the serialized compressed form of the mappings into a parsed map. */ public Map<String, Object> getSourceAsMap() throws IOException { return sourceAsMap(); }
ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> indexMappings = response.getMappings(); ImmutableOpenMap<String, MappingMetaData> typeMappings = indexMappings.get(indexName); MappingMetaData mapping = typeMappings.get(type); Map<String, Mapping> mappingAsMap = new HashMap<>(); try { Object properties = mapping.sourceAsMap().get("properties"); mappingAsMap = (Map<String, Mapping>) gson.fromJson(gson.toJson(properties), _elasticsearch_type_mapping_map_type); return mappingAsMap; }
public MetaObject getMetaObject(String clusterId, String type) { Optional<MappingMetaData> mapping = this.indexProvider.getMapping(clusterId, type); Map<String, Object> entries = mapping .map(mappingMetaData -> mappingMetaData.sourceAsMap()) .orElse(Collections.emptyMap()); MetaObject meta = this.createMetaObjects(type, entries); return meta; }
private int getTaskResultMappingVersion(IndexMetaData metaData) { MappingMetaData mappingMetaData = metaData.getMappings().get(TASK_TYPE); if (mappingMetaData == null) { return 0; } @SuppressWarnings("unchecked") Map<String, Object> meta = (Map<String, Object>) mappingMetaData.sourceAsMap().get("_meta"); if (meta == null || meta.containsKey(TASK_RESULT_MAPPING_VERSION_META_FIELD) == false) { return 1; // The mapping was created before meta field was introduced } return (int) meta.get(TASK_RESULT_MAPPING_VERSION_META_FIELD); }
private int getTaskResultMappingVersion(IndexMetaData metaData) { MappingMetaData mappingMetaData = metaData.getMappings().get(TASK_TYPE); if (mappingMetaData == null) { return 0; } @SuppressWarnings("unchecked") Map<String, Object> meta = (Map<String, Object>) mappingMetaData.sourceAsMap().get("_meta"); if (meta == null || meta.containsKey(TASK_RESULT_MAPPING_VERSION_META_FIELD) == false) { return 1; // The mapping was created before meta field was introduced } return (int) meta.get(TASK_RESULT_MAPPING_VERSION_META_FIELD); }
public MetaObject getMetaObject(String clusterId, String type) { Optional<MappingMetaData> mapping = this.indexProvider.getMapping(clusterId, type); Map<String, Object> entries = mapping .map(mappingMetaData -> mappingMetaData.sourceAsMap()) .orElse(Collections.emptyMap()); MetaObject meta = this.createMetaObjects(type, entries); return meta; }
private void writeMappings(ImmutableOpenMap<String, MappingMetaData> mappings, XContentBuilder builder, Params params) throws IOException { builder.startObject(Fields.MAPPINGS); if (mappings != null) { for (ObjectObjectCursor<String, MappingMetaData> typeEntry : mappings) { builder.field(typeEntry.key); builder.map(typeEntry.value.sourceAsMap()); } } builder.endObject(); }
private void writeMappings(ImmutableOpenMap<String, MappingMetaData> mappings, XContentBuilder builder, ToXContent.Params params) throws IOException { builder.startObject(Fields.MAPPINGS); if (mappings != null) { for (ObjectObjectCursor<String, MappingMetaData> typeEntry : mappings) { builder.field(typeEntry.key); builder.map(typeEntry.value.sourceAsMap()); } } builder.endObject(); }
builder.field(MAPPINGS.getPreferredName(), mappings.sourceAsMap()); builder.field(typeEntry.key, typeEntry.value.sourceAsMap());
public Map<String, Object> getMappings() throws IOException { ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> indexMappings = client.admin().indices().prepareGetMappings( indexName).setTypes(documentType).execute().actionGet().getMappings(); ImmutableOpenMap<String, MappingMetaData> typeMappings = indexMappings.get(indexName); MappingMetaData mappings = typeMappings.get(documentType); return mappings.sourceAsMap(); }
/** * 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(); }
public ImmutableIndexInfo(String name, IndexService indexService, MappingMetaData mappingMetaData, MetaData metadata, boolean versionLessEngine) throws IOException { this.name = name; this.versionLessEngine = versionLessEngine; this.indexService = indexService; this.mapping = mappingMetaData.sourceAsMap(); this.type = mappingMetaData.type(); Map<String,Object> mappingMap = (Map<String,Object>)mappingMetaData.getSourceAsMap(); Map<String,Object> metaMap = (mappingMap == null) ? null : (Map<String,Object>)mappingMap.get("_meta"); this.refresh = getMetaSettings(metadata.settings(), indexService.getIndexSettings(), metaMap, IndexMetaData.INDEX_SYNCHRONOUS_REFRESH_SETTING); this.snapshot = getMetaSettings(metadata.settings(), indexService.getIndexSettings(), metaMap, IndexMetaData.INDEX_SNAPSHOT_WITH_SSTABLE_SETTING); this.includeNodeId = getMetaSettings(metadata.settings(), indexService.getIndexSettings(), metaMap, IndexMetaData.INDEX_INCLUDE_NODE_ID_SETTING); this.index_on_compaction = getMetaSettings(metadata.settings(), indexService.getIndexSettings(), metaMap, IndexMetaData.INDEX_INDEX_ON_COMPACTION_SETTING); this.index_static_columns = getMetaSettings(metadata.settings(), indexService.getIndexSettings(), metaMap, IndexMetaData.INDEX_INDEX_STATIC_COLUMNS_SETTING); this.index_static_only = getMetaSettings(metadata.settings(), indexService.getIndexSettings(), metaMap, IndexMetaData.INDEX_INDEX_STATIC_ONLY_SETTING); }