# When to use docvalue\_fields

**URL:** <https://discuss.elastic.co/t/when-to-use-docvalue-fields/103144>\
**Category:** Elasticsearch\
**Created:** [October 8, 2017, 9:41am UTC](https://discuss.elastic.co/t/when-to-use-docvalue-fields/103144 "2017-10-08T09:41:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaharmor](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@shaharmor](https://discuss.elastic.co/u/shaharmor)\
**Post date:** [October 8, 2017, 9:41am UTC](https://discuss.elastic.co/t/when-to-use-docvalue-fields/103144/1 "2017-10-08T09:41:33Z")

</div>

Hi,

I see that Kibana is using `docvalue_fields` all the time for the `@timestamp` field.

When is using `docvalue_fields` vs `stored_fields` better? Is there a general use case? Aren't all fields fetched using doc\_values anyway?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 9, 2017, 12:35am UTC](https://discuss.elastic.co/t/when-to-use-docvalue-fields/103144/2 "2017-10-09T00:35:23Z")

</div>

I'm not sure they are supposed to be interchangeable.

[Fields | Elasticsearch Reference [5.6] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-stored-fields.html) states;

> The stored\_fields parameter is about fields that are explicitly marked as stored in the mapping, which is off by default and generally not recommended.

---

<div class="post-metadata">

**Author:** ![shaharmor](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@shaharmor](https://discuss.elastic.co/u/shaharmor)\
**Post date:** [October 9, 2017, 7:18am UTC](https://discuss.elastic.co/t/when-to-use-docvalue-fields/103144/3 "2017-10-09T07:18:44Z")

</div>

And what about `docvalue_fields`?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [October 9, 2017, 7:29am UTC](https://discuss.elastic.co/t/when-to-use-docvalue-fields/103144/4 "2017-10-09T07:29:51Z")

</div>

Can you elaborate?

---

<div class="post-metadata">

**Author:** ![shaharmor](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@shaharmor](https://discuss.elastic.co/u/shaharmor)\
**Post date:** [October 9, 2017, 7:30am UTC](https://discuss.elastic.co/t/when-to-use-docvalue-fields/103144/5 "2017-10-09T07:30:58Z")

</div>

Sure.

There is this `docvalue_fields` option for the Search API: [https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-docvalue-fields.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-docvalue-fields.html)

When should I use that?  
My index has only `keyword` fields and all have `doc_values` enabled for them, so what does this option do in the Search API?

---

<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:** [November 6, 2017, 7:31am UTC](https://discuss.elastic.co/t/when-to-use-docvalue-fields/103144/6 "2017-11-06T07:31:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [September 27, 2019, 5:40pm UTC](https://discuss.elastic.co/t/when-to-use-docvalue-fields/103144/7 "2019-09-27T17:40:03Z")

</div>

Kibana uses docvalue\_fields for `date` fields to get the value back in a consistent format. If Kibana used the value from \_source, then parsing the date would be almost impossible because the formats would vary wildly from installation to installation.
