# Extract the values of a field from elasticsearch

**URL:** <https://discuss.elastic.co/t/extract-the-values-of-a-field-from-elasticsearch/196522>\
**Category:** Elasticsearch\
**Created:** [August 23, 2019, 12:54pm UTC](https://discuss.elastic.co/t/extract-the-values-of-a-field-from-elasticsearch/196522 "2019-08-23T12:54:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![decodeit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/decodeit/32/46023_2.png) [@decodeit](https://discuss.elastic.co/u/decodeit)\
**Post date:** [August 23, 2019, 12:54pm UTC](https://discuss.elastic.co/t/extract-the-values-of-a-field-from-elasticsearch/196522/1 "2019-08-23T12:54:05Z")

</div>

I have a field name across 100 documents. I want to extract the values that the name field has across all documents without returning duplicate.  
how can I achieve that.  
Thanks

---

<div class="post-metadata">

**Author:** ![linkerc](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@linkerc](https://discuss.elastic.co/u/linkerc)\
**Post date:** [August 23, 2019, 11:14pm UTC](https://discuss.elastic.co/t/extract-the-values-of-a-field-from-elasticsearch/196522/2 "2019-08-23T23:14:19Z")

</div>

ex:  
if the field is called "xyz", aggregate using below payload assuming xyz is string.  
If it's number, then just remove ".keyword".  
"label" is just a name you give for reference when you get the payload back.  
This will give you all unique "xyz" values in your index.

```
{
"aggs": {
    "label": {
      "terms": {
        "field": "xyz.keyword",
        "size": 100
      }
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![decodeit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/decodeit/32/46023_2.png) [@decodeit](https://discuss.elastic.co/u/decodeit)\
**Post date:** [August 28, 2019, 3:23pm UTC](https://discuss.elastic.co/t/extract-the-values-of-a-field-from-elasticsearch/196522/3 "2019-08-28T15:23:30Z")

</div>

This is giving me only 10 of the values of the fields.  
so the field is this way,  
"field":{  
"a":,  
"b":  
}

I am trying to get all values of a and b

---

<div class="post-metadata">

**Author:** ![linkerc](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@linkerc](https://discuss.elastic.co/u/linkerc)\
**Post date:** [August 29, 2019, 7:20pm UTC](https://discuss.elastic.co/t/extract-the-values-of-a-field-from-elasticsearch/196522/4 "2019-08-29T19:20:18Z")

</div>

"size" defaults to 10.

---

<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 26, 2019, 7:20pm UTC](https://discuss.elastic.co/t/extract-the-values-of-a-field-from-elasticsearch/196522/5 "2019-09-26T19:20:23Z")

</div>

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