WARNING: Version 5.2 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.
Script Query
editScript Query
editA query allowing to define scripts as queries. They are typically used in a filter context, for example:
GET /_search { "query": { "bool" : { "must" : { "script" : { "script" : { "inline": "doc['num1'].value > 1", "lang": "painless" } } } } } }
Custom Parameters
editScripts are compiled and cached for faster execution. If the same script can be used, just with different parameters provider, it is preferable to use the ability to pass parameters to the script itself, for example:
GET /_search { "query": { "bool" : { "must" : { "script" : { "script" : { "inline" : "doc['num1'].value > params.param1", "lang" : "painless", "params" : { "param1" : 5 } } } } } } }