# Nested docs vs many fields

**URL:** <https://discuss.elastic.co/t/nested-docs-vs-many-fields/73666>\
**Category:** Elasticsearch\
**Created:** [February 2, 2017, 11:49am UTC](https://discuss.elastic.co/t/nested-docs-vs-many-fields/73666 "2017-02-02T11:49:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mabn0](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mabn0/32/15135_2.png) [@mabn0](https://discuss.elastic.co/u/mabn0)\
**Post date:** [February 2, 2017, 11:49am UTC](https://discuss.elastic.co/t/nested-docs-vs-many-fields/73666/1 "2017-02-02T11:49:46Z")

</div>

I have a use case where I need to store many fields per document - around 1000 (let's say 200 date fields, 200 long fields, 200 keyword, 200 string, 200 something)

I want to do on them:

- filtering - equality, range for numeric fields, equals / prefix / contains on strings
- sorting (for string fields - by lowercased value)
- and aggregations - min/max/count on numeric fields, terms, count on strings

Most of those fields in each document are empty - 10 are always filled and additional 5-15 random ones.  
Number of documents is in the range of tens-hundreds of millions.

The question is - how well does elasticsearch handle 1k+ fields? Does it make sense to index each such field as nested document with field\_id + field\_value (separately for each type)?  
I'd assume that sorting, filtering and aggregations would work better on fields then on nested documents but if having 1k+ fields is a reasonable approach.

The workload is read-heavy (low latency required) - 10s queries per second but there is a continuous stream of updates/inserts/deletes as well.

---

<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:** [March 2, 2017, 11:50am UTC](https://discuss.elastic.co/t/nested-docs-vs-many-fields/73666/2 "2017-03-02T11:50:07Z")

</div>

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