问题描述
这是我的情况;
我的架构中有一个名为elmo_field
的字段.我希望elmo_field
应该具有有效值.即
I have a field at my schema named elmo_field
. I want that elmo_field
should have payloaded values. i.e.
dorothy|0.46 sesame|0.37 big bird|0.19 bird|0.22
当用户搜索关键字(即dorothy
)时,我想在常规得分上添加0.46.如果用户搜索big bird
,则应添加0.19,如果用户搜索bird
,则应添加0.22(添加有效载荷-或添加有效载荷*归一化系数).
When a user searches for a keyword i.e. dorothy
I want to add 0.46 to usual score. If user searches for big bird
, 0.19 should be added and if user searches for bird
, 0.22 should be added (payloads are added - or payloads * normalize coefficient will be added).
我的意思是我将在Solr模式的其他字段中搜索索引.而且我将同时在elmo_field
进行另一次搜索(这是一个完全匹配的搜索),如果匹配,我将增加有效载荷的分数.
I mean I will make a search on my index at my other fields of solr schema. And I will make another search (this one is an exact match search) at elmo_field
at same time and if matches something I will increase score with payloads.
有什么想法吗?
推荐答案
我已经实现了自定义相似性包装器.对于平常的事情,我使用了DefaultSimilarity.如果一个字段是有效字段,则使用由我实现的另一个相似性.该相似性类只是忽略有效负载值.我还实现了一个查询解析器,它是edismax的自定义版本.通过这种方法,我可以将有效负载值添加到文档分数中.
I've implemented a custom similarity wrapper. For usual things I've used DefaultSimilarity. If a field is a payloaded field another similarity that is implemented by me is used. That similarity class just ignores payload value. I've also implemented a query parser that is a customized version of edismax. With that approach I could add payload value into the document score.
这篇关于根据Solr中多值字段的有效负载为得分加分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!