# How to select only one field from an array?

**URL:** <https://discuss.elastic.co/t/how-to-select-only-one-field-from-an-array/246275>\
**Category:** Elasticsearch\
**Created:** [August 25, 2020, 11:54am UTC](https://discuss.elastic.co/t/how-to-select-only-one-field-from-an-array/246275 "2020-08-25T11:54:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mayank\_Ruhella](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mayank_ruhella/32/71455_2.png) [@Mayank\_Ruhella](https://discuss.elastic.co/u/Mayank_Ruhella)\
**Post date:** [August 25, 2020, 11:54am UTC](https://discuss.elastic.co/t/how-to-select-only-one-field-from-an-array/246275/1 "2020-08-25T11:54:43Z")

</div>

**Output**

```auto
"_source" : {
          "mortgagesObj" : [
            {
              "regDate" : "04/06/2020"
            },
            {
              "regDate" : "01/10/2013"
            },
            {
              "regDate" : "15/09/2016"
            },
            {
              "regDate" : "02/10/2013"
            },
            {
              "regDate" : "01/10/2013"
            },
            {
              "regDate" : "14/12/2015"
            },
            {
              "regDate" : "15/09/2016"
            },
            {
              "regDate" : "15/06/2020"
            },
            {
              "regDate" : "09/06/2020"
            },
            {
              "regDate" : "07/10/2013"
            },
            {
              "regDate" : "05/06/2020"
            },
            {
              "regDate" : "09/06/2020"
            }
          ]
}

```

**Query**

```auto
"query": {
    "nested": {
      "path": "mortgagesObj",
      "query": {
        "bool": {
          "must": [
            {
              "range": {
                "mortgagesObj.regDate": {
                  "gte": "01/01/2020",
                  "lte": "24/08/2020",
                  "format": "dd/MM/yyyy||yyyy"
                }
              }
            }
          ]
        }
      }
    }
  }

```

**Question**  
Question 1 : I want to select field only between '01/01/2020' and '24/08/2020', but I am getting all the fields inside that array which I do not want.

Question 2 : Is it possible to count number of fields inside an array when I getting the output?

---

<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 22, 2020, 11:54am UTC](https://discuss.elastic.co/t/how-to-select-only-one-field-from-an-array/246275/2 "2020-09-22T11:54:47Z")

</div>

Closed on September 22, 2020, 11:54am UTC

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