我试图通过将_score乘以存储在每个文档中的单个值的平方根来修改elasticsearch中的搜索分数。下面是我正在使用的JSON查询。我哪里出错?
{
"index": "resources",
"type": "page",
"from": "0",
"size": "20",
"body": {
"query": {
"match": {
"content": "baseball"
},
"function_score": {
"functions": [{
"script_score": {
"params": [],
"script": "_score * sqrt(page['obls'].value)"
}
}]
}
}
}
}
提前感谢您的帮助!
答案 0 :(得分:0)
如果您使用的是1.4.X,我会使用field value factor函数,如下所示:
{
"query": {
"function_score": {
"query": {
"match": {
"content": "baseball"
}
},
"functions": [
{
"field_value_factor": {
"field": "obls",
"factor": 1,
"modifier": "sqrt"
}
}
]
}
},
"from": "0",
"size": "20"
}