# "docs\_value" doesn't seem to take affect

**URL:** <https://discuss.elastic.co/t/docs-value-doesnt-seem-to-take-affect/24958>\
**Category:** Elasticsearch\
**Created:** [July 6, 2015, 3:40pm UTC](https://discuss.elastic.co/t/docs-value-doesnt-seem-to-take-affect/24958 "2015-07-06T15:40:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![raz](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@raz](https://discuss.elastic.co/u/raz)\
**Post date:** [July 6, 2015, 3:40pm UTC](https://discuss.elastic.co/t/docs-value-doesnt-seem-to-take-affect/24958/1 "2015-07-06T15:40:07Z")

</div>

We use ES 1.4.4 . We configured some fields to be "docs\_value", however we still see that the field data cache of these fields is growing when we check it with :

/\_stats/fielddata?fields=\*&pretty

So for instance I add in the template this definition:  
"itemUrl": {  
"index": "not\_analyzed",  
"doc\_values": true,  
"type": "string"  
}

and I see in the stats:  
"events\_54c06841-02e5-4e07-9908-da32b97be02d\_2015-07-04" : {  
"primaries" : {  
"fielddata" : {  
"memory\_size\_in\_bytes" : 3455416,  
"evictions" : 0,  
"fields" : {  
"itemUrl" : {  
"memory\_size\_in\_bytes" : 2589088  
},  
"itemId" : {  
"memory\_size\_in\_bytes" : 633912  
},  
"itemMimeMetaType" : {  
"memory\_size\_in\_bytes" : 1848  
},  
"clientId" : {  
"memory\_size\_in\_bytes" : 222032  
},  
"itemLabel" : {  
"memory\_size\_in\_bytes" : 8536  
}  
}  
}  
}

As you can see, "itemUrl" is present. Am I doing something wrong here ?

---

<div class="post-metadata">

**Author:** ![Harlin\_ES](https://avatars.discourse-cdn.com/v4/letter/h/977dab/32.png) [@Harlin\_ES](https://discuss.elastic.co/u/Harlin_ES)\
**Post date:** [July 6, 2015, 4:04pm UTC](https://discuss.elastic.co/t/docs-value-doesnt-seem-to-take-affect/24958/2 "2015-07-06T16:04:00Z")

</div>

You could try adding the clause:

"fielddata": { "format": "doc\_values"},

to your field mapping. This is another way to enable doc values

---

<div class="post-metadata">

**Author:** ![raz](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@raz](https://discuss.elastic.co/u/raz)\
**Post date:** [July 7, 2015, 6:45am UTC](https://discuss.elastic.co/t/docs-value-doesnt-seem-to-take-affect/24958/3 "2015-07-07T06:45:36Z")

</div>

Hi Harlin,

Thanks for the quick answer. I have two questions:

1. Is my method wrong in describing the "docs\_value : true" ?
2. How is your suggested configurations fits in the index mapping ? can you please provide example ?

Thanks !!

---

<div class="post-metadata">

**Author:** ![Harlin\_ES](https://avatars.discourse-cdn.com/v4/letter/h/977dab/32.png) [@Harlin\_ES](https://discuss.elastic.co/u/Harlin_ES)\
**Post date:** [July 7, 2015, 4:08pm UTC](https://discuss.elastic.co/t/docs-value-doesnt-seem-to-take-affect/24958/4 "2015-07-07T16:08:04Z")

</div>

Hey Raz,

1. No, your method is not wrong using "doc\_values: true"

2. Here's an example:

Also, when you changed your mapping, did you re-index your data after applying the mapping? In order for doc values to take effect, every doc that fits the mapping has to be indexed after the mapping has been applied.

---

<div class="post-metadata">

**Author:** ![raz](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@raz](https://discuss.elastic.co/u/raz)\
**Post date:** [July 7, 2015, 7:19pm UTC](https://discuss.elastic.co/t/docs-value-doesnt-seem-to-take-affect/24958/5 "2015-07-07T19:19:35Z")

</div>

Hi Harlin.  
Thank you for the example 😄  
No. I didn't re-index my data. I'm using daily indices. So from what I understood from the docs, fields that will be indexed after applying the mapping, will be stored as doc\_values on the disk.  
I don't mind that fields that were indexed before the change are not stored as doc\_values on the disk (because in time everything will become doc\_values because I will archive the old indices).  
I also read that after segment merge, the changes will take effect on old indices.  
Should I re-index anyway ?

---

<div class="post-metadata">

**Author:** ![Harlin\_ES](https://avatars.discourse-cdn.com/v4/letter/h/977dab/32.png) [@Harlin\_ES](https://discuss.elastic.co/u/Harlin_ES)\
**Post date:** [July 7, 2015, 8:57pm UTC](https://discuss.elastic.co/t/docs-value-doesnt-seem-to-take-affect/24958/6 "2015-07-07T20:57:57Z")

</div>

> So from what I understood from the docs, fields that will be indexed  
> after applying the mapping, will be stored as doc\_values on the disk.

This is definitely true, since you are using daily indices, your new indices should be using doc values

> I also read that after segment merge, the changes will take effect on old indices.

You may be right about this, but I wouldn't trust it.

I wouldn't re index if you don't have to, though it is the only way to grantee that all of your indices will use doc values.

---

<div class="post-metadata">

**Author:** ![raz](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@raz](https://discuss.elastic.co/u/raz)\
**Post date:** [July 8, 2015, 5:24am UTC](https://discuss.elastic.co/t/docs-value-doesnt-seem-to-take-affect/24958/7 "2015-07-08T05:24:16Z")

</div>

Thank you for the comprehensive response !  
Another small question. Can I define the doc\_values in dynamic\_template if I want that all the fields from certain type will use it ?  
If for instance I define:

{  
"my\_type" : {  
"dynamic\_templates" : [  
{  
"template\_1" : {  
"match" : "\*",  
"match\_mapping\_type" : "string",  
"mapping" : {  
"type" : "string",  
"doc\_values" :true,  
"fielddata: {  
"format" : "doc\_values"  
}  
}  
}  
}  
],  
"properties": {  
"my\_field": {  
"type": "string",  
"index": "not\_analyzed"  
}  
}  
}  
}

my\_field will also be defined as doc\_values ?

---

<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:02am UTC](https://discuss.elastic.co/t/docs-value-doesnt-seem-to-take-affect/24958/8 "2017-07-06T00:02:59Z")

</div>


