POST /_search
{
"query": {
"script" : {
"script" : {
"inline": "doc['value'].value > 1"
}
}
}
}
GET /_search
{
"script_fields": {
"square_root_field": {
"script": {
"inline": "return Math.sqrt(doc['value'].value);"
}
}
}
}
POST /_update
{
"script": "ctx._source.date='2018-03-22T06:01:47+0000'"
}
GET /_search
{
"script_fields": {
"square_root_field": {
"script": {
"inline": "
int totalScore(def scores) {
def total = 0;
for (def score : scores) {
total += score;
}
return total;
}
if (totalScore(doc['scores']) > 90) {
return 'passed';
} else {
return 'failed';
};
"
}
}
}
}
POST _scripts/calculate-score
{
"script": {
"lang": "painless",
"source": "Math.log(_score * 2) + params.my_modifier"
}
}
GET _scripts/calculate-score
DELETE _scripts/calculate-score
public $script = <<<JAVA
if (doc['age'] > 18) {
return 'old';
} else {
return 'young';
}
JAVA;