Query :
[
{"query":
{"custom_score":
{"filter":
{"prefix":
{"user_account.account_number":
"670"
}
},
"query":
{"filtered":
{"query":
{"match_all":[]
},
"filter":
{"and":
[{"term":
{"user_account.account_id":1
}
},
{"term":
{"user_account.type":"super"
}
}
]
}
}
},
"script":"random()"
}
},
"from":0,"size":1
}
]
日志:
SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[iPTJT-rkQ2uCfxcC7DmmXg][xpay][2]: SearchParseException[[user][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [[{"query":{"custom_score":{"filter":{"prefix":{"user_account.account_number":"670"}},"query":{"filtered":{"query":{"match_all":[]},"filter":{"and":[{"term":{"user_account.account_id":1}},{"term":{"user_account.type":"i"}}]}}},"script":"random()"}},"from":0,"size":1}]]]]; nested: ElasticsearchParseException[Expected START_OBJECT but got START_ARRAY null]; }{[iPTJT-rkQ2uCfxcC7DmmXg][xpay][3]: SearchParseException[[xpay][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [[{"query":{"custom_score":{"filter":{"prefix":{"user_account.account_number":"670"}},"query":{"filtered":{"query":{"match_all":[]},"filter":{"and":[{"term":{"user_account.account_id":1}},{"term":{"user_account.type":"i"}}]}}},"script":"random()"}},"from":0,"size":1}]]]]; nested: ElasticsearchParseException[Expected START_OBJECT but got START_ARRAY null]; }{[iPTJT-rkQ2uCfxcC7DmmXg][xpay][0]: SearchParseException[[xpay][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [[{"query":{"custom_score":{"filter":{"prefix":{"user_account.account_number":"670"}},"query":{"filtered":{"query":{"match_all":[]},"filter":{"and":[{"term":{"user_account.account_id":1}},{"term":{"user_account.type":"i"}}]}}},"script":"random()"}},"from":0,"size":1}]]]]; nested: ElasticsearchParseException[Expected START_OBJECT but got START_ARRAY null]; }{[iPTJT-rkQ2uCfxcC7DmmXg][xpay][1]: SearchParseException[[xpay][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [[{"query":{"custom_score":{"filter":{"prefix":{"user_account.account_number":"670"}},"query":{"filtered":{"query":{"match_all":[]},"filter":{"and":[{"term":{"user_account.account_id":1}},{"term":{"user_account.type":"super"}}]}}},"script":"random()"}},"from":0,"size":1}]]]]; nested: ElasticsearchParseException[Expected START_OBJECT but got START_ARRAY null]; }]
答案 0 :(得分:2)
custom_score在新版本中已弃用。使用功能评分查询而不是custom_score。
custom_score查询
"custom_score": {
"params": {
"param1": 2,
"param2": 3.1
},
"query": {...},
"script": "_score * doc['my_numeric_field'].value / pow(param1, param2)"
}
变为
"function_score": {
"boost_mode": "replace",
"query": {...},
"script_score": {
"params": {
"param1": 2,
"param2": 3.1
},
"script": "_score * doc['my_numeric_field'].value / pow(param1, param2)"
}
}
答案 1 :(得分:-1)
尝试将"match_all":[]
替换为"match_all":{}