[英]Search for documents in elasticsearch and then query the nested fields
我有这样的索引:
{
"rentals": {
"aliases": {},
"mappings": {
"rental": {
"properties": {
"address": {
"type": "text"
},
"availability": {
"type": "nested",
"properties": {
"chargeBasis": {
"type": "text"
},
"date": {
"type": "date"
},
"isAvailable": {
"type": "boolean"
},
"rate": {
"type": "double"
}
}
}
}
这是我的用例:
我需要搜索具有给定地址的所有“租金”。
我需要获取所有搜索到的“租金”的“可用性”数据; 仅适用于今天的日期 。
您需要使用嵌套查询 :
由于嵌套对象被索引为单独的隐藏文档,因此我们无法直接对其进行查询。 相反,我们必须使用嵌套查询来访问它们。
尝试类似:
{
"query": {
"nested": {
"path": "availability",
"query": {
"term": {
"availability.date": "2015-01-01"
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.