# The effect of multi-fields and copy\_to on storage size

**URL:** <https://discuss.elastic.co/t/the-effect-of-multi-fields-and-copy-to-on-storage-size/17186>\
**Category:** Elasticsearch\
**Created:** [April 24, 2014, 9:30pm UTC](https://discuss.elastic.co/t/the-effect-of-multi-fields-and-copy-to-on-storage-size/17186 "2014-04-24T21:30:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremy\_McLain](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@Jeremy\_McLain](https://discuss.elastic.co/u/Jeremy_McLain)\
**Post date:** [April 24, 2014, 9:30pm UTC](https://discuss.elastic.co/t/the-effect-of-multi-fields-and-copy-to-on-storage-size/17186/1 "2014-04-24T21:30:15Z")

</div>

I want to analyze the same content three different ways and have the  
ability to return highlighting information in the query results. In order  
to do highlighting the fields need to be stored. The mapping below contains  
a multi-field indexed two different ways. The same content is copied to the  
third standalone field and indexed a different way (just pretend that it  
can't be moved into the multi-field). My question: Will this content be  
stored once, twice, or three times?

{  
"text\_document": {  
"\_source": {  
"enabled": false  
},  
"\_all": {  
"enabled": false  
},  
"properties": {  
"body": {  
"type": "string",  
"store": true,  
"analyzer": "standard",  
"copy\_to": "another\_field",  
"fields": {  
"secondary": {  
"type": "string",  
"store": true,  
"analyzer": "simple"  
},  
}  
},  
"another\_field": {  
"type": "string",  
"store": true,  
"analyzer": "snowball"  
}  
}  
}  
}

--  
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/b88388f2-8632-4a16-879c-39150019edfb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b88388f2-8632-4a16-879c-39150019edfb%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Jeremy\_McLain](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@Jeremy\_McLain](https://discuss.elastic.co/u/Jeremy_McLain)\
**Post date:** [April 30, 2014, 8:07pm UTC](https://discuss.elastic.co/t/the-effect-of-multi-fields-and-copy-to-on-storage-size/17186/2 "2014-04-30T20:07:26Z")

</div>

Ideas anyone?

--  
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/21311c5e-c0d5-4896-8560-a24e1683b1fc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/21311c5e-c0d5-4896-8560-a24e1683b1fc%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:** [May 1, 2014, 8:39pm UTC](https://discuss.elastic.co/t/the-effect-of-multi-fields-and-copy-to-on-storage-size/17186/3 "2014-05-01T20:39:19Z")

</div>

In that example, all three fields are going to be indexed and stored  
separately, so the content will be duplicated 3 times. However, I would  
expect compression to handle that efficiently.

On Wed, Apr 30, 2014 at 10:07 PM, Jeremy McLain [gongchengshi@gmail.com](mailto:gongchengshi@gmail.com)wrote:

> Ideas anyone?
> 
> --  
> 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/21311c5e-c0d5-4896-8560-a24e1683b1fc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/21311c5e-c0d5-4896-8560-a24e1683b1fc%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/21311c5e-c0d5-4896-8560-a24e1683b1fc%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/21311c5e-c0d5-4896-8560-a24e1683b1fc%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/CAL6Z4j6im-907DJwjprGBkwuBEhk%3DAvVFVtkTzKnnuOZf0RnOQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6im-907DJwjprGBkwuBEhk%3DAvVFVtkTzKnnuOZf0RnOQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Jeremy\_McLain](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@Jeremy\_McLain](https://discuss.elastic.co/u/Jeremy_McLain)\
**Post date:** [May 12, 2014, 5:43pm UTC](https://discuss.elastic.co/t/the-effect-of-multi-fields-and-copy-to-on-storage-size/17186/4 "2014-05-12T17:43:12Z")

</div>

Even if the three fields are compressed isn't it still storing three  
compressed copies of the same thing? That is still three times more  
overhead than it needs to be using. It seems very wasteful of space.  
Ideally the space used by the database would be  
size\_of\_stored\_fields\_compressed + size\_of\_index. In my case my database  
will look more like (size\_of\_stored\_fields\_compressed x 3) + size\_of\_index.  
This greatly increases my storage requirements!

If I enabled the type's \_source field and disabled individual field storage  
could I still get highlighting info in the query response for those fields?

Thanks, Adrien, for your response.

--  
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/6dec8a1c-e354-447d-82c0-cdd355a5afcc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6dec8a1c-e354-447d-82c0-cdd355a5afcc%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:** [May 12, 2014, 8:20pm UTC](https://discuss.elastic.co/t/the-effect-of-multi-fields-and-copy-to-on-storage-size/17186/5 "2014-05-12T20:20:24Z")

</div>

Hi Jeremy,

On Mon, May 12, 2014 at 7:43 PM, Jeremy McLain [gongchengshi@gmail.com](mailto:gongchengshi@gmail.com)wrote:

> Even if the three fields are compressed isn't it still storing three  
> compressed copies of the same thing? That is still three times more  
> overhead than it needs to be using. It seems very wasteful of space.  
> Ideally the space used by the database would be  
> size\_of\_stored\_fields\_compressed + size\_of\_index. In my case my database  
> will look more like (size\_of\_stored\_fields\_compressed x 3) + size\_of\_index.  
> This greatly increases my storage requirements!

It is not storing 3 compressed copies of the same thing, but storing these  
3 things (as a whole) compressed. The difference is important because it  
means that the 2nd and 3rd copies are effectively stored as references to  
the first field value. I would recommend building two indices, once with  
the copy\_fields, and once without to see what the difference is in practice.

> If I enabled the type's \_source field and disabled individual field  
> storage could I still get highlighting info in the query response for those  
> fields?

Yes, although I would recommend keeping \_source if possible. It makes lots  
of things easier, for example you can reindex from elasticsearch itself,  
etc.

--  
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/CAL6Z4j67kqaP9SC8d\_\_b7Qi4KGpX7kRAa0hxo6enKTdC7wvLxA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j67kqaP9SC8d__b7Qi4KGpX7kRAa0hxo6enKTdC7wvLxA%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, 1:29am UTC](https://discuss.elastic.co/t/the-effect-of-multi-fields-and-copy-to-on-storage-size/17186/6 "2017-07-06T01:29:59Z")

</div>


