lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Yu <ukour...@gmail.com>
Subject sort by field and score
Date Tue, 27 Nov 2012 03:51:21 GMT
Hi All,


Now  I want to sort by a field and the relevance
For example

SortField sortField[] = {new SortField("id", new
CustomComparatorSource(bitSet)),SortField.FIELD_SCORE};
Sort sort = new Sort(sortField);
TopDocs topDocs = indexSearcher.search(query, 10,sort);

if (0 < topDocs.totalHits) {
            for (ScoreDoc scoreDoc : topDocs.scoreDocs) {

System.out.println(indexSearcher.doc(scoreDoc.doc).get("id"));
                System.out.println("score is " + scoreDoc.score);

 System.out.println(indexSearcher.doc(scoreDoc.doc).get("name"));
            }
        }

I found that the search result sort just by [new SortField("id", new
CustomComparatorSource(bitSet))]
[SortField.FIELD_SCORE] does not work at all


PS: my lucene version is 3.6

does anybodu know the reason or how to solve it ?


Thanks ,
Andy

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message