Solr rule based boost

北慕城南 提交于 2019-12-18 13:23:34

问题


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.

  1. 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.

  2. 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.

  3. 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.


回答1:


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 :

  1. : Use qf to boost your product_name field.
  2. : Use pf to boost your product_name field where all of the terms in the q parameter appear in close proximity.
  3. : Use bq to boost documents where the words with or without don't appear. See here. For example : bq=(*:* -with -without)^999


来源:https://stackoverflow.com/questions/30621679/solr-rule-based-boost

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!