# how is Answer document related to tags in the Question document in Elasticsearch documentation example

**URL:** <https://discuss.elastic.co/t/how-is-answer-document-related-to-tags-in-the-question-document-in-elasticsearch-documentation-example/368930>\
**Category:** Elasticsearch\
**Created:** [October 16, 2024, 4:05pm UTC](https://discuss.elastic.co/t/how-is-answer-document-related-to-tags-in-the-question-document-in-elasticsearch-documentation-example/368930 "2024-10-16T16:05:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yulinxp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yulinxp/32/138393_2.png) [@yulinxp](https://discuss.elastic.co/u/yulinxp)\
**Post date:** [October 16, 2024, 4:05pm UTC](https://discuss.elastic.co/t/how-is-answer-document-related-to-tags-in-the-question-document-in-elasticsearch-documentation-example/368930/1 "2024-10-16T16:05:19Z")

</div>

I am reading [Elasticsearch documentation 8.15](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-children-aggregation.html). Parent 1 has tags array.

```auto
  PUT child_example/_doc/1
    {
      "join": {
        "name": "question"
      },
      "body": "<p>I have Windows 2003 server and i bought a new Windows 2008 server...",
      "title": "Whats the best way to file transfer my site from server to a newer one?",
      "tags": [
        "windows-server-2003",
        "windows-server-2008",
        "file-transfer"
      ]
    }

```

Here is one child.

```auto
 PUT child_example/_doc/2?routing=1
    {
      "join": {
        "name": "answer",
        "parent": "1"
      },
      "owner": {
        "location": "Norfolk, United Kingdom",
        "display_name": "Sam",
        "id": 48
      },
      "body": "<p>Unfortunately you're pretty much limited to FTP...",
      "creation_date": "2009-05-04T13:45:37.030"
    }

```

This is the query to returns the top question tags and per tag the top answer owners.

```auto
 POST child_example/_search?size=0
    {
      "aggs": {
        "top-tags": {
          "terms": {
            "field": "tags.keyword",
            "size": 10
          },
          "aggs": {
            "to-answers": {
              "children": {
                "type" : "answer" 
              },
              "aggs": {
                "top-names": {
                  "terms": {
                    "field": "owner.display_name.keyword",
                    "size": 10
                  }
                }
              }
            }
          }
        }
      }
    }

```

But how is Answer document related to **tags** in the Question document?
