本文整理了Java中org.elasticsearch.cluster.metadata.MappingMetaData.type()
方法的一些代码示例,展示了MappingMetaData.type()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MappingMetaData.type()
方法的具体详情如下:
包路径:org.elasticsearch.cluster.metadata.MappingMetaData
类名称:MappingMetaData
方法名:type
暂无
代码示例来源:origin: SonarSource/sonarqube
private void verifyFakeIndex() {
ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = mappings();
MappingMetaData mapping = mappings.get("fakes").get("fake");
assertThat(mapping.type()).isEqualTo("fake");
assertThat(mapping.getSourceAsMap()).isNotEmpty();
assertThat(countMappingFields(mapping)).isEqualTo(2);
assertThat(field(mapping, "updatedAt").get("type")).isEqualTo("date");
}
代码示例来源:origin: org.elasticsearch/elasticsearch
public Builder putMapping(MappingMetaData mappingMd) {
mappings.put(mappingMd.type(), mappingMd);
return this;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Converts the serialized compressed form of the mappings into a parsed map.
*/
public Map<String, Object> sourceAsMap() throws ElasticsearchParseException {
Map<String, Object> mapping = XContentHelper.convertToMap(source.compressedReference(), true).v2();
if (mapping.size() == 1 && mapping.containsKey(type())) {
// the type name is the root value, reduce it
mapping = (Map<String, Object>) mapping.get(type());
}
return mapping;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
private void initMappers(Map<String, Object> withoutType) {
if (withoutType.containsKey("_routing")) {
boolean required = false;
Map<String, Object> routingNode = (Map<String, Object>) withoutType.get("_routing");
for (Map.Entry<String, Object> entry : routingNode.entrySet()) {
String fieldName = entry.getKey();
Object fieldNode = entry.getValue();
if (fieldName.equals("required")) {
try {
required = nodeBooleanValue(fieldNode);
} catch (IllegalArgumentException ex) {
throw new IllegalArgumentException("Failed to create mapping for type [" + this.type() + "]. " +
"Illegal value in field [_routing.required].", ex);
}
}
}
this.routing = new Routing(required);
} else {
this.routing = Routing.EMPTY;
}
if (withoutType.containsKey("_parent")) {
this.hasParentField = true;
} else {
this.hasParentField = false;
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@SuppressWarnings("unchecked")
private static MappingMetaData filterFields(MappingMetaData mappingMetaData, Predicate<String> fieldPredicate) throws IOException {
if (fieldPredicate == MapperPlugin.NOOP_FIELD_PREDICATE) {
return mappingMetaData;
}
Map<String, Object> sourceAsMap = XContentHelper.convertToMap(mappingMetaData.source().compressedReference(), true).v2();
Map<String, Object> mapping;
if (sourceAsMap.size() == 1 && sourceAsMap.containsKey(mappingMetaData.type())) {
mapping = (Map<String, Object>) sourceAsMap.get(mappingMetaData.type());
} else {
mapping = sourceAsMap;
}
Map<String, Object> properties = (Map<String, Object>)mapping.get("properties");
if (properties == null || properties.isEmpty()) {
return mappingMetaData;
}
filterFields("", properties, fieldPredicate);
return new MappingMetaData(mappingMetaData.type(), sourceAsMap);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
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);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
final CompressedXContent currentSource = currentIndexMetaData.mapping(mapping.value.type()).source();
final CompressedXContent newSource = mapping.value.source();
assert currentSource.equals(newSource) :
"expected current mapping [" + currentSource + "] for type [" + mapping.value.type() + "] "
+ "to be the same as new mapping [" + newSource + "]";
代码示例来源:origin: apache/servicemix-bundles
public Builder putMapping(MappingMetaData mappingMd) {
mappings.put(mappingMd.type(), mappingMd);
return this;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
for (ObjectCursor<MappingMetaData> mapping : indexMetaData.getMappings().values()) {
String parentType = newMapper.parentFieldMapper().type();
if (parentType.equals(mapping.value.type()) &&
mapperService.getParentTypes().contains(parentType) == false) {
throw new IllegalArgumentException("can't add a _parent field that points to an " +
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(type());
source().writeTo(out);
// routing
out.writeBoolean(routing().required());
if (out.getVersion().before(Version.V_6_0_0_alpha1)) {
// timestamp
out.writeBoolean(false); // enabled
out.writeString(DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.pattern());
out.writeOptionalString("now"); // 5.x default
out.writeOptionalBoolean(null);
}
out.writeBoolean(hasParentField());
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
public Builder putMapping(MappingMetaData mappingMd) {
mappings.put(mappingMd.type(), mappingMd);
return this;
}
代码示例来源:origin: harbby/presto-connectors
public Builder putMapping(MappingMetaData mappingMd) {
mappings.put(mappingMd.type(), mappingMd);
return this;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
public Builder putMapping(MappingMetaData mappingMd) {
mappings.put(mappingMd.type(), mappingMd);
return this;
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
/**
* Converts the serialized compressed form of the mappings into a parsed map.
*/
public Map<String, Object> sourceAsMap() throws IOException {
Map<String, Object> mapping = XContentHelper.convertToMap(source.compressedReference(), true).v2();
if (mapping.size() == 1 && mapping.containsKey(type())) {
// the type name is the root value, reduce it
mapping = (Map<String, Object>) mapping.get(type());
}
return mapping;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
/**
* Converts the serialized compressed form of the mappings into a parsed map.
*/
public Map<String, Object> sourceAsMap() throws ElasticsearchParseException {
Map<String, Object> mapping = XContentHelper.convertToMap(source.compressedReference(), true).v2();
if (mapping.size() == 1 && mapping.containsKey(type())) {
// the type name is the root value, reduce it
mapping = (Map<String, Object>) mapping.get(type());
}
return mapping;
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Converts the serialized compressed form of the mappings into a parsed map.
*/
public Map<String, Object> sourceAsMap() throws ElasticsearchParseException {
Map<String, Object> mapping = XContentHelper.convertToMap(source.compressedReference(), true).v2();
if (mapping.size() == 1 && mapping.containsKey(type())) {
// the type name is the root value, reduce it
mapping = (Map<String, Object>) mapping.get(type());
}
return mapping;
}
代码示例来源:origin: harbby/presto-connectors
/**
* Converts the serialized compressed form of the mappings into a parsed map.
*/
public Map<String, Object> sourceAsMap() throws IOException {
Map<String, Object> mapping = XContentHelper.convertToMap(source.compressedReference(), true).v2();
if (mapping.size() == 1 && mapping.containsKey(type())) {
// the type name is the root value, reduce it
mapping = (Map<String, Object>) mapping.get(type());
}
return mapping;
}
代码示例来源:origin: rmagen/elastic-gremlin
public static DeleteByQueryResponse clearIndex(Client client, String indexName){
DeleteByQueryResponse indexDeleteByQueryResponses = client.prepareDeleteByQuery(indexName).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
GetMappingsResponse getMappingsResponse = client.admin().indices().prepareGetMappings(indexName).execute().actionGet();
ArrayList<String> mappings = new ArrayList();
getMappingsResponse.getMappings().forEach(map -> {
map.value.forEach(map2 -> mappings.add(map2.value.type()));
});
if(mappings.size() > 0) {
DeleteMappingResponse deleteMappingResponse = client.admin().indices().prepareDeleteMapping(indexName).setType(mappings.toArray(new String[mappings.size()])).execute().actionGet();
}
return indexDeleteByQueryResponses;
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
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);
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(type());
source().writeTo(out);
// routing
out.writeBoolean(routing().required());
// timestamp
out.writeBoolean(timestamp().enabled());
out.writeString(timestamp().format());
out.writeOptionalString(timestamp().defaultTimestamp());
out.writeOptionalBoolean(timestamp().ignoreMissing());
out.writeBoolean(hasParentField());
}
内容来源于网络,如有侵权,请联系作者删除!