Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch get size stats of document given document Id

Using Elasticsearch 1.4.0

Is there a way to find out the various size stats of a particular document given it's id?

So just to see how ES breaks down each individual document?

like image 713
user432024 Avatar asked Dec 29 '14 15:12

user432024


1 Answers

Elasticsearch has a _size field that you can request for a document. In order to use it, you may have to enable it on the mapping for your document type by adding "_size": {"enabled": true, "store": true}. There isn't much documentation on its specifics, but it appears to match the total length of the _source field for that document. Totaling the _size of all documents in an index, however, will not match the primary store size for that index. This makes sense, as the underlying lucene indices are storing a tokenized representation of the document, not necessarily its _source.

Example Query:

curl localhost:9200/myIndex/sometype/28c53efe-2eaf-11e5-80c3-000d1fc9a922?fields=_size

Result:

{
    "_index": "myIndex",
    "_type": "sometype",
    "_id": "28c53efe-2eaf-11e5-80c3-000d1fc9a922",
    "_version": 1,
    "found": true,
    "fields": {
        "_size": 905
    }
}
like image 107
Dusty Avatar answered Sep 25 '22 08:09

Dusty