需求:商品排序,无库存的商品排在后面(排序)。

搜索:

 默认搜索:                                            df:

      

可以看出左图第1个、第6个库存为0.

现在的需求是想将这两个库存为0的商品排在最后面。

edismax-》bf:product(map(store,1,9999999,1),100) ,效果如右图。

store map的规则:

store=0,v(store)=0;

store>0,v(store)=1;(默认store的最大值999999999)

product*100,为了突显加权的效果。(可忽略)

以上等同于:

q: queryStr_val_:"product(map(store,1,9999999,1),100)"

观察打分的细节:

 <str name="92011786">
12.634275 = (MATCH) sum of:
2.0679202 = (MATCH) sum of:
1.2457463 = (MATCH) weight(searchField:165 in 18377) [DefaultSimilarity], result of:
1.2457463 = score(doc=18377,freq=2.0 = termFreq=2.0
), product of:
0.77180904 = queryWeight, product of:
7.3044024 = idf(docFreq=78, maxDocs=43211)
0.105663545 = queryNorm
1.6140602 = fieldWeight in 18377, product of:
1.4142135 = tf(freq=2.0), with freq of:
2.0 = termFreq=2.0
7.3044024 = idf(docFreq=78, maxDocs=43211)
0.15625 = fieldNorm(doc=18377)
0.82217383 = (MATCH) weight(searchField:清爽 in 18377) [DefaultSimilarity], result of:
0.82217383 = score(doc=18377,freq=2.0 = termFreq=2.0
), product of:
0.6270135 = queryWeight, product of:
5.934057 = idf(docFreq=310, maxDocs=43211)
0.105663545 = queryNorm
1.3112538 = fieldWeight in 18377, product of:
1.4142135 = tf(freq=2.0), with freq of:
2.0 = termFreq=2.0
5.934057 = idf(docFreq=310, maxDocs=43211)
0.15625 = fieldNorm(doc=18377)
10.566355 = (MATCH) FunctionQuery(product(map(int(store),1.0,9999999.0,const(1)),const(100))), product of:
100.0 = product(map(int(store)=10,min=1.0,max=9999999.0,target=const(1)),const(100))
1.0 = boost
0.105663545 = queryNorm
</str>

从上可以大致看出总分12.634275为文本分2.0679202加上库存加分10.566355。


扩展阅读:

http://wiki.apache.org/solr/DisMax

DisMax is an abbreviation Disjunction Max, and is a popular query mode with Solr.

Simply put, it's your choice for all user generated queries.

Out of the box, Solr uses the standard Solr query parser which is pretty stupid, understanding only syntactically correct boolean queries like "title:foo OR body:foo", it can only search one field by default, and it may very well throw an exception in your face if you put in some characters it does not like.

Therefore a new, more robust query mode was needed and the DisMax and ExtendedDisMax Query Parsers were born. They are designed to process simple user entered phrases (without heavy syntax) and search for the individual words across several fields using different weighting (boosts) based on the significance of each field, and it should never throw an exception.

Disjunction refers to the fact that your search is executed across multiple fields, e.g. title, body and keywords, with different relevance weights

Max means that if your word "foo" matches both title and body, the max score of these two (probably title match) is added to the score, not the sum of the two as a simple OR query would do. This gives more control over your ranking.

DisMax is usually the short name for the actual query parser, so don't be confused. The old DisMax parser has been around for some time, while the new and more advanced ExtendedDisMax parser was introduced in  Solr3.1 as experimental.

There is a Lucid Imagination Blog post that explains the origins and conceptual behavior of dismax functionality.


FunctionQuery:

http://wiki.apache.org/solr/FunctionQuery#map

ExtendedDisMax[edisMax]:

http://wiki.apache.org/solr/ExtendedDisMax

Solr 自定义排序[1]的更多相关文章

  1. solr特点三: 基于Solr实现排序定制化参考

    排序实现有N种形式,最低成本.最快响应时间是目标 一份索引,支持N种排序策略并且在线互不干扰是要考虑的每一种实现,处理的场景是不同的,不要千篇一律 020排序,从索引到效果,有不少坑,这篇文章没有细说 ...

  2. Java集合框架实现自定义排序

    Java集合框架针对不同的数据结构提供了多种排序的方法,虽然很多时候我们可以自己实现排序,比如数组等,但是灵活的使用JDK提供的排序方法,可以提高开发效率,而且通常JDK的实现要比自己造的轮子性能更优 ...

  3. DataTable自定义排序

    使用JQ DataTable 的时候,希望某列数据可以进行自定义排序,操作如下:(以中文排序和百分比排序为例) 1:定义排序类型: //百分率排序 jQuery.fn.dataTableExt.oSo ...

  4. 干货之UICollectionViewFlowLayout自定义排序和拖拽手势

    使用UICollectionView,需要使用UICollectionViewLayout控制UICollectionViewCell布局,虽然UICollectionViewLayout提供了高度自 ...

  5. DataGridView 绑定List集合后实现自定义排序

    这里只贴主要代码,dataList是已添加数据的全局变量,绑定数据源 datagridview1.DataSource = dataList,以下是核心代码. 实现点击列表头实现自定义排序 priva ...

  6. 【转】c++中Vector等STL容器的自定义排序

    如果要自己定义STL容器的元素类最好满足STL容器对元素的要求    必须要求:     1.Copy构造函数     2.赋值=操作符     3.能够销毁对象的析构函数    另外:     1. ...

  7. mysql如何用order by 自定义排序

    mysql如何用order by 自定义排序 id name roleId aaa bbb ccc ddd eee ,MySQL可以通过field()函数自定义排序,格式:field(value,st ...

  8. python 自定义排序函数

    自定义排序函数 Python内置的 sorted()函数可对list进行排序: >>>sorted([36, 5, 12, 9, 21]) [5, 9, 12, 21, 36] 但 ...

  9. 定制对ArrayList的sort方法的自定义排序

    java中的ArrayList需要通过collections类的sort方法来进行排序 如果想自定义排序方式则需要有类来实现Comparator接口并重写compare方法 调用sort方法时将Arr ...

随机推荐

  1. 【转&改进】Linux MPI 单机配置

    MPI的全称是Message Passing Interface即标准消息传递界面,可以用于并行计算.MPI有多种实现版本,如MPICH, CHIMP以及OPENMPI.这里我们采用MPICH版本. ...

  2. Unity 3D调用Windows打开、保存窗口、文件浏览器

    Unity调用Window窗口 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- 心分 ...

  3. div和span与块级和行内标签

    <div>标签: 是一个区块容器标记,<div></div>之间是一个容器, 可以包含段落.表格.图片等各种HTML元素. <span>标签: 没有实际 ...

  4. AE旋转

    精准对位: 好几个图层上的旋转点在一个位置上: 方法1:勾选网格,定点. 方法2:按住ctrl+r  调出尺寸.拖参考线,焦点自动吸附功能. 选中四张或者选中第一张,按shift键,选中最后一张(即可 ...

  5. pat--7-11 出栈序列的合法性(25 分)

    7-11 出栈序列的合法性(25 分) 给定一个最大容量为 M 的堆栈,将 N 个数字按 1, 2, 3, ..., N 的顺序入栈,允许按任何顺序出栈,则哪些数字序列是不可能得到的?例如给定 M=5 ...

  6. weixin-java-mp集成微信公众号自带客服功能

    电脑端登录公众号管理后台,[添加功能插件]开通客服功能,输入"人工客服"接入客服热线 底部有我的微信二维码,如有问题,可加好友进行技术交流! ​ ​ ​ ​ ​ ​ ​ weixi ...

  7. linux 的压缩 打包

    1.压缩打包,常见的命令:gzip bzip2 xz zip tar gzip:  不能压缩目录 gip  -[0-9]  file_name   压缩级别, 默认是6 gzip  file_nane ...

  8. C语言常用命令

    ## 基本流程:创建——编辑——编译.链接——执行$ touch 1-1.c$ vim 1-1.c # include <stdio.h>int main{printf("... ...

  9. Elasticsearch基本用法(1)--原生操作

    2.2.创建索引 2.2.1.语法 创建索引的请求格式: 请求方式:PUT 请求路径:/索引库名 请求参数:json格式: { "settings": { "number ...

  10. java 调用process

    java调用process 有两种实现方法,一是使用Runtime类,二是使用Process类. 我在最近的项目里用的是Runtime类,接下来写下总结. 有图有真相(在网上学来一句话) packag ...