【发布时间】:2020-02-18 06:35:30
【问题描述】:
随着planned removal of mapping types 来到 ElasticSearch,这是否也意味着嵌套文档和嵌套查询的弃用? ElasticSearch 将/将如何支持在无类型上下文中查询嵌套对象?
我正在考虑的功能是能够仅返回匹配搜索条件的嵌套数组中的命中。
编辑 1:ElasticSearch 版本 6 中的示例映射 + 查询
ElasticSearch 6 映射
{
"rec": {
"mappings": {
"history": {
"properties": {
"dateCompleted": {
"type": "keyword"
},
"dateCreated": {
"type": "keyword"
},
"dateOrdered": {
"type": "keyword"
},
"dateToArrive": {
"type": "keyword"
},
"details": {
"type": "nested",
"properties": {
"clientId": {
"type": "keyword"
},
"company": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"orderNumber": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
}
}
ElasticSearch 6 查询
{
"from": 0,
"query": {
"nested": {
"inner_hits": {},
"path": "details",
"query": {
"bool": {
"must": [
{
"match_phrase": {
"details.company.keyword": {
"query": "ABCD"
}
}
}
]
}
}
}
},
"size": 10,
"sort": [],
"_source": false
}
【问题讨论】:
-
我认为这不会对此产生影响,我想尝试一下,因为如果您可以分享您的映射、示例文档和查询,那就太好了,顺便说一句 +1问题
-
谢谢,@es-enthu。我添加了一个精简的示例映射和查询,希望能展示它在 ElasticSearch 6 中是如何工作的。
标签: elasticsearch nested nest elasticsearch-mapping elasticsearch-7