java GetMappings在弹性搜索7中发生了变化。十、
我已将弹性搜索从“2.3.4”升级到“7.10.0”
在更改应用程序代码时,对下面的GetMappings情况感到困惑:
旧代码(2.3.4):
Map<String, Object> mappingMeta = client.admin().indices().prepareGetMappings("index1").get().mappings().get("index1").get("type1").getSourceAsMap();
新代码(7.10.0):
GetMappingsRequest mappingsRequest = new GetMappingsRequest();
mappingsRequest.indices("index1");
GetMappingsResponse mappingsResponse = client.indices().getMapping(mappingsRequest, RequestOptions.DEFAULT);
Map<String, Object> mappingMeta = mappingsResponse.mappings().get("what_should_come_here? "index1" or "type1").getSourceAsMap();
在从新代码中的响应获取mappingdata时,有人能帮我吗?get下面应该是什么(参见新代码块的最后一行,也是get PARM中询问的)?是indexName还是Type name
# 1 楼答案
经过一段时间的研发;D发现我们可以在ES 7中得到索引的字段映射。x版本,但不能用于类型,因为类型在7.0的API中已被弃用
所以,在上述情况下,我只能得到索引的映射