此时,我们可以使用negative boost来解决这个问题。negative boost会降低elasticsearch词条在每个document中相关度分数计算时的比值,从而变相的提高了java词条的比值,实现更加合理的排序。 GET /index_name/_search { "query": { "boosting": { "positive": { "match": { "field1": "java" } }, "negative": {...
它接受一个positive查询和一个negative查询。只有匹配了positive查询的文档才会被包含到结果集中,但是同时匹配了negative查询的文档会被降低其相关度,通过将文档原本的_score和negative_boost参数进行相乘来得到新的_score。 因此,negative_boost参数必须小于1.0。在上面的例子中,任何包含了指定负面词条的文档的_score都会是...
boosting 查询包括 positive、negative 和 negative_boost 三个部分,positive 中的查询评分保持不变,negative 中的查询会降低文档评分,negative_boost 指明 negative 中降低的权值。如果我们想对 2015 年之前出版的书降低评分,可以构造一个 boosting 查询,查询语句如下: GET books/_search{"query": {"boosting": {"p...
boosting 查询用于需要对两个查询的评分进行调整的场景,boosting 查询会把两个查询封装在一起并降低其中一个查询的评分。 boosting 查询包括 positive、negative 和 negative_boost 三个部分,positive 中的查询评分保持不变,negative 中的查询会降低文档评分,negative_boost 指明 negative 中降低的权值。如果我们想对 2015...
4 通过 boosting query 嵌套搜索修改内层搜索结果的相关性得分先看一下 boosting query 嵌套搜索的语法:GET /myindex/_search{ "query": { "boosting": { "positive": { 嵌套子查询 }, "negative": { 嵌套子查询 } , "negative_boost": 调整权重 } }}boosting 嵌套查询以 positive 下的子查询来获取...
3.negative_boost降低相关性 对于某些结果不满意,但又不想通过 must_not 排除掉,可以考虑可以考虑boosting query的negative_boost。即:降低评分 negative_boost (Required, float) Floating point number between 0 and 1.0 used to decrease the relevance scores of documents matching the negative query. 官网文档地...
{"term":{"sex":{"value":"女","boost":1.0} } }, {"term":{"sect.keywords":{"value":"明教","boost":1.0} } } ],"adjust_pure_negative":true,"boost":1.0} } } Java构造查询语句: SearchSourceBuildersearchSourceBuilder=newSearchSourceBuilder();//构建查询语句searchSourceBuilder.query(Quer...
{ "query": { "bool": { "must": [ { "term": { "sex": { "value": "女", "boost": 1.0 } } }, { "term": { "sect.keywords": { "value": "明教", "boost": 1.0 } } } ], "adjust_pure_negative": true, "boost": 1.0 } } } Java构造查询语句: 代码语言:javascript 代码...
GET/person/_search{"query":{"term":{"name.keyword":{"value":"张无忌","boost":1.0}}} ElasticSearch 5.0以后,string类型有重大变更,移除了string类型,string字段被拆分成两种新的数据类型: text用于全文搜索的,而keyword用于关键词搜索。 查询结果: 代码...
1.0}}}],“adjust_pure_negative”: true,“boost”: 1.0}},“sort”: [{“createTime”: {“order”: “desc”}}]}java代码调用:/**一、查询条件拼装*/SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();//按创建时间降序排序...