Updated on 2024-11-29 GMT+08:00

Disabling the _source Field

The _source field contains the body of the original JSON document that is passed during the indexing. This field itself is not indexed (so it is not searchable), but it is stored so that it can be returned when the fetch request, such as get or search, is executed.

However, the _source field has much storage overhead in indexing. Therefore, the field can be disabled as follows:

curl -XPUT --tlsv1.2 --negotiate -k -u : 'https://ip:httpport/tweets?pretty' -H 'Content-Type: application/json' -d'
{
   "mappings": {
          "tweet": {
               "_source": {
                       "enabled": false
                 }
           }
     }
}'
Before disabling the _source field, note that if the _source field is unavailable, the following functions are not supported:
  • update, update_by_query, and reindex APIs.
  • Highlight
  • Reindex an Elasticsearch index to another index in order to modify the mapping or analysis, or to upgrade the index to a new major version.
  • Debug query or aggregation by viewing the original document used for indexing.
  • Automatically repair damaged indexes.