My current elasticsearch query is-
{
"must": [
{
"range": {
"firstClosedAt": {
"gte": 1667948400000,
"lte": 1668034800000
}
}
},
{
"term": {
"status": "CLOSED"
}
}
I want to modify it such that if "firstClosedAt" is null or not present then look for "closedAt". Just like we have coalesce("firstClosedAt","closedAt") in sql
Help would be appreciated
1条答案
按热度按时间tvokkenx1#
ES中没有coalesce等效项,但您可以执行如下查询,如下所示:“使用firstClosedAt,或者如果firstClosedAt不存在,则使用ClosedAt”:
但是,如果您在编制索引时**创建另一个日期字段,则可以创建一个简单得多的查询,该字段的值为
firstClosedAt
或closedAt
(如果firstClosedAt
不存在