# Understanding doc\_values?

**URL:** https://discuss.elastic.co/t/understanding-doc-values/20114
**Category:** Elasticsearch
**Created:** [October 7, 2014, 1:11pm UTC](https://discuss.elastic.co/t/understanding-doc-values/20114 "2014-10-07T13:11:07Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Michael\_Gallego\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_gallego_2/32/1160_2.png) [@Michael\_Gallego\_2](https://discuss.elastic.co/u/Michael_Gallego_2)
#### Post date: [October 7, 2014, 1:11pm UTC](https://discuss.elastic.co/t/understanding-doc-values/20114/1 "2014-10-07T13:11:07Z")

</div>

Hi,

With the release of Elasticsearch 1.4, I discovered about doc\_values.  
However their use remains a bit obscure for me, and the documentation  
didn't help. As I understand it, it is mostly useful when performing  
aggregations, as it allows to reduce the memory amount of data loaded in  
memory. The doc recommends to specify not\_analyzed string as doc\_values, as  
well as values that are used for aggregations. But for instance, if my  
aggregations are about summing one value called "amount", does it make the  
"amount" integer/double as a good candidate for doc\_values, or is it only  
useful for properties that are space consuming?

In overall, if my use case is nearly only aggregations, should I go the way  
of setting all proeprties as doc\_values, except the analyzed strings?

Thanks!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0d204979-3403-4b07-9782-c4b52120f7e9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0d204979-3403-4b07-9782-c4b52120f7e9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [October 7, 2014, 2:23pm UTC](https://discuss.elastic.co/t/understanding-doc-values/20114/2 "2014-10-07T14:23:34Z")

</div>

Perhaps it is easier to talk about the downsides of doc\_values.

If you have slow disks, common when using low level VMs with shared disks,  
then retrieving your data will be much slower.

Also, you cannot filter on doc\_values fields, so it depends on your other  
use cases.

The amount field seems like a good candidate for doc\_values, but it depends  
on the downsides I highlighted above.

Cheers,

Ivan  
On Oct 7, 2014 6:11 AM, "Michaël Gallego" [michael@maestrooo.com](mailto:michael@maestrooo.com) wrote:

> Hi,
> 
> With the release of Elasticsearch 1.4, I discovered about doc\_values.  
> However their use remains a bit obscure for me, and the documentation  
> didn't help. As I understand it, it is mostly useful when performing  
> aggregations, as it allows to reduce the memory amount of data loaded in  
> memory. The doc recommends to specify not\_analyzed string as doc\_values, as  
> well as values that are used for aggregations. But for instance, if my  
> aggregations are about summing one value called "amount", does it make the  
> "amount" integer/double as a good candidate for doc\_values, or is it only  
> useful for properties that are space consuming?
> 
> In overall, if my use case is nearly only aggregations, should I go the  
> way of setting all proeprties as doc\_values, except the analyzed strings?
> 
> Thanks!
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/0d204979-3403-4b07-9782-c4b52120f7e9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0d204979-3403-4b07-9782-c4b52120f7e9%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/0d204979-3403-4b07-9782-c4b52120f7e9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/0d204979-3403-4b07-9782-c4b52120f7e9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQC9HouWNV8qmGaHXfR%2BuTbojybD%3DBYpT9woMadnMEHdaA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQC9HouWNV8qmGaHXfR%2BuTbojybD%3DBYpT9woMadnMEHdaA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Michael\_Gallego\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_gallego_2/32/1160_2.png) [@Michael\_Gallego\_2](https://discuss.elastic.co/u/Michael_Gallego_2)
#### Post date: [October 7, 2014, 3:19pm UTC](https://discuss.elastic.co/t/understanding-doc-values/20114/3 "2014-10-07T15:19:01Z")

</div>

I'm using a machine with fast SSD so it should be ok.

I'm not sure to udnerstand the downside "you cannot filter". What do you  
mean exactly? I tried to do a range filter on the value, and it indeed  
works!

Le mardi 7 octobre 2014 16:23:41 UTC+2, Ivan Brusic a écrit :

> Perhaps it is easier to talk about the downsides of doc\_values.
> 
> If you have slow disks, common when using low level VMs with shared disks,  
> then retrieving your data will be much slower.
> 
> Also, you cannot filter on doc\_values fields, so it depends on your other  
> use cases.
> 
> The amount field seems like a good candidate for doc\_values, but it  
> depends on the downsides I highlighted above.
> 
> Cheers,
> 
> Ivan  
> On Oct 7, 2014 6:11 AM, "Michaël Gallego" \<[mic...@maestrooo.com](mailto:mic...@maestrooo.com)  
> \<javascript:\>\> wrote:
> 
> > Hi,
> > 
> > With the release of Elasticsearch 1.4, I discovered about doc\_values.  
> > However their use remains a bit obscure for me, and the documentation  
> > didn't help. As I understand it, it is mostly useful when performing  
> > aggregations, as it allows to reduce the memory amount of data loaded in  
> > memory. The doc recommends to specify not\_analyzed string as doc\_values, as  
> > well as values that are used for aggregations. But for instance, if my  
> > aggregations are about summing one value called "amount", does it make the  
> > "amount" integer/double as a good candidate for doc\_values, or is it only  
> > useful for properties that are space consuming?
> > 
> > In overall, if my use case is nearly only aggregations, should I go the  
> > way of setting all proeprties as doc\_values, except the analyzed strings?
> > 
> > Thanks!
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/0d204979-3403-4b07-9782-c4b52120f7e9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0d204979-3403-4b07-9782-c4b52120f7e9%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/0d204979-3403-4b07-9782-c4b52120f7e9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/0d204979-3403-4b07-9782-c4b52120f7e9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/45292b0b-659e-418c-9eee-e6d3bff23abf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/45292b0b-659e-418c-9eee-e6d3bff23abf%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [October 7, 2014, 4:33pm UTC](https://discuss.elastic.co/t/understanding-doc-values/20114/4 "2014-10-07T16:33:45Z")

</div>

Hi Michaël,

Doc values just mean that field data will be computed at indexing time and  
stored on disk as opposed to computed at search time (which is the  
default). You can expect them to be slightly slower, but they have  
significant benefits too: their memory footprint is low, since most stuff  
is stored on disk. In particular this will help with other issues such as  
garbage collection. And since they are computed at indexing time, you don't  
have the same cold start issue that you can have with in-memory fielddata  
since recomputing them from the inverted index is both CPU and I/O  
intensive. We initially added doc values support in 1.0 but they got better  
and better with each release (especially in the forthcoming 1.4 release)  
and we are even thinking about making them the default in a future release  
(nothing decided yet, just thinking about it).

On Tue, Oct 7, 2014 at 5:19 PM, Michaël Gallego [michael@maestrooo.com](mailto:michael@maestrooo.com)  
wrote:

> I'm using a machine with fast SSD so it should be ok.
> 
> I'm not sure to udnerstand the downside "you cannot filter". What do you  
> mean exactly? I tried to do a range filter on the value, and it indeed  
> works!
> 
> Le mardi 7 octobre 2014 16:23:41 UTC+2, Ivan Brusic a écrit :
> 
> > Perhaps it is easier to talk about the downsides of doc\_values.
> > 
> > If you have slow disks, common when using low level VMs with shared  
> > disks, then retrieving your data will be much slower.
> > 
> > Also, you cannot filter on doc\_values fields, so it depends on your other  
> > use cases.
> > 
> > The amount field seems like a good candidate for doc\_values, but it  
> > depends on the downsides I highlighted above.
> > 
> > Cheers,
> > 
> > Ivan  
> > On Oct 7, 2014 6:11 AM, "Michaël Gallego" [mic...@maestrooo.com](mailto:mic...@maestrooo.com) wrote:
> > 
> > > Hi,
> > > 
> > > With the release of Elasticsearch 1.4, I discovered about doc\_values.  
> > > However their use remains a bit obscure for me, and the documentation  
> > > didn't help. As I understand it, it is mostly useful when performing  
> > > aggregations, as it allows to reduce the memory amount of data loaded in  
> > > memory. The doc recommends to specify not\_analyzed string as doc\_values, as  
> > > well as values that are used for aggregations. But for instance, if my  
> > > aggregations are about summing one value called "amount", does it make the  
> > > "amount" integer/double as a good candidate for doc\_values, or is it only  
> > > useful for properties that are space consuming?
> > > 
> > > In overall, if my use case is nearly only aggregations, should I go the  
> > > way of setting all proeprties as doc\_values, except the analyzed strings?
> > > 
> > > Thanks!
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > msgid/elasticsearch/0d204979-3403-4b07-9782-c4b52120f7e9%  
> > > [40googlegroups.com](http://40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/0d204979-3403-4b07-9782-c4b52120f7e9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/0d204979-3403-4b07-9782-c4b52120f7e9%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/45292b0b-659e-418c-9eee-e6d3bff23abf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/45292b0b-659e-418c-9eee-e6d3bff23abf%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/45292b0b-659e-418c-9eee-e6d3bff23abf%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/45292b0b-659e-418c-9eee-e6d3bff23abf%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6p5Z1k6U9LNNzeXXwM-Y%2BG%2BuNC%3DAYxbBOS1P%3DHZBN\_%3Dg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6p5Z1k6U9LNNzeXXwM-Y%2BG%2BuNC%3DAYxbBOS1P%3DHZBN_%3Dg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Michael\_Gallego\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_gallego_2/32/1160_2.png) [@Michael\_Gallego\_2](https://discuss.elastic.co/u/Michael_Gallego_2)
#### Post date: [October 9, 2014, 12:13pm UTC](https://discuss.elastic.co/t/understanding-doc-values/20114/5 "2014-10-09T12:13:20Z")

</div>

Hi again,

I've tried to create two types and fill them with data that mimic my own  
data, both with doc\_values for all non-analyzed string and numeric fields  
and without doc\_values. My additional question is to know if there are some  
overhead of mixing both doc\_values and non-doc values inside the same  
document, or it does not matter?

On my small machine and Elasticsearch 1.3, doc\_values is approximately 25%  
slower, if 1.4 makes this much better, I think I'll use them. However, the  
question is: how can I actually benchmark this? I didn't find any way to  
profile my aggregation queries to see things like memory consumption taken  
by one query. Without this information, how can I know some important  
metrics that would help me to choose between doc\_values and without  
doc\_values?

Thanks a lot!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/fee91837-0f29-4268-9391-c3581ce4b70b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fee91837-0f29-4268-9391-c3581ce4b70b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [October 9, 2014, 2:50pm UTC](https://discuss.elastic.co/t/understanding-doc-values/20114/6 "2014-10-09T14:50:51Z")

</div>

It is perfectly fine to have some fields that have doc values and other  
fields that don't.

Doc values are indeed faster in 1.4, especially on numeric fields. Using  
doc values doesn't change the memory usage of aggregations. However, it  
will change the memory usage for field data. It's a bit tricky to track  
today because doc values are not accounted in "fielddata" but in the  
"segments"[1] memory usage.

[1]

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Thu, Oct 9, 2014 at 2:13 PM, Michaël Gallego [michael@maestrooo.com](mailto:michael@maestrooo.com)  
wrote:

> Hi again,
> 
> I've tried to create two types and fill them with data that mimic my own  
> data, both with doc\_values for all non-analyzed string and numeric fields  
> and without doc\_values. My additional question is to know if there are some  
> overhead of mixing both doc\_values and non-doc values inside the same  
> document, or it does not matter?
> 
> On my small machine and Elasticsearch 1.3, doc\_values is approximately 25%  
> slower, if 1.4 makes this much better, I think I'll use them. However, the  
> question is: how can I actually benchmark this? I didn't find any way to  
> profile my aggregation queries to see things like memory consumption taken  
> by one query. Without this information, how can I know some important  
> metrics that would help me to choose between doc\_values and without  
> doc\_values?
> 
> Thanks a lot!
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/fee91837-0f29-4268-9391-c3581ce4b70b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fee91837-0f29-4268-9391-c3581ce4b70b%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/fee91837-0f29-4268-9391-c3581ce4b70b%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/fee91837-0f29-4268-9391-c3581ce4b70b%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5EM1bjd1FZgaGN\_NqR6xRSHOw35AFSwgq1q4JiGbEx%2BQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5EM1bjd1FZgaGN_NqR6xRSHOw35AFSwgq1q4JiGbEx%2BQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [July 6, 2017, 12:57am UTC](https://discuss.elastic.co/t/understanding-doc-values/20114/7 "2017-07-06T00:57:17Z")

</div>


