开启script:
Scripting settingsedit
The script.disable_dynamic
node setting has been replaced by fine-grained script settings described in the scripting
docs. The following setting previously used to enable dynamic or inline scripts:
script.disable_dynamic: false
It should be replaced with the following two settings in elasticsearch.yml
that achieve the same result:
script.inline: on script.indexed: on
脚本使用,特别注意写法:
curl -XGET 'hm:9200/cars/transactions/_search?search_type=count' -d '
{
"aggs":{
"make":{
"cardinality":{
"script": "doc["make"].value"
}
}
}
}'
curl -XGET 'hm:9200/cars/transactions/_search?search_type=count' -d '
{
"aggs":{
"make":{
"cardinality":{
"script": "doc['"'"'make'"'"'].value"
}
}
}
}'
doc["dtEventTime"].date.getHourOfDay()