【发布时间】:2015-10-19 06:50:47
【问题描述】:
我正在使用 Elasticsearch 和 Spring Data Elasticsearch 进行项目。
我需要获取我的索引的对象类型的映射。我的@document 类看起来像:
@Document(indexName = "esbsdocuments", type = ESBSDocumentEls.MAPPING_TYPE)
public class ESBSDocumentEls extends ESBSDomainModel {
...
@Field(type =FieldType.Object, store = false)
private Object metadata;
...
}
如果我尝试通过http://xxx:9200/_mapping 获取它,我可以正确获取“元数据”字段的映射:
...
"metadata": {
"properties": {
"APP": {
"type": "string"
},
"APPDST": {
"type": "string"
},
"APPSUB": {
"type": "string"
},
"COUNTSUB": {
"type": "string"
},
"DOMINIO": {
"type": "string"
},
"DUPLICATE": {
"type": "string"
},
"EXCLUDEFIELDNAMES": {
"type": "string"
},
"FECHA": {
"type": "string"
},
"ID": {
"type": "string"
},
"IDF": {
"type": "string"
},
"IDSUB": {
"type": "string"
},
"LOCALEDATE": {
"type": "string"
},
"MENSAJE": {
"type": "string"
},
"TAMANYO": {
"type": "string"
},
"TIPO": {
"type": "string"
},
"VERSION": {
"type": "string"
}
}
},
...
但是当我在代码中尝试使用
Map mapping = elasticsearchTemplate.getMapping(ESBSDocumentEls.class);
我只能得到:
... (definition of metadata dynamic templates)
metadata={type=object}
...
如何使用 ElasticSearchTemplate 或其他 Spring Data Elasticsearch 类获取详细的映射定义??
非常感谢!
【问题讨论】:
标签: elasticsearch spring-data-elasticsearch