# Get /myindex/\_search - return just 1 or 2 Fields not the whole Bucket or Document

**URL:** <https://discuss.elastic.co/t/get-myindex-search-return-just-1-or-2-fields-not-the-whole-bucket-or-document/206632>\
**Category:** Elasticsearch\
**Created:** [November 5, 2019, 3:18pm UTC](https://discuss.elastic.co/t/get-myindex-search-return-just-1-or-2-fields-not-the-whole-bucket-or-document/206632 "2019-11-05T15:18:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Datakids](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/datakids/32/39622_2.png) [@Datakids](https://discuss.elastic.co/u/Datakids)\
**Post date:** [November 5, 2019, 3:18pm UTC](https://discuss.elastic.co/t/get-myindex-search-return-just-1-or-2-fields-not-the-whole-bucket-or-document/206632/1 "2019-11-05T15:18:47Z")

</div>

Hi all,  
im stuck in how to use the search in right way.

What I did to get all out of my Index:

```
PUT /myindex/_settings
{ "index" : { "max_result_window" : 100000 } }

```

Now with following GET Request I can show all the index entries = Check

```
GET /myindex/_search
{
  "size": 50000,
  "aggs": {
    "allEntries": {
      "terms": {
        "field": "Nr.keyword"
      }
    }
  }
}

```

The result is as json with more then 3milion lines...wow...ok

What I want is a result that shrinked down to just show me the 2 fields :  
"Nr.keyword"  
"Nr\_alternate.keyword"  
At least around 15000 entries  
However, I do not want all the other fields around so how can I get just 1 or 2 fields as json result?

Thanks and Brgds

---

<div class="post-metadata">

**Author:** ![st3inbeiss](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/st3inbeiss/32/55332_2.png) [@st3inbeiss](https://discuss.elastic.co/u/st3inbeiss)\
**Post date:** [November 5, 2019, 3:34pm UTC](https://discuss.elastic.co/t/get-myindex-search-return-just-1-or-2-fields-not-the-whole-bucket-or-document/206632/2 "2019-11-05T15:34:02Z")

</div>

Hi!

Of course you can get just 1 or 2 fields in the result! You can use a source-filter as described [here.](https://stackoverflow.com/questions/9605292/make-elasticsearch-only-return-certain-fields)

Your query then will look something like this:

```auto
GET /myindex/_search
{
  "size": 50000,
  "aggs": {
    "allEntries": {
      "terms": {
        "field": "Nr.keyword"
      }
    }
  },"_source": ["Nr.keyword", "Nr_alternate.keyword"]
}

```

or whichever fields you want to have returned. Just put them in the array...

---

<div class="post-metadata">

**Author:** ![Datakids](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/datakids/32/39622_2.png) [@Datakids](https://discuss.elastic.co/u/Datakids)\
**Post date:** [November 5, 2019, 3:55pm UTC](https://discuss.elastic.co/t/get-myindex-search-return-just-1-or-2-fields-not-the-whole-bucket-or-document/206632/3 "2019-11-05T15:55:42Z")

</div>

Oh man you safed my life 🙂  
Thanks for your fast response...

---

<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 3, 2019, 3:55pm UTC](https://discuss.elastic.co/t/get-myindex-search-return-just-1-or-2-fields-not-the-whole-bucket-or-document/206632/4 "2019-12-03T15:55:46Z")

</div>

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