Lucene精确排序 [英] Lucene exact ordering

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

问题描述

我遇到了一个长期问题,就是不太了解如何实现不错的Lucene排序或排名.假设我有一个城市及其人口清单.如果有人搜索"new"或"london",我希望按人口顺序排列前缀匹配列表,而我要使用前缀搜索和反向按字段排序的方法(存在人口字段,即新墨西哥州纽约市) ;或伦敦,伦敦德里.

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

有人有一个查询解决方案吗?

解决方案

dlamblin,请让我看看是否正确:您要进行基于前缀的查询,然后按总体对结果进行排序,并可能将优先选择完全匹配的排序顺序. 我建议您将搜索与排序分开,并使用CustomSorter进行排序: 这是描述自定义的博客条目分类器. 经典的Lucene书很好地描述了这一点. >

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天全站免登陆