AnsweredAssumed Answered

URGENT:Sorting Lucene result on tokenized property possible?

Question asked by serverok on Apr 14, 2009
Latest reply on Jan 18, 2010 by kbootz
Hi all,
we have the problem with sorting of lucene search result by some properties which are indexed and tokenised.

What is the best/fastest method to correctly sort lucene results by properties that contain multiple tokens (http://lucene.apache.org/java/2_3_2/api/org/apache/lucene/search/Sort.html)? :
<index enabled="true">
   <atomic>true</atomic>
   <stored>false</stored>
   <tokenised>true</tokenised>
</index>

Is the only choice to sort "manually" in the web script after running the lucene query without sorting?

I tried use JS sort function:
var result = search.luceneSearch(query);
result.sort(Sorting);
….
function Sorting(a, b) {
   var x = a.properties['cm:title'];
   var y = b.properties['cm:title'];
   return ((x > y) ? 1 : -1);
}

but if we have a big list of content in lucene result (100, 200 and more) - then this section
var x = a.properties['cm:title'];
var y = b.properties['cm:title'];
very long working.

Also we have around 50 properties to each content (custom Model) - maybe this is the reason why we have so long going on reading the value of properties?

I would be very grateful for help in solving this problem.

Thank's,
Oleg Koval

Outcomes