lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frank Wesemann <>
Subject Re: How to achive this kind of document ordering
Date Wed, 19 May 2010 20:53:45 GMT
Hi Dragan,
> First, all results are ordered by SortFieldA in ascending order. Than 
> by SortFieldB so that all documents with the same SortFieldA value are 
> ordered in "levels" structure. Each level consists of documents with 
> distinct SortFieldB values.
> So, the requirenment is to show documents from first level first, than 
> second level, and so on.
> It will not be possible to order documents while indexing, so I will 
> need search time ordering.
> Is this achievable with lucene? What would be the best approach to 
> solve this without huge performance impact on multimillion documents 
> index?
You might want to have a look at and the 
accompanied Comparator Classes
For a similar approach ( I had to sort by the quantity on a certain 
Field ) I borrowed a lot of the idea of these classes.
 From the basic principles therein I derived DocumentComparators, which 
compare not only FieldValues but whole documents.
The outcome is not one sorted list, but a structure of lists which I 
combine in nested
while( list<SortFieldA>.hasNext() ) {
    overallResult.add ( listOfSortFieldA.get( listOfSortFieldB).next() )

Performance is ofcourse affected by numbers of documents you want to return.

mit freundlichem Gruß,

Frank Wesemann
Fotofinder GmbH         USt-IdNr. DE812854514
Software Entwicklung    Web:
Potsdamer Str. 96       Tel: +49 30 25 79 28 90
10785 Berlin            Fax: +49 30 25 79 28 999

Sitz: Berlin
Amtsgericht Berlin Charlottenburg (HRB 73099)
Geschäftsführer: Ali Paczensky

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message