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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to