# Document size in elastic 7.0

**URL:** <https://discuss.elastic.co/t/document-size-in-elastic-7-0/178239>\
**Category:** Elasticsearch\
**Created:** [April 24, 2019, 12:01pm UTC](https://discuss.elastic.co/t/document-size-in-elastic-7-0/178239 "2019-04-24T12:01:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![aksadvance](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@aksadvance](https://discuss.elastic.co/u/aksadvance)\
**Post date:** [April 24, 2019, 12:01pm UTC](https://discuss.elastic.co/t/document-size-in-elastic-7-0/178239/1 "2019-04-24T12:01:39Z")

</div>

I have done below steps but still not getting the document size in result.

1. Installed mapper-size plugin.
2. Enabled \_size also and its reflecting in index mapping  
curl -X PUT "localhost:9200//\_mapping" -H 'Content-Type: application/json' -d'  
{  
"\_size": {  
"enabled": true  
}  
}’

When i am executing search apis, still not getting document size in response.

GET //\_search  
{  
"query": { "match\_all": {} }  
}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 24, 2019, 12:20pm UTC](https://discuss.elastic.co/t/document-size-in-elastic-7-0/178239/2 "2019-04-24T12:20:54Z")

</div>

That's expected.  
Documentation says:

> The value of the `_size` field is accessible in queries, aggregations, scripts, and when sorting

It does not mean that it's accessible as the \_source field.

---

<div class="post-metadata">

**Author:** ![aksadvance](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@aksadvance](https://discuss.elastic.co/u/aksadvance)\
**Post date:** [April 24, 2019, 12:23pm UTC](https://discuss.elastic.co/t/document-size-in-elastic-7-0/178239/3 "2019-04-24T12:23:54Z")

</div>

Sure, but is there any way to get the size of document via creating some query? Something like pass document id and get the document size.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 24, 2019, 12:36pm UTC](https://discuss.elastic.co/t/document-size-in-elastic-7-0/178239/4 "2019-04-24T12:36:11Z")

</div>

What is the use case? I mean that it's just the size of the json content which is something you can easily compute on the client side.

---

<div class="post-metadata">

**Author:** ![aksadvance](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@aksadvance](https://discuss.elastic.co/u/aksadvance)\
**Post date:** [April 24, 2019, 12:43pm UTC](https://discuss.elastic.co/t/document-size-in-elastic-7-0/178239/5 "2019-04-24T12:43:14Z")

</div>

ok, basically i have detailed-description field in the document, this field can have 50KB of data in api request so document size can be 50KB max.  
I am doing capacity planning for the data nodes, I know elastic uses Lz4 for compression but want to make sure whats the total size of document in elastic against the 50KB of data on client side. Do we have any plugin or some api which can return the saved document size on elastic.

---

<div class="post-metadata">

**Author:** ![aksadvance](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@aksadvance](https://discuss.elastic.co/u/aksadvance)\
**Post date:** [April 24, 2019, 1:32pm UTC](https://discuss.elastic.co/t/document-size-in-elastic-7-0/178239/6 "2019-04-24T13:32:02Z")

</div>

so i found the way to get the size like below.  
curl -X GET "[http://localhost:9200/](http://localhost:9200/)\< index-name \>/\_doc/\<\_id\>?stored\_fields=\_size"

Now the problem is on client side and above query responding same data size.  
detailed\_description field is part of \_source.

Whats this size ? Is this the size of raw data or saved data in elastic(compressed) ?

why its not showing the compressed data size ? Please suggest.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 24, 2019, 2:28pm UTC](https://discuss.elastic.co/t/document-size-in-elastic-7-0/178239/7 "2019-04-24T14:28:54Z")

</div>

If your goal is just to do capacity planning, what about sending real data against a real cluster and measure the place it's actually taking on disk?

There are so many things happening behind the scene in addition to storing a json document. Think about field indices, doc\_values, ...

---

<div class="post-metadata">

**Author:** ![dbakti7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dbakti7/32/42250_2.png) [@dbakti7](https://discuss.elastic.co/u/dbakti7)\
**Post date:** [April 24, 2019, 2:51pm UTC](https://discuss.elastic.co/t/document-size-in-elastic-7-0/178239/8 "2019-04-24T14:51:07Z")

</div>

In addition of what @dadoonet mentioned (getting size reported on file system), "total size" is also influenced by number of segments.  
Compression mostly happens within a segment, so depending on your use cases, if you are creating a lot of small segments, the reported size might be bigger compared to after segment merging happened.  
So I would suggest to also consider recording number of segments when you are polling the index size to avoid wrong capacity planning.

---

<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:** [May 22, 2019, 2:51pm UTC](https://discuss.elastic.co/t/document-size-in-elastic-7-0/178239/9 "2019-05-22T14:51:07Z")

</div>

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