这是我的索引
POST /blogs/1
{
"name" : "learn java","popularity" : 100
}
POST /blogs/2
{
"name" : "learn elasticsearch","popularity" : 10
}
我的搜索查询:
GET /blogs/_search
{
"query": {
"function_score": {
"query": {
"match": {
"name": "learn"
}
},"script_score": {
"script": {
"source": "_score*(1+Math.log(1+doc['popularity'].value))"
}
}
}
}
}
返回:
[
{
"_index": "blogs","_type": "1","_id": "AW5fxnperVbDy5wjSDBC","_score": 0.58024323,"_source": {
"name": "learn elastic search","popularity": 100
}
},{
"_index": "blogs","_id": "AW5fxqmL8cCMCxtBYOyC","_score": 0.43638366,"_source": {
"name": "learn java","popularity": 10
}
}
]
问题:我需要在结果中返回一个额外的字段,这将给我原始分数(只是tf / idf并没有考虑到受欢迎程度)
我探索过的东西:script_fields(在获取时无法访问_score
。