【问题标题】:Elastic search Query to Find Unanswered Questions用于查找未回答问题的弹性搜索查询
【发布时间】:2021-11-08 21:00:09
【问题描述】:

我需要使用字段“user_response”:[]”来查找未回答的问题总数。我没有得到任何计数。

我的要求是如果 User_Response 为空白或不可用,那么这应该是我未回答的问题

我在下面的查询中写了这个但没有得到它给我的计数 0

GET/activity_tracking/_search
{
  "size": 0,
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "user_response": "[ ]"
          }
        }
      ]
    }
  }
}

以下是映射详细信息

{
  "user_response": {
    "properties": {
      "qid": {
        "type": "Keyword",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      }
    }
  }
}

【问题讨论】:

    标签: elasticsearch elasticsearch-5


    【解决方案1】:

    在您的查询中使用exists function

    GET /_search
    {
      "query": {
        "bool": {
          "must_not": {
            "exists": {
              "field": "user_response.qid"
            }
          }
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2016-05-23
      • 2020-06-29
      • 2021-07-05
      • 1970-01-01
      • 2021-10-31
      • 1970-01-01
      • 2019-02-01
      • 2019-04-23
      • 2014-11-09
      相关资源
      最近更新 更多