感谢:
https://blog.csdn.net/u012270682/article/details/80165836
查询空字段参考
https://blog.csdn.net/zhang862520682/article/details/80333196
更多参考
https://blog.csdn.net/u011652364/article/details/78901945
https://yuerblog.cc/2018/08/23/painless-doc-values/
官网
https://www.elastic.co/guide/en/elasticsearch/reference/5.4/modules-scripting-painless.html
注意
异常
Invalid pipeline aggregation named [******] of type [bucket_script]. Only sibling pipeline aggregations are allowed at the top level
顶层只允许同级管道聚合
过滤
需求: 如果aaa字段不存在,则使用bbb字段
aaa<=结果<=bbbb
{
"from": 0,
"size": 10,
"query": {
"bool": {
"filter": [
{
{
"script" : {
通过脚本过滤
"script" : {
"inline" : "if(doc['aaa'].empty==true){if(doc['bbbbb'].value>=97.0){return doc['bbbbb'].value;}}else{if(doc['aaa'].value>=97.0){return doc['aaa'].value;}}",
"lang" : "painless"
},
"boost" : 1.0
}
},
{
"script" : {
"script" : {