# Index Size is 4 times than a document size?

**URL:** <https://discuss.elastic.co/t/index-size-is-4-times-than-a-document-size/47272>\
**Category:** Elasticsearch\
**Created:** [April 13, 2016, 3:42pm UTC](https://discuss.elastic.co/t/index-size-is-4-times-than-a-document-size/47272 "2016-04-13T15:42:41Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasa47](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vasa47](https://discuss.elastic.co/u/vasa47)\
**Post date:** [April 13, 2016, 3:42pm UTC](https://discuss.elastic.co/t/index-size-is-4-times-than-a-document-size/47272/1 "2016-04-13T15:42:42Z")

</div>

With this below setting and mapping I indexed a text file of 1.3MB and now my index size in data/clusters\_name/nodes/ size is almost 4 times. What is happening? what settings am I missing?

```
    "settings" : {
        "number_of_shards" : 1,
        "number_of_replicas" : 0
        },
        {
      "mappings": {
        "attachment" : {
        "properties" : {
             "file" : {
             "type" : "attachment",
                "fields" : {
                  "title" : { "store" : "yes" },
                   "file" : { "term_vector":"with_positions_offsets", "store":"yes" }
                 }
             }
           }
        }
    }
```

---

<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 13, 2016, 5:13pm UTC](https://discuss.elastic.co/t/index-size-is-4-times-than-a-document-size/47272/2 "2016-04-13T17:13:09Z")

</div>

Please format your code with `</>` icon.

You have to understand what elasticsearch does in that case:

- extracts the text with Tika and adds it to field: `file.file`
- stores this extracted text (you explicitly asked for it)
- index this content
- extracts every single field content into `_all` field (I did not check but may be the BASE64 content is also added to this field) and index that
- store in `_source` the JSON doc, including your `BASE64` content.

That's why I'm not surprised by your numbers.

I'd at least disable `_all` field.

Also, note that with 5.0, this plugin moves as a Node Ingest plugin which will give definitely better results!

HTH

---

<div class="post-metadata">

**Author:** ![vasa47](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vasa47](https://discuss.elastic.co/u/vasa47)\
**Post date:** [April 14, 2016, 10:22am UTC](https://discuss.elastic.co/t/index-size-is-4-times-than-a-document-size/47272/3 "2016-04-14T10:22:56Z")

</div>

Okay I am bit confused on how mapper attachments work on indexing a file.

PUT /test  
PUT /test/person/\_mapping

```
{
    "person" : {
        "properties" : {
             "my_attachment" : { "type" : "attachment" }
        }
    }
}

```

PUT /test/person/1

```
{
    "my_attachment" : "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="
}

```

This is giving 9.5 kb of index size. In which the base64 content is just 48 bytes. Of course \_all is enabled by default or content is stored and even the base64 content is stored or not.

I just want to index a file on the local fileSystem with title and content enabling highlighting. Can you please point out how you do this with the index size factor of 1 or less.

---

<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 14, 2016, 10:43am UTC](https://discuss.elastic.co/t/index-size-is-4-times-than-a-document-size/47272/4 "2016-04-14T10:43:04Z")

</div>

Well. You have also some metadata so with a small content like this you can not really measure anything.  
Also, you have to know that stored fields are compressed. Here again it depends on the effective compress ratio.

What I recommend is to do extraction of text on your end or use elasticsearch 5.0 and the ingest-attachment plugin (not suitable for production yet).

---

<div class="post-metadata">

**Author:** ![vasa47](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vasa47](https://discuss.elastic.co/u/vasa47)\
**Post date:** [April 14, 2016, 10:57am UTC](https://discuss.elastic.co/t/index-size-is-4-times-than-a-document-size/47272/5 "2016-04-14T10:57:49Z")

</div>

I ll try it out the ingest attachment plugin.

---

<div class="post-metadata">

**Author:** ![virtualmagister](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/virtualmagister/32/8053_2.png) [@virtualmagister](https://discuss.elastic.co/u/virtualmagister)\
**Post date:** [April 14, 2016, 4:26pm UTC](https://discuss.elastic.co/t/index-size-is-4-times-than-a-document-size/47272/6 "2016-04-14T16:26:16Z")

</div>

@dadoonet  
So, will Elasticsearch 5 (with Ingestion node / Ingestion-attachment plugin) became a valid and robust choice as primary repository? (blob content)  
thanks  
Gianni

---

<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 14, 2016, 4:49pm UTC](https://discuss.elastic.co/t/index-size-is-4-times-than-a-document-size/47272/7 "2016-04-14T16:49:33Z")

</div>

Not related.

Ingest node does not mean that we will store the "blob" in elasticsearch. That's totally the opposite. We will extract from the binary only the needed text and will index that text only.

---

<div class="post-metadata">

**Author:** ![virtualmagister](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/virtualmagister/32/8053_2.png) [@virtualmagister](https://discuss.elastic.co/u/virtualmagister)\
**Post date:** [April 19, 2016, 9:42am UTC](https://discuss.elastic.co/t/index-size-is-4-times-than-a-document-size/47272/8 "2016-04-19T09:42:49Z")

</div>

> [@dadoonet](#):
>
> not suitable for production yet).

Thanks @dadoonet for your answer.  
Currently we are using mapper-attachment plugin in a big environment so the binary is in the \_source and Elasticsearch is primary and only repository.  
In this new scenario, will the blob continue to be stored in the same way?  
The text extraction process in the ingestion node is asynchronous to the post?

Thanks,  
Gianni

---

<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 5, 2017, 10:58pm UTC](https://discuss.elastic.co/t/index-size-is-4-times-than-a-document-size/47272/9 "2017-07-05T22:58:08Z")

</div>


