How can I query a document that has no nested documents

Hello

Assuming I have a doc as follow

{
   id: 1,
  events: [
    type: "logged_in",
    date: "01/01/01",
    type: "logged_in",
    date: "02/01/01"
  ]
}

I would like to query all the users that have not logged in in the last 6 month.

I have started with something like this but I don't know how to have an equivalent of must_not has_child with nested docs. I really need nested docs since we're using percolator API

{
  "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "events",
            "query": {
              "bool": {
                "must": [
                  {
                    "range": {
                      "events.date": {
                        "gt": "now-6M"
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.