# Fetching one field from every inner hit (docvalue\_field VS source filtering)

**URL:** <https://discuss.elastic.co/t/fetching-one-field-from-every-inner-hit-docvalue-field-vs-source-filtering/201024>\
**Category:** Elasticsearch\
**Created:** [September 25, 2019, 12:11pm UTC](https://discuss.elastic.co/t/fetching-one-field-from-every-inner-hit-docvalue-field-vs-source-filtering/201024 "2019-09-25T12:11:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![menshenin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/menshenin/32/52975_2.png) [@menshenin](https://discuss.elastic.co/u/menshenin)\
**Post date:** [September 25, 2019, 12:11pm UTC](https://discuss.elastic.co/t/fetching-one-field-from-every-inner-hit-docvalue-field-vs-source-filtering/201024/1 "2019-09-25T12:11:36Z")

</div>

Hi,

I have an index that stores complex documents with multiple nested fields, but as a query result I always need only one field from the nested document (some uid).  
How should I do: just turn off the \_source and take the values using docvalue\_field, or storing \_source and get values from it using source filtering?  
Which of the two options is better?  
I hope for your help.

---

<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:** [October 23, 2019, 12:11pm UTC](https://discuss.elastic.co/t/fetching-one-field-from-every-inner-hit-docvalue-field-vs-source-filtering/201024/2 "2019-10-23T12:11:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Julie\_Tibshirani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/julie_tibshirani/32/55628_2.png) [@Julie\_Tibshirani](https://discuss.elastic.co/u/Julie_Tibshirani)\
**Post date:** [June 2, 2020, 9:06pm UTC](https://discuss.elastic.co/t/fetching-one-field-from-every-inner-hit-docvalue-field-vs-source-filtering/201024/3 "2020-06-02T21:06:32Z")

</div>

This is coming quite late, but I wanted to link to a new reference page we're adding that gives some guidance on when to use source filtering vs. `docvalue_fields`: [Add a reference on returning fields during a search. by jtibshirani · Pull Request #57500 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/pull/57500).

> How should I do: just turn off the \_source and take the values using docvalue\_field, or storing \_source and get values from it using source filtering?

If you really only need one value in the response, and it's available from doc values, then it could be more efficient to load it using `docvalue_fields` instead of source filtering. If you don't use the \_source elsewhere, then you could disable it to save space. It's important to know that certain features will no longer work when the \_source isn't stored, such as reindex, source-only snapshots, and highlighting (in some cases).
