中英文双语网站,wordpress多广告位,电子商务网站建设指导思想,wordpress安装主题后打不开es默认score是根据query的相关度进行打分的#xff0c;具体打分机制可以参见#xff1a;官方文档。如果召回时既希望有相关性又能根据其他信息进行排序。 例如小红书搜索的时候#xff0c;可能既希望有召回相关度又能根据热度信息#xff08;如果喜欢、收藏等等参数去进行召…es默认score是根据query的相关度进行打分的具体打分机制可以参见官方文档。如果召回时既希望有相关性又能根据其他信息进行排序。 例如小红书搜索的时候可能既希望有召回相关度又能根据热度信息如果喜欢、收藏等等参数去进行召回
具体使用方式 script_score 查询 官方文档
demo
package es_clientimport (contextfmttestingtimegithub.com/stretchr/testify/require
)func TestQueryEs(t *testing.T) {client, err : NewEsClient(es地址, 用户账号, 用户密码)require.NoError(t, err)ctx, cancel : context.WithTimeout(context.Background(), time.Second*10)defer cancel()query : map[string]interface{}{query: map[string]interface{}{function_score: map[string]interface{}{query: map[string]interface{}{match: map[string]interface{}{name: 狐妖,},},functions: []map[string]interface{}{{script_score: map[string]interface{}{script: map[string]interface{}{// params: map[string]interface{}{// access_num_ratio: 500,// },// lang: painless,source: doc[create_time].value ,},},},},},},size: 3}reslt, err : QueryEs(client, ctx, query, 表名)fmt.Println(reslt, err)}
依赖
github.com/elastic/go-elasticsearch/v7 v7.17.10参考 ES自定义评分机制:function_score查询详解