Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch Elasticsearch:查找包含数组字段的所有文档,数组字段可以为空或非空_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch - Fatal编程技术网 elasticsearch Elasticsearch:查找包含数组字段的所有文档,数组字段可以为空或非空,elasticsearch,elasticsearch" /> elasticsearch Elasticsearch:查找包含数组字段的所有文档,数组字段可以为空或非空,elasticsearch,elasticsearch" />

elasticsearch Elasticsearch:查找包含数组字段的所有文档,数组字段可以为空或非空

elasticsearch Elasticsearch:查找包含数组字段的所有文档,数组字段可以为空或非空,elasticsearch,elasticsearch,请在我的elasticsearch 7.7.0中找到以下示例文档。如何构建优化查询以获取包含数组字段的所有文档。如您所见,有些文档没有此字段,有些文档的值为null。需要获取此字段为空数组或数组中有某些项的文档。需要删除缺少字段或字段为空的文档 示例文档: [ { "_index" : "test", "_type" : "_doc", "_id"

请在我的elasticsearch 7.7.0中找到以下示例文档。如何构建优化查询以获取包含数组字段的所有文档。如您所见,有些文档没有此字段,有些文档的值为null。需要获取此字段为空数组或数组中有某些项的文档。需要删除缺少字段或字段为空的文档

示例文档:
[
     {
       "_index" : "test",
       "_type" : "_doc",
       "_id" : "5",
       "_score" : 1.0,
       "_source" : {
         "severity" : 5,
         "problemInvestigations" : [
           {
             "Request ID01" : "PBI000000000001",
             "Request Description01" : "PBI000000000001: Test 1"
           },
           {
             "Request Description02" : "PBI000000000002: Test 2",
             "Request ID02" : "PBI000000000002"
           },
           {
             "Request ID03" : "PBI000000000003",
             "Request Description03" : "PBI000000000003: Test 3"
           },
           {
             "Request ID01" : "PBI000000000016",
             "Request Description01" : "PBI000000000016: Test 3"
           }
         ],
         "Summary*" : "Bitlocker encryption log in issue",
         "tenantId" : "tenant",
         "Operational Categorization Tier 2" : "Software",
         "Incident Number" : "PDINC0003203145"
       }
     },
     {
       "_index" : "test",
       "_type" : "_doc",
       "_id" : "92",
       "_score" : 1.0,
       "_source" : {
         "severity" : 5,
         "problemInvestigations" : [
           {
             "Request ID01" : "PBI000000000016",
             "Request Description01" : "PBI000000000016: Test 3"
           }
         ],
         "Summary*" : "Bitlocker encryption log in issue",
         "tenantId" : "tenant",
         "Operational Categorization Tier 2" : "Software",
         "Incident Number" : "PDINC0003203145"
       }
     },
     {
       "_index" : "test",
       "_type" : "_doc",
       "_id" : "107",
       "_score" : 1.0,
       "_source" : {
         "severity" : 5,
         "problemInvestigations" : [ ],
         "Summary*" : "Bitlocker encryption log in issue",
         "tenantId" : "tenant",
         "Operational Categorization Tier 2" : "Software",
         "Incident Number" : "PDINC0003203145"
       }
     },
     {
       "_index" : "test",
       "_type" : "_doc",
       "_id" : "134",
       "_score" : 1.0,
       "_source" : {
         "severity" : 5,
         "problemInvestigations" : null,
         "Summary*" : "Bitlocker encryption log in issue",
         "tenantId" : "tenant",
         "Operational Categorization Tier 2" : "Software",
         "Incident Number" : "PDINC0003203145"
       }
     },
     {
       "_index" : "test",
       "_type" : "_doc",
       "_id" : "135",
       "_score" : 1.0,
       "_source" : {
         "severity" : 5,
         "Summary*" : "Bitlocker encryption log in issue",
         "tenantId" : "tenant",
         "Operational Categorization Tier 2" : "Software",
         "Incident Number" : "PDINC0003203145"
       }
     }
   ]
我正在寻找以下文件作为结果的一部分:

预期结果:
[
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "5",
        "_score" : 1.0,
        "_source" : {
          "severity" : 5,
          "problemInvestigations" : [
            {
              "Request ID01" : "PBI000000000001",
              "Request Description01" : "PBI000000000001: Test 1"
            },
            {
              "Request Description02" : "PBI000000000002: Test 2",
              "Request ID02" : "PBI000000000002"
            },
            {
              "Request ID03" : "PBI000000000003",
              "Request Description03" : "PBI000000000003: Test 3"
            },
            {
              "Request ID01" : "PBI000000000016",
              "Request Description01" : "PBI000000000016: Test 3"
            }
          ],
          "Summary*" : "Bitlocker encryption log in issue",
          "tenantId" : "tenant",
          "Operational Categorization Tier 2" : "Software",
          "Incident Number" : "PDINC0003203145"
        }
      },
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "92",
        "_score" : 1.0,
        "_source" : {
          "severity" : 5,
          "problemInvestigations" : [
            {
              "Request ID01" : "PBI000000000016",
              "Request Description01" : "PBI000000000016: Test 3"
            }
          ],
          "Summary*" : "Bitlocker encryption log in issue",
          "tenantId" : "tenant",
          "Operational Categorization Tier 2" : "Software",
          "Incident Number" : "PDINC0003203145"
        }
      },
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "107",
        "_score" : 1.0,
        "_source" : {
          "severity" : 5,
          "problemInvestigations" : [ ],
          "Summary*" : "Bitlocker encryption log in issue",
          "tenantId" : "tenant",
          "Operational Categorization Tier 2" : "Software",
          "Incident Number" : "PDINC0003203145"
        }
      }
]
我在下面运行查询,但没有得到任何文档。请建议

GET test/_search
{
  "query": {
    "bool": {
      "filter": {
        "script": {
          "script": """
            if (doc.containsKey('problemInvestigations') && doc['problemInvestigations'].values.length >= 0) {
              return true;
            }else{
              return false;
            }
          """
        }
      }
    }
  }
}