当前位置: 首页 > news >正文

开封做网站睿艺美怎么弄一个网站

开封做网站睿艺美,怎么弄一个网站,wordpress滚动主题,成都电脑培训班零基础script_score介绍 在Elasticsearch中&#xff0c;script_score是在function_score查询中的一种功能强大的方式&#xff0c;允许用户使用内置Painless脚本语言或者其他支持的语言来动态计算每个文档的评分 script_score语法 GET /<索引名>/_search {"query":…

script_score介绍

在Elasticsearch中,script_score是在function_score查询中的一种功能强大的方式,允许用户使用内置Painless脚本语言或者其他支持的语言来动态计算每个文档的评分

script_score语法

GET /<索引名>/_search
{"query": {"function_score": {"query": { "match_all": {} }, // 或者其它查询条件"functions": [{"script_score": {"script": {"source": """double customScore = 0;if (doc['field1'].value > params.threshold1) {customScore += doc['field1'].value * params.multiplier1;}customScore += doc['field2'].value;return customScore;""","params": {"threshold1": 50,"multiplier1": 0.5}}}}],"score_mode": "sum", // 或者其它score_mode"boost_mode": "replace" // 或者其它boost_mode}}
}
  • script_score被用来定义一个脚本,该脚本计算文档的自定义评分
  • source字段内是Painless脚本,它可以访问文档中的字段值(如doc[‘field1’].value和doc[‘field2’].value)并对它们进行计算
  • params是一个键值对对象,用于传递给脚本的参数,此处定义了两个参数:threshold1和multiplier1

script_score 案例

场景

假设我们有一个问答论坛索引,需要基于回答数量和点赞数查找高质量

索引创建

PUT /forum_questions
{"mappings": {"properties": {"question": {"type": "text"},"answer_count": {"type": "long"},"upvotes": {"type": "long"}}}
}

文档插入

POST /forum_questions/_doc/
{"question": "What is Elasticsearch?","answer_count": 5,"upvotes": 20
}POST /forum_questions/_doc/
{"question": "How to configure Elasticsearch for production?","answer_count": 3,"upvotes": 15
}POST /forum_questions/_doc/
{"question": "Best practices for indexing data in Elasticsearch?","answer_count": 10,"upvotes": 30
}POST /forum_questions/_doc/
{"question": "How to optimize Elasticsearch performance?","answer_count": 8,"upvotes": 18
}POST /forum_questions/_doc/
{"question": "What are shards and replicas in Elasticsearch?","answer_count": 6,"upvotes": 25
}POST /forum_questions/_doc/
{"question": "How to handle time-based data in Elasticsearch?","answer_count": 4,"upvotes": 12
}POST /forum_questions/_doc/
{"question": "What is the difference between match and term queries?","answer_count": 7,"upvotes": 23
}POST /forum_questions/_doc/
{"question": "How to set up Elasticsearch clusters?","answer_count": 9,"upvotes": 16
}

查询

GET /forum_questions/_search
{"query": {"function_score": {"query": { "match_all": {} }, // 或者使用具体查询条件"functions": [{"script_score": {"script": {"source": """double score = 0;score += doc['answer_count'].value * params.answer_weight;score += doc['upvotes'].value * params.upvote_weight;return score;""","params": {"answer_weight": 0.7,"upvote_weight": 0.3}}}}],"score_mode": "sum"}}
}
http://www.dinnco.com/news/811.html

相关文章:

  • 做药品网站规划方案天津seo排名公司
  • 99设计网站seo网站排名优化工具
  • 自己做局域网网站的流程上海百度推广排名
  • 汽车网站模板网络营销知识点
  • 网站开发实训心得800字太原seo团队
  • 企业做网站好处百度快照在哪里找
  • vb.net 网站开发实例pc优化工具
  • wxqqcom微信网页版谷歌seo外链
  • 河南那家做网站实力强网站运营方案
  • 宁波网站制作 收费标准网站建设优化的技巧
  • 做网站能赚钱seo竞价
  • 来年做那个网站能致富郑州seo线下培训
  • 影视制作传媒公司网络seo招聘
  • 如何在淘宝上做自己的网站百度竞价推广托管
  • 如何在自己的网站上做直播如何建立和设计公司网站
  • 城乡建设部网站 挂证河南郑州最新事件
  • 用discuz做的门户网站我的百度账号
  • 哪个网站有卖做一次性口机器的长春网站建设技术托管
  • 网站建设的七大优缺点杭州网站建设
  • 网站制作价格表新媒体营销推广公司
  • 怎么做旅游网站推广厦门seo排名扣费
  • 西安网站建设雄账号抖音热门搜索关键词
  • 做网站的设计理念aso推广平台
  • 日照百达建设咨询有限公司内部网站中国免费网站服务器下载
  • 怎样设置网站主域名长沙网络公司营销推广
  • 电子商务网站创建过程seo外链建设的方法有
  • 鲅鱼圈网站开发哪家好哦上海网络推广
  • 南京网站网站建设公司百度推广怎么做效果好
  • 网站推广建设加盟新闻头条 今天
  • 保障房建设网站首页网络营销手段有哪四种