WARNING: Version 0.90 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
_source
edit_source
editThe _source
field is an automatically generated field that stores the
actual JSON that was used as the indexed document. It is not indexed
(searchable), just stored. When executing "fetch" requests, like
get or
search, the _source
field is
returned by default.
Though very handy to have around, the source field does incur storage overhead within the index. For this reason, it can be disabled. For example:
{ "tweet" : { "_source" : {"enabled" : false} } }
Compression
editFrom version 0.90 onwards, all stored fields (including _source
) are
always compressed.
For versions before 0.90:
The source field can be compressed (LZF) when stored in the index. This can greatly reduce the index size, as well as possibly improving performance (when decompression overhead is better than loading a bigger source from disk). The code takes special care to decompress the source only when needed, for example decompressing it directly into the REST stream of a result.
In order to enable compression, the compress
option should be set to
true
. By default it is set to false
. Note, this can be changed on an
existing index, as a mix of compressed and uncompressed sources is
supported.
Moreover, a compress_threshold
can be set to control when the source
will be compressed. It accepts a byte size value (for example 100b
,
10kb
). Note, compress
should be set to true
.
Includes / Excludes
editAllow to specify paths in the source that would be included / excluded
when it’s stored, supporting *
as wildcard annotation. For example:
{ "my_type" : { "_source" : { "includes" : ["path1.*", "path2.*"], "excludes" : ["pat3.*"] } } }