Based on Solr rules

I am using Solr-5.0.0 . I am looking in the product_name field. I need to add some rules to get relevant results.

  • If I'm looking for a word, if an exact match exists, it should be the first. Example: if I search for laptop , it must first return the exact product_name with the laptop.

  • If I am looking for more than one word, it must obey rule 1. along with the smallest distance between long word names. Example: if I am looking for a dell laptop , it should return the Dell laptop first than the Dell Inspiron laptop.

  • If I search for words, it should not return results containing the words with or without . Example: in a laptop bag search, he should not give a Dell laptop with a bag or dell laptop without bags.

How can I achieve these rule-based relevant search results during a query?

My application is in java, so a Java response is welcome.

+6
source share
1 answer

For starters, you should use dismax or edismax instead of the default ( lucene ).

Then you can improve relevance using different parameters:

  • : use qf to increase the product_name field.
  • : Use pf to increase the product_name field, where all members of q are displayed in close proximity.
  • : Use bq to enlarge documents where the words with or without not displayed. See here . For example: bq=(*:* -with -without)^999
+1
source

Source: https://habr.com/ru/post/988453/


All Articles