需求:商品排序,无库存的商品排在后面(排序)。
搜索:
默认搜索: 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)"
观察打分的细节:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <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
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性