Lucene 精确排序 [英] Lucene exact ordering

查看:17
本文介绍了Lucene 精确排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在不太了解如何实现一个像样的 Lucene 排序或排名方面遇到了这个长期问题.假设我有一个城市及其人口的列表.如果有人搜索新"或伦敦",我想要按人口排序的前缀匹配列表,并且我使用前缀搜索和反转的按字段排序,其中有一个人口字段,即纽约新墨西哥州;或伦敦,伦敦德里.

但是,我也总是希望完全匹配的名称位于顶部.因此,在伦敦"的情况下,列表应该显示伦敦,伦敦,伦敦德里",其中第一个伦敦在英国,第二个伦敦在康涅狄格州,即使伦敦德里的人口比伦敦 CT 多.

有人有单一的查询解决方案吗?

解决方案

dlamblin,让我看看我是否理解正确:排序顺序优先于完全匹配.我建议您将搜索与排序分开并使用 CustomSorter 进行排序:这是一个描述自定义的博客条目分拣机.经典的 Lucene 书 很好地描述了这一点.p>

I've had this long term issue in not quite understanding how to implement a decent Lucene sort or ranking. Say I have a list of cities and their populations. If someone searches "new" or "london" I want the list of prefix matches ordered by population, and I have that working with a prefix search and an sort by field reversed, where there is a population field, IE New Mexico, New York; or London, Londonderry.

However I also always want the exact matching name to be at the top. So in the case of "London" the list should show "London, London, Londonderry" where the first London is in the UK and the second London is in Connecticut, even if Londonderry has a higher population than London CT.

Does anyone have a single query solution?

解决方案

dlamblin,let me see if I get this correctly: You want to make a prefix-based query, and then sort the results by population, and maybe combine the sort order with preference for exact matches. I suggest you separate the search from the sort and use a CustomSorter for the sorting: Here's a blog entry describing a custom sorter. The classic Lucene book describes this well.

这篇关于Lucene 精确排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆