栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Elasticsearch中的加权随机抽样

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Elasticsearch中的加权随机抽样

万一它对任何人都有帮助,这就是我最近实施加权改组的方式。

在此示例中,我们对公司进行了洗牌。每个公司都有一个介于0到100之间的“
company_score”。通过这种简单的加权改组,得分为100的公司出现在首页的可能性是得分为20的公司的5倍。

json_body = {    "sort": ["_score"],    "query": {        "function_score": { "query": main_query,  # put your main query here "functions": [     {         "random_score": {},     },     {         "field_value_factor": {  "field": "company_score",  "modifier": "none",  "missing": 0,         }     } ], # How to combine the result of the two functions 'random_score' and 'field_value_factor'. # This way, on average the combined _score of a company having score 100 will be 5 times as much # as the combined _score of a company having score 20, and thus will be 5 times more likely # to appear on first page. "score_mode": "multiply", # How to combine the result of function_score with the original _score from the query. # We overwrite it as our combined _score (random x company_score) is all we need. "boost_mode": "replace",        }    }}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/380833.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号