【问题标题】:Elastic Search - Multiple match conditionElastic Search - 多重匹配条件
【发布时间】:2022-11-30 21:59:06
【问题描述】:

我需要编写一个复杂的场景并想知道如何做到这一点 - 我有 3 种不同类型的条目如下

我需要找到带有 **completed ** 的呼叫状态,但有些情况下 completed 状态存储在 2 个条目中。

Record-1 [ Condition-1: 当 lastOutboundStatus 繁忙且 lastInbountStatus 完成时]

"lastOutboundStatus": {
  "status": "busy",
  "timeStamp": 1664945413238
 },
 "lastInboundStatus": {
  "status": "completed",
  "timeStamp": 1664945413238
 },

Record-2 [条件2:当lastInbountStatus完成且lastOutboundStatus不存在时]

"lastInboundStatus": {
  "status": "completed",
  "timeStamp": 1664945413238
 }

Record-3 [ 条件 3:当 lastOutboundStatus 完成时,“lastInboundStatus”可能存在或不存在,无关紧要 - 优先级是 lastOutboundStatus 是否完成]

"lastOutboundStatus": {
  "status": "completed",
  "timeStamp": 1664945413238
 }
"lastInboundStatus": {
  "status": "completed",
  "timeStamp": 1664945413238
 },

只需一个查询,我就需要满足 3 个条件 - 这样才能获得正确的记录。 因此,当我搜索状态已完成时,应该会出现以上所有 3 条记录。

任何忍者都可以提供帮助!!!!

我是elasticsearch的新手,需要一些大师的帮助

【问题讨论】:

    标签: elasticsearch opensearch


    【解决方案1】:

    您可以尝试使用简单的multi_match 查询

    POSt test/_search
    {
      "query": {
        "multi_match": {
          "query": "completed",
          "fields": [
            "lastOutboundStatus.status",
            "lastInboundStatus.status"
          ]
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-14
      • 2015-07-13
      • 2015-02-07
      • 1970-01-01
      • 1970-01-01
      • 2021-02-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多