[英]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.