WARNING: Version 1.6 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.
Transform
editTransform
editThe document can be transformed before it is indexed by registering a
script in the transform
element of the mapping. The result of the
transform is indexed but the original source is stored in the _source
field. Example:
{ "example" : { "transform" : { "script" : "if (ctx._source['title']?.startsWith('t')) ctx._source['suggest'] = ctx._source['content']", "params" : { "variable" : "not used but an example anyway" }, "lang": "groovy" }, "properties": { "title": { "type": "string" }, "content": { "type": "string" }, "suggest": { "type": "string" } } } }
Its also possible to specify multiple transforms:
{ "example" : { "transform" : [ {"script": "ctx._source['suggest'] = ctx._source['content']"} {"script": "ctx._source['foo'] = ctx._source['bar'];"} ] } }
Because the result isn’t stored in the source it can’t normally be fetched by source filtering. It can be highlighted if it is marked as stored.