|
需求:商品排序,无库存的商品排在后面(排序)。
搜索:
默认搜索: 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)"
观察打分的细节:
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
从上可以大致看出总分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
|
|