单独排序的Solr Boost查询 [英] solr boost query with separate sort

查看:252
本文介绍了单独排序的Solr Boost查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将inv = 0(可能值从0到1000)的所有文档降级到结果集的末尾.在查询中,我还有其他排序选项,例如名称desc.

I want to demote all documents that have inv=0(possible values from 0 to 1000) to the end of the result set. i have got other sorting options like name desc also as part of the query.

例如下面是我的Solr文档

For example below are my solr documents

Doc1 : name=apple , Inv=2
Doc2 : name=ball , Inv=1
Doc3 : name=cat , Inv=0
Doc4 : name=dog , Inv=0
Doc5 : name=fish , Inv=4
Doc6 : name=Goat , Inv=5

我想实现下面的排序...在这里,我想将inv = 0的所有文档向下推至底部,然后应用名称asc"排序.

I want achieve below sorting ...here, i want to push all documents with inv=0 down to bottom and then apply "name asc" sorting.

Doc1
Doc2
Doc5
Doc6
Doc3
Doc4

我的solr请求就像

bq:(:AND -inv:"0")^ 999.0& defType:"edismax"

bq: "(: AND -inv:"0")^999.0" & defType: "edismax"

这里999是我给降级结果的排名.

here 999 is the rank that i gave to demote results.

此增强查询工作正常.它将所有inv = 0的文档向下移动到底部.

this boosting query works fine. it moves all documents with inv=0 down to the bottom.

但是,当我在solr查询中添加& sort = name asc时,它会优先于bq排序"sort".我看到以下结果为"name asc".

But when i add &sort=name asc to the solr query, it prioritizes "sort" over bq..i am seeing below results with "name asc".

Doc1 : name=apple , Inv=2
Doc2 : name=ball , Inv=1
Doc3 : name=cat , Inv=0
Doc4 : name=dog , Inv=0
Doc5 : name=fish , Inv=4
Doc6 : name=Goat , Inv=5

任何人都可以帮助我. ?

can anyone please help me out. ?

推荐答案

排序将覆盖增强.

因此,您可以通过将条件映射设置为增强值来将排序移入增强.

So, you either move your sort into boost by making that condition map into boost values.

或者您可以使用 query()语法将升压条件分类.这是 hoss的Lucene/Solr Revolution 2016演讲中的瑰宝之一(单击开始演示):

Or you move your boost condition into sort, using query() syntax. This was one of the gems from the Lucene/Solr Revolution 2016 presentation by hoss (click start presentation):

        qq = Harry
         q = +{!edismax v=$qq}
        qf = title actor writer director  keywords
      sort = query($title_sort,0) desc, title asc
title_sort = {!field f=title v=$qq}

这篇关于单独排序的Solr Boost查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆