abhay patel
abhay patel

Reputation: 73

Solr search getting different scrore of products with OR condtion in query

We are facing problem with query where we are using multiple 'OR' conditions to search products from solr documents

below is our searching condition with "OR"

<str name="q">(product_related_kword:(leather AND shopping AND bags)) OR (product_related_kword:(paper AND shopping AND bags))</str>

here we are searching for tow products "leather shopping bags" && "paper shopping bags"

Now we got the result like this

<str name="product_name">leather Paper shopping bag</str>
<float name="score">58.45</float></doc>

<str name="product_name">Paper shopping bag</str>
<float name="score">56.45</float></doc>

<str name="product_name">leather shopping bags</str>
<float name="score">56.45</float></doc>

why we got different 'score' for the product in top "leather Paper shopping bag"

i want equal score for the search results if matched in the document with 'OR' condition

Upvotes: 0

Views: 82

Answers (1)

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8658

You can use the dismax here. The dismax comes with many params and one of them is phrase fields.

The pf (Phrase Fields) Parameter Once the list of matching documents has been identified using the fq and qf parameters, the pf parameter can be used to "boost" the score of documents in cases where all of the terms in the q parameter appear in close proximity.

The format is the same as that used by the qf parameter: a list of fields and "boosts" to associate with each of them when making phrase queries out of the entire q parameter.

You can read more about dismax here

The mm (Minimum Should Match) Parameter When processing queries, Lucene/Solr recognizes three types of clauses: mandatory, prohibited, and "optional" (also known as "should" clauses). By default, all words or phrases specified in the q parameter are treated as "optional" clauses unless they are preceded by a "+" or a "-". When dealing with these "optional" clauses, the mm parameter makes it possible to say that a certain minimum number of those clauses must match. The DisMax query parser offers great flexibility in how the minimum number can be specified.

Upvotes: 1

Related Questions