lucene group bobo-Browse to sort the problem

Encountered a problem today with bobo grouped in ascending price actually two standing in the front than the 1000. Obviously it is a string sort.

100

1000

2

20

201

Then I went online to find a moment in this regard the article, the basic not be found. No option but to look at their source. Silly very naive BrowseRequest found in setFacetSpecO (String name, FacetSpec facetSpec) method. FacetSpec class have setOrderBy (FacetSortSpec order) method.

When the order = FacetSortSpec.OrderByCustom can be customized to sort by.

Call setCustomComparatorFactory (ComparatorFactory comparatorFactory); when I wrote a method to achieve after ComparatorFactory interface. Indeed achieved a sort, but only achieved a sort of grouping fields. Carefully looked at the code, the original starting point of my wrong. This class has always been a class action group. I would like to sort the results with the present is not here. Then I went to read under the lucene source. Found FieldSortedHitQueue this class, this class is the class to sort the results. Similarly, in the bobo, I also hit the LuceneSortDocComparatorFactory, but there had to say something a little problem. In the bobo in it if you do not set the default sorting rules, so it will not enter LuceneSortDocComparatorFactory category. It is the default sort in SimpleFacetHandler under getScoreDocComparator (). The getScoreDocComparator return is FacetDataCache the getScoreDocComparator (), how to do it. The simplest is to write their own class inheritance SimpleFacetHandler. The getScoreDocComparator return to the null, said that with the use of lucene sort. Well basically the problem here has been resolved.

If you have any questions and what advice can give me a message.

分类:Java 时间:2010-02-03 人气:507
分享到:
blog comments powered by Disqus

相关文章

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.117 (s). 12 q(s)