Solr: boost based on existence of a field, disregarding that field's contents

扶醉桌前 提交于 2019-12-23 16:59:16

问题


I'd like to boost a query based on the existence of a field in the document, regardless of the contents of that field. Let's say a document has a field containing an id value of a photo, and I'd like documents that have photos to come up first on the search.

The photo id value would be irrelevant to the search query but the existence of the field is what would matter. How to do it?


回答1:


As described here, field:[* TO *] will match all documents with the field and can be used by you for boosting.

With DisMax, bq can be used for boosting as described here. Add <str name="bq">field:[* TO *]^10</str> to the requestHandler in solrconfig.xml

Note that the above does not guarantee all documents with photos will come up at the top followed by documents that don't have photos. However, I think that the above should work well for your use case - please try it out and let me know if you really need guaranteed, absolute ordering.



来源:https://stackoverflow.com/questions/9723644/solr-boost-based-on-existence-of-a-field-disregarding-that-fields-contents

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