# How can I query a document that has no nested documents

**URL:** <https://discuss.elastic.co/t/how-can-i-query-a-document-that-has-no-nested-documents/99154>\
**Category:** Elasticsearch\
**Created:** [September 1, 2017, 5:00pm UTC](https://discuss.elastic.co/t/how-can-i-query-a-document-that-has-no-nested-documents/99154 "2017-09-01T17:00:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christophe\_Verbinne1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christophe_verbinne1/32/21760_2.png) [@Christophe\_Verbinne1](https://discuss.elastic.co/u/Christophe_Verbinne1)\
**Post date:** [September 1, 2017, 5:00pm UTC](https://discuss.elastic.co/t/how-can-i-query-a-document-that-has-no-nested-documents/99154/1 "2017-09-01T17:00:37Z")

</div>

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"
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 29, 2017, 5:01pm UTC](https://discuss.elastic.co/t/how-can-i-query-a-document-that-has-no-nested-documents/99154/2 "2017-09-29T17:01:23Z")

</div>

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