# Caveats of a large mapping

**URL:** <https://discuss.elastic.co/t/caveats-of-a-large-mapping/5903>\
**Category:** Elasticsearch\
**Created:** [November 17, 2011, 5:29pm UTC](https://discuss.elastic.co/t/caveats-of-a-large-mapping/5903 "2011-11-17T17:29:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Hoffman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick_hoffman/32/1872_2.png) [@Nick\_Hoffman](https://discuss.elastic.co/u/Nick_Hoffman)\
**Post date:** [November 17, 2011, 5:29pm UTC](https://discuss.elastic.co/t/caveats-of-a-large-mapping/5903/1 "2011-11-17T17:29:46Z")

</div>

The documents that my application needs to index contain an ever-growing  
number of arbitrary fields. Most of these fields are strings, but some are  
dates or numbers. To be able to sort on these arbitrary fields, I've built  
a dynamic template into my mapping:

> <https://gist.github.com/nickhoffman/e018df778fcece76717e>

As the number of documents and arbitrary fields grow, the dynamic template  
will add fields to the mapping.

With only 1000 documents indexed, my mapping is 220 lines long. That's not  
much, but after indexing 10,000 or 100,000 documents, that mapping will  
grow significantly; probably upwards of 1,000 or 5,000 lines.

Are there any caveats that one should be aware of when doing this?

Thanks!

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 20, 2011, 8:00am UTC](https://discuss.elastic.co/t/caveats-of-a-large-mapping/5903/2 "2011-11-20T08:00:42Z")

</div>

The mappings are compressed and not "pretty printed" internally, so you  
should not care about the size of it in that regard. Many fields do mean  
more memory usage Lucene wise, just something to be aware.

On Thu, Nov 17, 2011 at 7:29 PM, Nick Hoffman [nick@deadorange.com](mailto:nick@deadorange.com) wrote:

> The documents that my application needs to index contain an ever-growing  
> number of arbitrary fields. Most of these fields are strings, but some are  
> dates or numbers. To be able to sort on these arbitrary fields, I've built  
> a dynamic template into my mapping:  
> [ES Dynamic Template · GitHub](https://gist.github.com/e018df778fcece76717e)
> 
> As the number of documents and arbitrary fields grow, the dynamic template  
> will add fields to the mapping.
> 
> With only 1000 documents indexed, my mapping is 220 lines long. That's not  
> much, but after indexing 10,000 or 100,000 documents, that mapping will  
> grow significantly; probably upwards of 1,000 or 5,000 lines.
> 
> Are there any caveats that one should be aware of when doing this?
> 
> Thanks!

---

<div class="post-metadata">

**Author:** ![Nick\_Hoffman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick_hoffman/32/1872_2.png) [@Nick\_Hoffman](https://discuss.elastic.co/u/Nick_Hoffman)\
**Post date:** [November 20, 2011, 9:56pm UTC](https://discuss.elastic.co/t/caveats-of-a-large-mapping/5903/3 "2011-11-20T21:56:48Z")

</div>

Thanks for the clarification!

---

<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, 3:48am UTC](https://discuss.elastic.co/t/caveats-of-a-large-mapping/5903/4 "2017-07-06T03:48:06Z")

</div>


