REST API
{
"query": {
"bool": {
"must": [
{
"term": {
"sqStatus": {
"value": 3,
"boost": 1
}
}
},
{
"script": {
"script": {
"source": "if (doc['finishTime'] == null) { false } else { doc['finishTime'].value.getMillis() > doc['timeLimit'].value.getMillis() }",
"lang": "painless"
},
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
}
}
Java Client
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(QueryBuilders.scriptQuery(new Script("if (doc['finishTime'] == null) { false } else { doc['finishTime'].value.getMillis() > doc['timeLimit'].value.getMillis() }")));
标签:脚本,finishTime,false,doc,value,getMillis,ElasticSearch,条件,boost From: https://www.cnblogs.com/yangchongxing/p/17999437