On 3/17/06, Java Programmer <[EMAIL PROTECTED]> wrote: > > Hello, > I tried to search myself for soultion, but without any good result, so I want > to ask group. > My problem concerns result grouping, the best example will be Google search > where you have results sorted by relevance, and also grouped by domain (they > have little indent/margin). In my project I want to get similar > functionality, without very huge CPU consumption. > > Can you share any helpful hints ? > > Best Regards, > Adr >
Hello, I have written some code to do sorting form me (it's not perfect, maybe it's even very poor solution, but I'm still learning). So if you have a time please take a look: long sort_start = new Date().getTime(); Map<String,ArrayList<Integer>> domains = new HashMap<String,ArrayList<Integer>>(); List<String> results = new ArrayList<String>(); int i = 0; while(i<hits.length() && i<500){ Document doc = hits.doc(i); String url = doc.get("domain"); if(!domains.containsKey(url)){ domains.put(url,new ArrayList<Integer>()); results.add(url); } domains.get(url).add(i); i++; } long sort_end = new Date().getTime(); so I'm grouping results for domains in Lists to prevent order of score, such ordered groups I put into Map and key of that Map I put into another List to prevent order of most scored domains, so in result I get: - domain A score 1.0 -- domain A score 0.6 - domain B score 0.9 etc. I put this code into servlet (Tomcat 5.5) and it's working but ... when I made first query it take a long time to run whole sorting process eg. 4900 ms, but when I run same query again (eg with paging), it's run very quickly eg 40 ms - why such thing is happen? Is there any optimizing in Lucene, or any kind of caching? When restarting servlet for queries which already were asked results are at once, but new queries always take long time to process. Maybe I'm miss something when read documentation - someone can give me an explanation? Best regards, Adr --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]