基于Solr规则的提升 [英] Solr rule based boost
问题描述
我正在使用 Solr-5.0.0 。我在字段 product_name
上搜索。
我需要添加一些规则来获得相关结果。
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.
-
如果我搜索一个单词,如果完全匹配存在,它应该是第一位的。
例如:如果我搜索笔记本电脑
,它应该使用 laptop 返回完全product_name
em> first。
If I search for a word, if exact match exists , it should come first. Ex: if I search for
laptop
,it should return exactproduct_name
with laptop first.
如果我搜索多个单词,它应该遵守规则1.并且最少的单词长度距离名称首先出现。
例如:如果我搜索 dell laptop
,它应该首先返回戴尔笔记本电脑而不是 dell inspiron laptop 。
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.
如果我搜索单词,则不应返回包含的结果
或没有
字样。
Ex:在搜索笔记本电脑包
中,它不应该给 dell笔记本电脑包带或戴尔笔记本电脑没有包结果第一。
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?
我的应用程序是在java中,所以感谢Java答案。
My application is in java, so Java answer is appreciated.
推荐答案
首先,您应该使用 dismax 或 edismax 查询解析器而不是默认值( lucene )。
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 :
- :使用 qf 来提升你的product_name字段。
- :使用 pf 来提升你的product_name字段,其中q参数中的所有术语都非常接近。
- :使用 bq 来提升单词
带
或没有
不会出现。 请参阅此处。例如:bq =(*:* -with -without)^ 999
- : Use qf to boost your product_name field.
- : Use pf to boost your product_name field where all of the terms in the q parameter appear in close proximity.
- : Use bq to boost documents where the words
with
orwithout
don't appear. See here. For example :bq=(*:* -with -without)^999
这篇关于基于Solr规则的提升的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!