基于 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
,它应该首先返回与 laptop 完全相同的product_name
.
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 notebook
,它应该首先返回Dell notebook,而不是dell inspiron notebook.
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.
如果我搜索单词,它不应该返回包含 with
或 without
单词的结果.例如:在搜索laptop bag
时,不应该先给出dell notebook with bag 或dell notebook without bag 的结果.
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 来提升没有出现
with
或without
字样的文档.参见此处.例如: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屋!