使用 lucene 发出数据库中的每个文档
我有一个索引,需要通过标准搜索获取所有文档,即使文档不受欢迎,仍然按相关性排名。
我的第一个想法是添加一个始终匹配的字段,但这可能会使相关性分数变形。
I've got an index where I need to get all documents with a standard search, still ranked by relevance, even if a document isn't a hit.
My first idea is to add a field that is always matched, but that might deform the relevance score.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
BooleanQuery
将原始查询与MatchAllDocsQuery
组合起来。在将MatchAllDocsQuery
与主查询结合之前,您可以通过将其提升设置为零来减轻这对评分的影响。这样您就不必向索引添加其他虚假字段。例如:
这应该为您提供来自
standardQuery
的点击,然后是索引中其余文档的点击。Use a
BooleanQuery
to combine your original query with aMatchAllDocsQuery
. You can mitigate the effect this has on scoring by setting the boost on theMatchAllDocsQuery
to zero before you combine it with your main query. This way you don't have to add an otherwise bogus field to the index.For example:
This should give you hits from
standardQuery
followed by the rest of the documents in the index.