这两者的查询结果是一样的,所以script score查询与function score查询的区别是什么?有分别有什么样应用场景?
function_score查询
script score查询
function_score查询
GET /hotel/_search
{
"query": {
"function_score": {
"query": {
"match_all": {} //匹配所有文档
},
"functions": [
{
"script_score": {
"script": "randomScore(100,'_seq_no')"
}
}
]
}
}
}
script score查询
GET hotel/_search
{
"query": {
"script_score": {
"script": {
"source": "randomScore(100,'_seq_no')"
},
"query": {
"match_all": {}
}
}
}
}
[size=13]
[/size]
0 个回复