ElasticSearch:检查嵌套对象数组是否为空

时间:2016-11-22 16:49:28

标签: elasticsearch

如何获取没有字段中任何对象的所有文档?

我有以下映射:

"properties" : {
  "name": {
    "type": "text"
  },
  "nestedArray": {
    "type": "nested",
    "properties": {
      "prop1": {
        "type": "text"
      },
      "prop2": {
        "type": "text"
      }
    }
  }
}

我希望得到所有文件" nestedArray"是空的或不存在。

我使用的是elasticSearch 5.0

1 个答案:

答案 0 :(得分:5)

我认为exists query可以解决这个问题。请尝试以下查询

Option Explicit
Public ModelNumber As String
Public PreviousModel As String
Public FinalModelNumber As String
Sub TrackerInput()
Dim ModelDescription As String
Dim LastRowPrevious As String
LastRowPrevious = Worksheets("Model Tracker").Cells(Rows.Count, 1).End(xlUp).Row
If LastRowPrevious = 2 Then
    ModelNumber = 2
    PreviousModel = 1
Else
    PreviousModel = Cells(LastRowPrevious, 1).Value
    ModelNumber = PreviousModel + 1
End If
MsgBox ("You are creating a new model. Model number is " & ModelNumber)
End Sub