我正在尝试在 SOLR 3.5.0 中设置提升处理程序,我需要以下等效于 dismax 格式的查询,它根据匹配类型在同一字段上定义不同的提升值(精确匹配获得 200,而通配符匹配获得 100) .
q=name:(foo*^100.0 或 foo^200.0)
This is one way to solve this problem.
Keep a text field with only WhiteSpaceTokenizer (and maybe LowerCaseFilter depending on your case-sensitivity needs). Use this field for the exact match. Let's call this field name_ws
.
Instead of using a wild-card query on name_ws
, use a text-type copy field with EdgeNGramTokenizer in your analyzer chain, which will output tokens like:
food -> f, fo, foo, food
Let's call this field name_edge
.
Then you can issue this dismax query:
q=foo&defType=dismax&qf=name_ws^200+name_edge^100
(Add debugQuery=on
to verify if the scoring works the way you want.)