From lucene-dev-return-3665-qmlist-jakarta-archive-lucene-dev=nagoya.apache.org@jakarta.apache.org Thu Jun 05 21:52:57 2003 Return-Path: Delivered-To: apmail-jakarta-lucene-dev-archive@apache.org Received: (qmail 15197 invoked from network); 5 Jun 2003 21:52:55 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 5 Jun 2003 21:52:55 -0000 Received: (qmail 4038 invoked by uid 97); 5 Jun 2003 21:55:15 -0000 Delivered-To: qmlist-jakarta-archive-lucene-dev@nagoya.betaversion.org Received: (qmail 4031 invoked from network); 5 Jun 2003 21:55:15 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 5 Jun 2003 21:55:15 -0000 Received: (qmail 14931 invoked by uid 500); 5 Jun 2003 21:52:53 -0000 Mailing-List: contact lucene-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Developers List" Reply-To: "Lucene Developers List" Delivered-To: mailing list lucene-dev@jakarta.apache.org Received: (qmail 14920 invoked from network); 5 Jun 2003 21:52:53 -0000 Received: from mhro1.mayo.edu (129.176.212.21) by daedalus.apache.org with SMTP; 5 Jun 2003 21:52:53 -0000 Received: from excsrv01.mayo.edu (excsrv01.mayo.edu [129.176.100.48]) by mhro1.mayo.edu with ESMTP for lucene-dev@jakarta.apache.org; Thu, 5 Jun 2003 16:52:55 -0500 Received: by excsrv01.mayo.edu with Internet Mail Service (5.5.2653.19) id ; Thu, 5 Jun 2003 16:52:54 -0500 Message-Id: <818623B5FD23D51193200002B32C076106FE4D0C@excsrv44.mayo.edu> From: "Armbrust, Daniel C." To: 'Lucene Developers List' Subject: RE: Document scoring - should I file a bug report? Date: Thu, 5 Jun 2003 16:52:47 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Heres my quasi code (I just copied and pasted out the important pieces)..... final ArrayList tempHits = new ArrayList(index.maxDoc() / 4); searcher.search(query, filter, new HitCollector() { public void collect(int doc, float score) { tempHits.add(new LuceneHits(doc, score)); } }); luceneHits = (LuceneHits[])tempHits.toArray(new LuceneHits[tempHits.size()]); Arrays.sort(luceneHits, new HitComparator()); //normalize the scores float scoreNorm = 1.0f; if (luceneHits.length > 0 && luceneHits[0].score > 1.0f) scoreNorm = 1.0f / luceneHits[0].score; for (int i = 0; i < luceneHits.length; i++) luceneHits[i].score = luceneHits[i].score * scoreNorm; public class LuceneHits { public int doc; public float score; public LuceneHits(int doc, float score) { this.doc = doc; this.score = score; } } public class HitComparator implements Comparator { public int compare(Object arg0, Object arg1) { LuceneHits a = (LuceneHits)arg0; LuceneHits b = (LuceneHits)arg1; if (a.score < b.score) return 1; else if (a.score == b.score) return 0; else return -1; } } --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-dev-help@jakarta.apache.org