在solr中使用edismax查询解析器在不同字段上使用不同的搜索词

时间:2018-11-19 08:45:27

标签: solr edismax

我有一个在多个字段中搜索的solr查询。为了增加召回率,我还进行通配符和模糊查询。我使用edismax查询解析器,因为我还必须使用boost函数。

以下是查询的相关部分:

defType=edismax&q= (wine AND company) OR  (wine* AND company*)^0.5  OR (wine* OR company*)^0.01 OR (wine~1 AND company~1)^0.02&qf=primary_tags^1 secondary_tags_s^0.2 merchant_name_s^0.5

现在,以上查询在所有字段(wine AND company) OR (wine* AND company*)^0.5 OR (wine* OR company*)^0.01 OR (wine~1 AND company~1)^0.02上搜索primary_tags^1 secondary_tags_s^0.2 merchant_name_s^0.5,但是我想要的是(wine AND company)仅应在merchant_name_s^0.5,{{1 }}在(wine* AND company*)^0.5 OR (wine* OR company*)^0.01上,primary_tags^1(wine~1 AND company~1)^0.02上。

实现该目标的正确方法是什么?

1 个答案:

答案 0 :(得分:0)

edismax supports the full Lucene syntax

q=merchant_name:(wine AND company)^0.5 primary_tags:(wine* AND company*)^0.5 primary_tags:(wine* OR company*)^0.01 secondary_tags_s:(wine~1 AND company~1)^0.0004

应该与您描述的查询相同。我将secondary_tags_s部分合并为一个权重,并分隔了primary_tags子句,因为无论如何,默认行为是两个术语之间的OR(取决于q.op)。 / p>