0
表達SQL嵌套條件我有這樣的SQL片段:在ElasticSearch
and (
(notrequired is not null and notrequired <= datedue)
or
(datefulfilled is not null and datefulfilled <= datedue)
)
我試圖表達這樣的:
""or"": [
{{
""and"": [
{{
""exists"": {{ ""field"": ""NotRequired"" }}
}},
{{
""script"": {{
""script"": ""doc['NotRequired'].value <= doc['DateDue'].value""
}}
}}
],
""and"": [
{{
""exists"": {{ ""field"": ""DateFulfilled"" }}
}},
{{
""script"": {{
""script"": ""doc['DateFulfilled'].value <= doc['DateDue'].value""
}}
}}
]
}}
]
外最and
作爲上聚集體的過濾器做到這一點應用了一個過濾器。因此,有一個
aggs: {
"name": {
filter: {},
aggs: {
"inner" : {
filter: {}
}
}
}
}
內過濾器是其中施加and
SQL片段內的一切。所以通過我的推算,因爲你在過濾器內進行過濾,所以應用and
。
請原諒ES片段的逃脫。