我有以下查詢,它在給予我所有期間(嵌套)+房屋屬於它們,並具有指定期間的到期日期。 現在我想嘗試獲取某個房屋的抵達日期,但我無法弄清楚在Elasticsearch中如何做到這一點的語法。找到某個父母的嵌套結果
GET /houses/house/_search
{
"_source" : ["HouseId"],
"query": {
"nested": {
"path": "Periods",
"query": {
"bool": {
"must": [
{"range": {
"Periods.ArrivalDate": {
"gte" : "2017-10-01",
"lt" : "2017-11-01"
}
}
}
]
}
},
"inner_hits" : {}
}
} }
的映射是這樣的(縮短到希望相關部分)
{
"houses": {
"mappings": {
"house": {
"properties": {
"Periods": {
"type": "nested",
"properties": {
"ArrivalDate": {
"type": "date",
"format": "yyyy-MM-dd"
},
....
"HouseId": {
"type": "keyword"
},
所以我想找到一個房子的可用arrivaldates具有一定HouseId在某個月內
你的意思是像' 「_source」 :{「include」:「Period.ArrivalDate」}'? –
不,我的意思是把結果限制在一個房子的時期。你的提示很好,可以解決我認爲的'''''''''黑客',但不是我的問題。這個想法是,我可以列出一個房子的可用時間。我已經有的查詢是用於搜索可用的房屋。 – Maarten
'inner_hits'和'_source'過濾是兩回事。什麼是「房子」? –