.getIndices() .get(mapping.get_index()) .getMappings(); } catch (NullPointerException e) { throw new IllegalArgumentException("Not found the mapping info of index: " + mapping.get_index());
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); }
/** * @param concreteIndex The concrete index to check if routing is required * @param type The type to check if routing is required * @return Whether routing is required according to the mapping for the specified index and type */ public boolean routingRequired(String concreteIndex, String type) { IndexMetaData indexMetaData = indices.get(concreteIndex); if (indexMetaData != null) { MappingMetaData mappingMetaData = indexMetaData.getMappings().get(type); if (mappingMetaData != null) { return mappingMetaData.routing().required(); } } return false; }
private synchronized Map<String, DocumentMapper> internalMerge(IndexMetaData indexMetaData, MergeReason reason, boolean updateAllTypes, boolean onlyUpdateIfNeeded) { Map<String, CompressedXContent> map = new LinkedHashMap<>(); for (ObjectCursor<MappingMetaData> cursor : indexMetaData.getMappings().values()) { MappingMetaData mappingMetaData = cursor.value; if (onlyUpdateIfNeeded) { DocumentMapper existingMapper = documentMapper(mappingMetaData.type()); if (existingMapper == null || mappingMetaData.source().equals(existingMapper.mappingSource()) == false) { map.put(mappingMetaData.type(), mappingMetaData.source()); } } else { map.put(mappingMetaData.type(), mappingMetaData.source()); } } return internalMerge(map, reason, updateAllTypes); }
for (ObjectObjectCursor<String, MappingMetaData> mapping : sourceMetaData.getMappings()) { mappingUpdateConsumer.accept(mapping.key, mapping.value);
for (ObjectObjectCursor<String, MappingMetaData> cursor : indexMetaData.getMappings()) { Map<String, Object> mapping = XContentHelper .convertToMap(new BytesArray(cursor.value.source().uncompressed()), false).v2();
Predicate<String> fieldPredicate = fieldFilter.apply(index); if (isAllTypes) { indexMapBuilder.put(index, filterFields(indexMetaData.getMappings(), fieldPredicate)); } else { ImmutableOpenMap.Builder<String, MappingMetaData> filteredMappings = ImmutableOpenMap.builder(); for (ObjectObjectCursor<String, MappingMetaData> cursor : indexMetaData.getMappings()) { if (Regex.simpleMatch(types, cursor.key)) { filteredMappings.put(cursor.key, filterFields(cursor.value, fieldPredicate));
for (ObjectObjectCursor<String, MappingMetaData> cursor : indexMetaData.getMappings()) { if (binary) { builder.value(cursor.value.source().compressed());
for (final ObjectCursor<MappingMetaData> mapping : newIndexMetaData.getMappings().values()) { final CompressedXContent currentSource = currentIndexMetaData.mapping(mapping.value.type()).source(); final CompressedXContent newSource = mapping.value.source();
for (ObjectCursor<MappingMetaData> mapping : indexMetaData.getMappings().values()) { String parentType = newMapper.parentFieldMapper().type(); if (parentType.equals(mapping.value.type()) &&
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); }
ImmutableOpenMap<String, MappingMetaData> mappings = state.metaData().getIndices().get(concreteIndex).getMappings(); if (mappings.isEmpty()) { listener.onResponse(new TypesExistsResponse(false));
public void dropTables(final IndexMetaData indexMetaData) throws RequestExecutionException { String ksName = indexMetaData.keyspace(); for(ObjectCursor<String> cfName : indexMetaData.getMappings().keys()) { dropTable(ksName, cfName.value); } }
public void createSecondaryIndices(final IndexMetaData indexMetaData) throws IOException { String ksName = indexMetaData.keyspace(); String className = indexMetaData.getSettings().get(IndexMetaData.SETTING_SECONDARY_INDEX_CLASS, this.settings.get(SETTING_CLUSTER_SECONDARY_INDEX_CLASS, defaultSecondaryIndexClass.getName())); for(ObjectCursor<MappingMetaData> cursor: indexMetaData.getMappings().values()) { createSecondaryIndex(ksName, cursor.value, className); } }
/** * @param concreteIndex The concrete index to check if routing is required * @param type The type to check if routing is required * @return Whether routing is required according to the mapping for the specified index and type */ public boolean routingRequired(String concreteIndex, String type) { IndexMetaData indexMetaData = indices.get(concreteIndex); if (indexMetaData != null) { MappingMetaData mappingMetaData = indexMetaData.getMappings().get(type); if (mappingMetaData != null) { return mappingMetaData.routing().required(); } } return false; }
/** * @param concreteIndex The concrete index to check if routing is required * @param type The type to check if routing is required * @return Whether routing is required according to the mapping for the specified index and type */ public boolean routingRequired(String concreteIndex, String type) { IndexMetaData indexMetaData = indices.get(concreteIndex); if (indexMetaData != null) { MappingMetaData mappingMetaData = indexMetaData.getMappings().get(type); if (mappingMetaData != null) { return mappingMetaData.routing().required(); } } return false; }
/** * @param concreteIndex The concrete index to check if routing is required * @param type The type to check if routing is required * @return Whether routing is required according to the mapping for the specified index and type */ public boolean routingRequired(String concreteIndex, String type) { IndexMetaData indexMetaData = indices.get(concreteIndex); if (indexMetaData != null) { MappingMetaData mappingMetaData = indexMetaData.getMappings().get(type); if (mappingMetaData != null) { return mappingMetaData.routing().required(); } } return false; }
private synchronized Map<String, DocumentMapper> internalMerge(IndexMetaData indexMetaData, MergeReason reason, boolean updateAllTypes, boolean onlyUpdateIfNeeded) { Map<String, CompressedXContent> map = new LinkedHashMap<>(); for (ObjectCursor<MappingMetaData> cursor : indexMetaData.getMappings().values()) { MappingMetaData mappingMetaData = cursor.value; if (onlyUpdateIfNeeded) { DocumentMapper existingMapper = documentMapper(mappingMetaData.type()); if (existingMapper == null || mappingMetaData.source().equals(existingMapper.mappingSource()) == false) { map.put(mappingMetaData.type(), mappingMetaData.source()); } } else { map.put(mappingMetaData.type(), mappingMetaData.source()); } } return internalMerge(map, reason, updateAllTypes); }
@Override public boolean typeExists(String indexName, String type) { return getAdminClient().cluster().prepareState().execute().actionGet().getState().metaData().index(indexName) .getMappings().containsKey(type); }