# How to get only the ‘\_source’ part of the hits. of the result

**URL:** <https://discuss.elastic.co/t/how-to-get-only-the-source-part-of-the-hits-of-the-result/233663>\
**Category:** Elasticsearch\
**Created:** [May 21, 2020, 4:49am UTC](https://discuss.elastic.co/t/how-to-get-only-the-source-part-of-the-hits-of-the-result/233663 "2020-05-21T04:49:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Muna](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@Muna](https://discuss.elastic.co/u/Muna)\
**Post date:** [May 21, 2020, 4:49am UTC](https://discuss.elastic.co/t/how-to-get-only-the-source-part-of-the-hits-of-the-result/233663/1 "2020-05-21T04:49:55Z")

</div>

is there any way to get only the '\_source' part of the result of the query .

Like from below result i want only the source part from the hits.

{  
"took" : 0,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"skipped" : 0,  
"failed" : 0  
},  
"hits" : {  
"total" : 1,  
"max\_score" : 1.0,  
"hits" : [  
{  
"\_index" : "abc",  
"\_type" : "abc",  
"\_id" : "13",  
"\_score" : 1.0,  
"\_source" : {  
"abc":125  
}  
}  
]  
}  
}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 21, 2020, 1:38pm UTC](https://discuss.elastic.co/t/how-to-get-only-the-source-part-of-the-hits-of-the-result/233663/2 "2020-05-21T13:38:54Z")

</div>

See [https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#common-options-response-filtering](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#common-options-response-filtering)

---

<div class="post-metadata">

**Author:** ![Muna](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@Muna](https://discuss.elastic.co/u/Muna)\
**Post date:** [May 22, 2020, 9:47am UTC](https://discuss.elastic.co/t/how-to-get-only-the-source-part-of-the-hits-of-the-result/233663/3 "2020-05-22T09:47:35Z")

</div>

Hi,  
tried using below

GET abcded/\_search?filter\_path=hits.hits.\_source

but once i get respone i need to loop through all to get "\_source".

i want to get data directly and use

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 22, 2020, 10:19am UTC](https://discuss.elastic.co/t/how-to-get-only-the-source-part-of-the-hits-of-the-result/233663/4 "2020-05-22T10:19:02Z")

</div>

As you might have more than one hit, it must be an array.  
You need to do this transformation in your application.

If you know the id of the document (and you are not searching) then you can do it.

---

<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 19, 2020, 10:19am UTC](https://discuss.elastic.co/t/how-to-get-only-the-source-part-of-the-hits-of-the-result/233663/5 "2020-06-19T10:19:06Z")

</div>

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