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 <ukour...@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-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to