首页 > 解决方案 > 弹性查询 DSL 不会在 JSON 字段中搜索方括号

问题描述

我正在尝试在名为 "print_response_message" 的列之一中查询具有 json 响应的索引。

返回的该列的示例值如下 2 条记录所示。

print_response_message

myTestResponse string is : {
   "orderPrintResponses" : [ 
    {
    "status" : "SUCCESS",
    "responseCode" : "200",
    "responseMessage" : "Documents printed",
    "groupId" : "CONFIRMATION",
    "orderItemResponses" : [ {
      "status" : "SUCCESS",
      "responseCode" : "200",
      "responseMessage" : "Documents printed successfully",
      "printDocumentMappingArray" : [ {
        "pID" : "01.01",
        "documentNumbers" : [ ]
      }]
    } ]
  } ]
}

myTestResponse string is : {
   "orderPrintResponses" : [ 
    {
    "status" : "SUCCESS",
    "responseCode" : "200",
    "responseMessage" : "Documents printed",
    "groupId" : "CONFIRMATION",
    "orderItemResponses" : [ {
      "status" : "SUCCESS",
      "responseCode" : "200",
      "responseMessage" : "Documents printed successfully",
      "printDocumentMappingArray" : [ {
        "pID" : "01.01",
        "documentNumbers" : [ "123456789" ]
      }]
    } ]
  } ]
}

我只想检索文档编号数组为空的响应,在我上面分享的示例中,第一个是因为它具有 "documentNumbers" : [ ] 。

我尝试了几种方法,包括匹配器、术语,但都没有奏效。

有人可以帮我解决这个问题吗?非常感谢您的帮助。再次感谢

我什至尝试转义 [] , : 等,但它们都没有奏效。它不断检索第二个值而不是第一个值。我几乎花了 2 天时间,但无法获得正确的查询来执行此操作。

我希望 print_response_message 的 json 包含“documentNumbers”:[]

标签: elasticsearchelastic-stackquerydslkibana-6

解决方案


推荐阅读