Different search term on different fields using edismax query parser in solr

被刻印的时光 ゝ 提交于 2021-02-11 12:49:33

问题


I have a solr query that searches on multiple fields. To increase the recall, I also do wildcard and fuzzy query. I use edismax query parser because I also have to use boost function.

Here is the relevant parts of the query:

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

Now, the above query searches for (wine AND company) OR (wine* AND company*)^0.5 OR (wine* OR company*)^0.01 OR (wine~1 AND company~1)^0.02 on all the fields primary_tags^1 secondary_tags_s^0.2 merchant_name_s^0.5, but what I want is that (wine AND company) should only be searched on merchant_name_s^0.5, (wine* AND company*)^0.5 OR (wine* OR company*)^0.01 on primary_tags^1 and (wine~1 AND company~1)^0.02 on secondary_tags_s^0.2.

What would be the correct way to achieve that?


回答1:


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

should be about the same query you've described. I've combined the secondary_tags_s part into one single weight and seprated the primary_tags clauses, since the default behavior is OR between the terms anyway (depending on q.op).



来源:https://stackoverflow.com/questions/53371028/different-search-term-on-different-fields-using-edismax-query-parser-in-solr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!