# Search query for document with nested objects

**URL:** <https://discuss.elastic.co/t/search-query-for-document-with-nested-objects/107954>\
**Category:** Elasticsearch\
**Created:** [November 16, 2017, 2:29pm UTC](https://discuss.elastic.co/t/search-query-for-document-with-nested-objects/107954 "2017-11-16T14:29:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![glkhv-vldmr](https://avatars.discourse-cdn.com/v4/letter/g/58f4c7/32.png) [@glkhv-vldmr](https://discuss.elastic.co/u/glkhv-vldmr)\
**Post date:** [November 16, 2017, 2:29pm UTC](https://discuss.elastic.co/t/search-query-for-document-with-nested-objects/107954/1 "2017-11-16T14:29:49Z")

</div>

Hi!  
Help please form an index structure and / or write a search query

i have about such mapping

```
{
    "doc": {
        "mappings": {
            "base": {
                "properties": {
                     ...,

                    "messages": {
                        "type": "nested",
                        "properties": {
                            ...,
                            "author_id": {
                                "type": "string",
                                "index": "not_analyzed"
                            }
                            ...
                        }
                    }
                }
            }
        }
    }

```

I want write query, that returns me all documents if **any** of messages.author\_id matches the requested

my query:

```
{
  "query": {
    "nested": {
      "path": "messages",
      "query": {
        "match": {
          "messages.author_id": "7781bb00-312f-4db1-93cf-e8d178517762"
        }
      }
    }
  }
}

```

but this query returns documents with **ALL**"messages.author\_id": "7781bb00-312f-4db1-93cf-e8d178517762" but i want **any** of "messages.author\_id": "7781bb00-312f-4db1-93cf-e8d178517762"

How can i do?

---

<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:** [December 14, 2017, 2:29pm UTC](https://discuss.elastic.co/t/search-query-for-document-with-nested-objects/107954/2 "2017-12-14T14:29:55Z")

</div>

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