关于这一点有很多问题和答案,但仍然没有得到满意的答案。elasticsearch版本:6.5
索引Map
"_doc": {
"properties": {
"ssid": {
"type": "long"
},
"nested_field": {
"type": "nested"
}
}
}
}
搜索查询:
{
"query": {
"bool": {
"filter": {
"script": {
"script": "params._source.nested_field.size() > 1"
}
}
}
}
}
也试过下面的查询,但没有运气
{
"query": {
"bool": {
"must": [
{
"nested": {
"path": "nested_field",
"query": {
"bool": {
"filter": {
"script": {
"script": "params._source.nested_field.size() > 1"
}
}
}
}
}
}
]
}
}
}
错误
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"params._source.nested_field.size() > 1",
" ^---- HERE"
],
"script": "params._source.nested_field.size() > 1",
"lang": "painless"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "testing_index",
"node": "XXXXXXXXXXXXXXXXXXXXXXX",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"params._source.nested_field.size() > 1",
" ^---- HERE"
],
"script": "params._source.nested_field.size() > 1",
"lang": "painless",
"caused_by": {
"type": "null_pointer_exception",
"reason": null
}
}
}
]
},
"status": 500
}
params.\u source.nested\u field在脚本化的\u字段中使用时返回嵌套数组,但在验证查询中不起作用。关于使用无痛脚本的嵌套查询的文档不完整。
暂无答案!
目前还没有任何答案,快来回答吧!