我在Elasticsearch中有以下查询:
{
"script_fields": {
"travel_time": {
"script": {
"inline": "doc['DateTo'].value - doc['DateFrom'].value"
}
}
},
"stored_fields": [
"_source"
],
"query": {
"bool": {
"filter": {
"exists": {
"field": "DateTo"
}
}
}
}
}
如何将DateFrom
添加到exists
过滤器中?
答案 0 :(得分:1)
您可以添加多个exists
条件:
"query": {
"bool": {
"filter": [
{
"exists": {
"field": "DateFrom"
}
},
{
"exists": {
"field": "DateTo"
}
},
{
"script": {
"script": {
"inline": "doc['DateTo'].value - doc['DateFrom'].value > 0"
}
}
}
]
}
}