我有一个关键字列表与相关分数,我想用它来匹配的elasticsearch索引文件。目标是通过输入关键字来匹配文档,并通过输入分数和文档关键字分数的组合来进行排名。
搜索输入示例:
[{
"name": "golang",
"score": 0.2
}, {
"name": "c++",
"score": 0.13
}, {
"name": "php",
"score": 0.07
}]
两个示例文档:
[{
"name": "John",
"location": "USA",
"scoredKeywords": [
{
"name": "php",
"score": 0.7
}, {
"name": "golang",
"score": 0.3
}, {
"name": "java",
"score": 0.17
}]
}, {
"name": "Bob",
"location": "USA",
"scoredKeywords": [
{
"name": "javascript",
"score": 0.8
}, {
"name": "php",
"score": 0.01
}, {
"name": "golang",
"score": 0.01
}]
}, {
"name": "Dave",
"location": "USA",
"scoredKeywords": [
{
"name": "golang",
"score": 0.9
}, {
"name": "html",
"score": 0.4
}, {
"name": "css",
"score": 0.3
}]
}]
我可以根据需要灵活地进行Map。
我对排名的想法是这样的:
Dave: (overall: 1800)
golang: 0.9
rank: (0.9 * 100) * (0.2 * 100) = 1800
html: 0.4
rank: n/a
css: 0.3
rank: n/a
John: (overall: 490 + 600 = 1090)
php: 0.7
rank: (0.7*100) * (0.07*100) = 490
golang: 0.3
rank: (0.3*100) * (0.2 * 100) = 600
java: 0.17
rank: n/a
Bob: (overall: 7 + 20 = 27)
javascript: 0.8
rank: n/a
php: 0.01
rank: (0.01 * 100) * (0.07 * 100) = 7
golang: 0.01
rank: (0.01 * 100) * (0.2 * 100) = 20
暂无答案!
目前还没有任何答案,快来回答吧!