I am using Solr-5.0.0. I am searching on a field product_name
.
I need to add some rules to get relevant results.
If I search for a word, if exact match exists , it should come first.
Ex: if I search for laptop
,it should return exact product_name
with laptop first.
If I search for more than one word , it should obey rule 1. along with least word length distanced names come first.
Ex: if I search dell laptop
, it should return Dell laptop first than dell inspiron laptop.
If I search for words it should not return results contains with
or without
words.
Ex: in search laptop bag
, it should not give dell laptop with bag or dell laptop without bag results first.
How can I achieve these rules based search relevant results at query time?
My application is in java, so Java answer is appreciated.
The “boost” parameter is very similar to the “bf” parameter, but instead of adding its result to the final score, it will multiply it. This is only available in the “Extended Dismax Query Parser” or the “Lucid Query Parser”.
qf. Query Fields: specifies the fields in the index on which to perform the query. If absent, defaults to df . mm. Minimum "Should" Match: specifies a minimum number of clauses that must match in a query.
To begin with, you should use the dismax or edismax query parser instead of the default (lucene).
Then you can improve relevancy using different parameters :
with
or without
don't appear. See here. For example : bq=(*:* -with -without)^999
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With