腳本使用express
在es API中支持腳本的地方,語法遵循相同的模式:less
"script": {code
"lang": "...", (1)
"inline" | "stored" | "file": "...", (2)
"params": { ... } (3)
}ip
(1)寫入腳本的語言,默認爲painless。io
(2)腳本能夠指定爲 inline
, stored
, or file
.file
(3) 傳遞給腳本的命名參數。語法
eq:下面腳本是查找請求 返回scripted field:
PUT my_index/my_type/1
{
"my_field": 5
}請求
GET my_index/_search
{
"script_fields": {
"my_doubled_field": {
"script": {
"lang": "expression",
"inline": "doc['my_field'] * multiplier",
"params": {
"multiplier": 2
}
}
}
}
}命名