有谁能帮我构造下面的查询。运行此查询时,出现以下错误。es版本为7.9.0;在我的模型中有一个字段“repliedby”,它是一个数组字段。它的值总是用空数组初始化。但在某些实体上,它有一个或几个对象。我需要编写一个查询,以获取所有项目与空数组只。
GET myTable/_search
{
"query": {
"bool": {
"must": [
{
"script": {
"script": {
"source": "doc['repliedBy'].size() == params.val",
"params": {
"val": 0
}
}
}
},
{
"range": {
"receivedDate": {
"gte": "2020-09-15T07:51:21.000Z",
"lte": "2020-12-01T07:51:21.000Z"
}
}
}
]
}
}
}
错误:
"error" : {
"root_cause" : [
{
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:90)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:41)",
"doc['repliedBy'].size() == params.val",
" ^---- HERE"
],
"script" : "doc['repliedBy'].size() == params.val",
"lang" : "painless",
"position" : {
"offset" : 4,
"start" : 0,
"end" : 37
}
}
],
1条答案
按热度按时间nnvyjq4y1#
这是我的工作
bool/must_not/exists
查询组合,如下所示: