Java Code Examples for org.elasticsearch.common.collect.ImmutableOpenMap#keys()
The following examples show how to use
org.elasticsearch.common.collect.ImmutableOpenMap#keys() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Elasticsearch7SearchIndex.java From vertexium with Apache License 2.0 | 6 votes |
private void loadExistingMappingIntoIndexInfo(Graph graph, IndexInfo indexInfo, String indexName) { indexRefreshTracker.refresh(client, indexName); GetMappingsResponse mapping = client.admin().indices().prepareGetMappings(indexName).get(); for (ObjectCursor<String> mappingIndexName : mapping.getMappings().keys()) { ImmutableOpenMap<String, MappingMetaData> typeMappings = mapping.getMappings().get(mappingIndexName.value); for (ObjectCursor<String> typeName : typeMappings.keys()) { MappingMetaData typeMapping = typeMappings.get(typeName.value); Map<String, Map<String, String>> properties = getPropertiesFromTypeMapping(typeMapping); if (properties == null) { continue; } for (Map.Entry<String, Map<String, String>> propertyEntry : properties.entrySet()) { String rawPropertyName = propertyEntry.getKey().replace(FIELDNAME_DOT_REPLACEMENT, "."); loadExistingPropertyMappingIntoIndexInfo(graph, indexInfo, rawPropertyName); } } } }
Example 2
Source File: Elasticsearch5SearchIndex.java From vertexium with Apache License 2.0 | 6 votes |
private void loadExistingMappingIntoIndexInfo(Graph graph, IndexInfo indexInfo, String indexName) { indexRefreshTracker.refresh(client, indexName); GetMappingsResponse mapping = client.admin().indices().prepareGetMappings(indexName).get(); for (ObjectCursor<String> mappingIndexName : mapping.getMappings().keys()) { ImmutableOpenMap<String, MappingMetaData> typeMappings = mapping.getMappings().get(mappingIndexName.value); for (ObjectCursor<String> typeName : typeMappings.keys()) { MappingMetaData typeMapping = typeMappings.get(typeName.value); Map<String, Map<String, String>> properties = getPropertiesFromTypeMapping(typeMapping); if (properties == null) { continue; } for (Map.Entry<String, Map<String, String>> propertyEntry : properties.entrySet()) { String rawPropertyName = propertyEntry.getKey().replace(FIELDNAME_DOT_REPLACEMENT, "."); loadExistingPropertyMappingIntoIndexInfo(graph, indexInfo, rawPropertyName); } } } }
Example 3
Source File: IndexServiceImpl.java From microservices-platform with Apache License 2.0 | 5 votes |
@Override public Map<String, Object> show(String indexName) throws IOException { GetIndexRequest request = new GetIndexRequest(); request.indices(indexName); GetIndexResponse getIndexResponse = elasticsearchRestTemplate.getClient() .indices().get(request, RequestOptions.DEFAULT); ImmutableOpenMap<String, MappingMetaData> mappOpenMap = getIndexResponse.getMappings().get(indexName); List<AliasMetaData> indexAliases = getIndexResponse.getAliases().get(indexName); String settingsStr = getIndexResponse.getSettings().get(indexName).toString(); Object settingsObj = null; if (StrUtil.isNotEmpty(settingsStr)) { settingsObj = JSONObject.parse(settingsStr); } Map<String, Object> result = new HashMap<>(1); Map<String, Object> indexMap = new HashMap<>(3); Map<String, Object> mappMap = new HashMap<>(mappOpenMap.size()); List<String> aliasesList = new ArrayList<>(indexAliases.size()); indexMap.put("aliases", aliasesList); indexMap.put("settings", settingsObj); indexMap.put("mappings", mappMap); result.put(indexName, indexMap); //获取mappings数据 for (ObjectCursor<String> key : mappOpenMap.keys()) { MappingMetaData data = mappOpenMap.get(key.value); Map<String, Object> dataMap = data.getSourceAsMap(); mappMap.put(key.value, dataMap); } //获取aliases数据 for (AliasMetaData aliases : indexAliases) { aliasesList.add(aliases.getAlias()); } return result; }
Example 4
Source File: VertexiumQueryStringQueryBuilder.java From vertexium with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected FieldNameToVisibilityMap getFieldNameToVisibilityMap(QueryShardContext context) { try { Map<String, String> results = new HashMap<>(); ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = context.getClient().admin().indices().prepareGetMappings().get().getMappings(); for (ObjectCursor<String> index : mappings.keys()) { ImmutableOpenMap<String, MappingMetaData> types = mappings.get(index.value); if (types == null) { continue; } MappingMetaData elementMetadata = types.get(ELEMENT_DOCUMENT_MAPPER_NAME); if (elementMetadata == null) { continue; } Map<String, Map<String, String>> meta = (Map<String, Map<String, String>>) elementMetadata.getSourceAsMap().get("_meta"); if (meta == null) { continue; } Map<String, String> vertexiumMeta = meta.get("vertexium"); if (vertexiumMeta == null) { continue; } results.putAll(vertexiumMeta); } return FieldNameToVisibilityMap.createFromVertexiumMetadata(results); } catch (Exception ex) { throw new RuntimeException("Could not get mappings", ex); } }