我有一个搜索多个字段的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
现在,上面的查询在所有字段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
,但我想要的是(wine AND company)
应该只在merchant_name_s^0.5
上搜索,(wine* AND company*)^0.5 OR (wine* OR company*)^0.01
在primary_tags^1
上搜索,而(wine~1 AND company~1)^0.02
在secondary_tags_s^0.2
上搜索。
实现这一目标的正确方法是什么?
edismax支持完整的Lucene语法。
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
(。