# Select only one element inside an object

**URL:** <https://discuss.elastic.co/t/select-only-one-element-inside-an-object/305296>\
**Category:** Elasticsearch\
**Created:** [May 20, 2022, 2:01pm UTC](https://discuss.elastic.co/t/select-only-one-element-inside-an-object/305296 "2022-05-20T14:01:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmoreram](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mmoreram/32/87391_2.png) [@mmoreram](https://discuss.elastic.co/u/mmoreram)\
**Post date:** [May 20, 2022, 2:01pm UTC](https://discuss.elastic.co/t/select-only-one-element-inside-an-object/305296/1 "2022-05-20T14:01:58Z")

</div>

Let's say I have an object with N fields, and I only want to return one of them. How can I do that? Can I exclude the whole object and then include one of their childs?

Thanks.

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [May 20, 2022, 2:42pm UTC](https://discuss.elastic.co/t/select-only-one-element-inside-an-object/305296/2 "2022-05-20T14:42:19Z")

</div>

Hi!!  
You says something like that:  
Doc

```auto
  "name" : "xpto",
          "address" : {
            "number" : 15,
            "street" : "street b"
          }

```

Query

```auto
GET idx_teste_nested/_search
{
  "_source": ["address.number"], 
  "query": {
    "match_all": {}
  }
}

```

Response (only address.number)

```auto
 {
        "_index" : "idx_teste_nested",
        "_type" : "_doc",
        "_id" : "WhTFioABHFVsAeBmboN8",
        "_score" : 1.0,
        "_source" : {
          "address" : {
            "number" : 15
          }
        }
      }

```

---

<div class="post-metadata">

**Author:** ![mmoreram](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mmoreram/32/87391_2.png) [@mmoreram](https://discuss.elastic.co/u/mmoreram)\
**Post date:** [May 20, 2022, 2:46pm UTC](https://discuss.elastic.co/t/select-only-one-element-inside-an-object/305296/3 "2022-05-20T14:46:57Z")

</div>

Well, I would like to return all other results as well, like `name` or other fields (I start with a wildcard)

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [May 20, 2022, 3:09pm UTC](https://discuss.elastic.co/t/select-only-one-element-inside-an-object/305296/4 "2022-05-20T15:09:43Z")

</div>

give a example for explain better

---

<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:** [June 17, 2022, 3:10pm UTC](https://discuss.elastic.co/t/select-only-one-element-inside-an-object/305296/5 "2022-06-17T15:10:41Z")

</div>

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