lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <ian....@gmail.com>
Subject Re: sort by field and score
Date Tue, 27 Nov 2012 10:51:30 GMT
What are you getting for the scores?  If it's NaN I think you'll need
to use a TopFieldCollector.  See for example
http://www.gossamer-threads.com/lists/lucene/java-user/86309


--
Ian.


On Tue, Nov 27, 2012 at 3:51 AM, Andy Yu <ukouryou@gmail.com> wrote:
> 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

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message