elasticsearch Elasticsearch查询-组合查询,elasticsearch,elasticsearch" /> elasticsearch Elasticsearch查询-组合查询,elasticsearch,elasticsearch" />

elasticsearch Elasticsearch查询-组合查询

elasticsearch Elasticsearch查询-组合查询,elasticsearch,elasticsearch,我正在使用Elasticsearch和Kibana 6.2.4。我有以下查询检索条件的数据:(1)提供endUtc不存在的所有记录;(2) 如果endUtc的值设置为大于从系统检索到的当前时间戳,请提供所有记录 GET /session/_search { "query": { "bool": { "must_not": { "exists": { "field": "endUtc" } } }

我正在使用Elasticsearch和Kibana 6.2.4。我有以下查询检索条件的数据:(1)提供endUtc不存在的所有记录;(2) 如果endUtc的值设置为大于从系统检索到的当前时间戳,请提供所有记录

GET /session/_search
{
  "query": {
    "bool": {
      "must_not": { 
        "exists": {
          "field": "endUtc"
        }
      }
    }
  }
}
而且

GET /session/_search
{
  "query": {
    "range": {
      "endUtc": {
        "gt": "<Current date/time>"
      }
    }
  }
}
GET/session/\u搜索
{
“查询”:{
“范围”:{
“endUtc”:{
“gt”:”
}
}
}
}
我无法将这两个查询组合在一起。有没有ES查询专家知道如何实现这一点

谢谢。

看看

您的查询可能类似于:

{
  "query": {
    "bool": {
      "should": [
        {
          "query": {
            "bool": {
              "must_not": {
                "exists": {
                  "field": "endUtc"
                }
              }
            }
          }
        },
        {
          "range": {
            "endUtc": {
              "gt": "<Current date/time>"
            }
          }
        }
      ]
    }
  }
}
{
“查询”:{
“布尔”:{
“应该”:[
{
“查询”:{
“布尔”:{
“不得”:{
“存在”:{
“字段”:“endUtc”
}
}
}
}
},
{
“范围”:{
“endUtc”:{
“gt”:”
}
}
}
]
}
}
}