elasticsearch function_score Query——文档排序结果的最后一道墙

本文涉及的产品
检索分析服务 Elasticsearch 版,2核4GB开发者规格 1个月
简介:

function_score Query

The function_score query is the ultimate tool for taking control of the scoring process. It allows you to apply a function to each document that matches the main query in order to alter or completely replace the original query _score.

In fact, you can apply different functions to subsets of the main result set by using filters, which gives you the best of both worlds: efficient scoring with cacheable filters.

It supports several predefined functions out of the box:

weight
Apply a simple boost to each document without the boost being normalized: a  weight of  2 results in  2 * _score.
field_value_factor
Use the value of a field in the document to alter the  _score, such as factoring in a  popularity count or number of  votes.
random_score
Use consistently random scoring to sort results differently for every user, while maintaining the same sort order for a single user.
Decay functionslinearexpgauss
Incorporate sliding-scale values like  publish_dategeo_location, or  price into the  _score to prefer recently published documents, documents near a latitude/longitude (lat/lon) point, or documents near a specified price point.
script_score
Use a custom script to take complete control of the scoring logic. If your needs extend beyond those of the functions in this list, write a custom script to implement the logic that you need.

Without the function_score query, we would not be able to combine the score from a full-text query with a factor like recency. We would have to sort either by _score or by date; the effect of one would obliterate the effect of the other. This query allows you to blend the two together: to still sort by full-text relevance, but giving extra weight to recently published documents, or popular documents, or products that are near the user’s price point. As you can imagine, a query that supports all of this can look fairly complex. We’ll start with a simple use case and work our way up the complexity ladder.

 

转自:https://www.elastic.co/guide/en/elasticsearch/guide/current/function-score-query.html












本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/6480761.html,如需转载请自行联系原作者


相关实践学习
使用阿里云Elasticsearch体验信息检索加速
通过创建登录阿里云Elasticsearch集群,使用DataWorks将MySQL数据同步至Elasticsearch,体验多条件检索效果,简单展示数据同步和信息检索加速的过程和操作。
ElasticSearch 入门精讲
ElasticSearch是一个开源的、基于Lucene的、分布式、高扩展、高实时的搜索与数据分析引擎。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr(也是基于Lucene)。 ElasticSearch的实现原理主要分为以下几个步骤: 用户将数据提交到Elastic Search 数据库中 通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据 当用户搜索数据时候,再根据权重将结果排名、打分 将返回结果呈现给用户 Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
相关文章
|
3月前
Elasticsearch之RestClient查询文档
Elasticsearch之RestClient查询文档
139 1
|
4月前
|
JSON 自然语言处理 数据库
数据库-ElasticSearch入门(索引、文档、查询)
数据库-ElasticSearch入门(索引、文档、查询)
288 0
|
7月前
|
数据库 索引
elasticsearch中join类型数据如何进行父子文档查询?
elasticsearch中join类型数据如何进行父子文档查询?
|
5月前
|
自然语言处理 关系型数据库 定位技术
分布式系列教程(35) -ElasticSearch文档映射
分布式系列教程(35) -ElasticSearch文档映射
43 0
|
1月前
|
BI
工具分享 - 将一个 ABAP Function Group 内所有 Function Module 按照代码行数从高到低排序并显示试读版
工具分享 - 将一个 ABAP Function Group 内所有 Function Module 按照代码行数从高到低排序并显示试读版
15 0
|
2月前
|
测试技术 定位技术 API
万字长文:一文彻底搞懂Elasticsearch中Geo数据类型查询、聚合、排序
万字长文:一文彻底搞懂Elasticsearch中Geo数据类型查询、聚合、排序
94612 140
|
2月前
|
JSON 前端开发 API
【Elasticsearch】搜索结果处理和RestClient查询文档
【Elasticsearch】搜索结果处理和RestClient查询文档
337 0
|
2月前
|
JSON 自然语言处理 算法
【Elasticsearch】DSL查询文档
【Elasticsearch】DSL查询文档
314 0
|
3月前
|
存储 自然语言处理 Java
SpringBoot集成ElasticSearch时分页排序查询时遇到的坑每次只能返回10条数据
SpringBoot集成ElasticSearch时分页排序查询时遇到的坑每次只能返回10条数据
56 0
|
4月前
|
网络架构 索引
elasticsearch 索引库操作和文档操作(二)
elasticsearch 索引库操作和文档操作
115 0

热门文章

最新文章