title: Lucene: how to get the score of a document
body: <p>I want to output the score of documents. The code I write for this is that:</p>
  
  <pre><code>IndexReader reader = IndexReader.open(FSDirectory.open(indexDir));
  IndexSearcher searcher = new IndexSearcher(reader);
  Analyzer analyzer = new IKAnalyzer();
  QueryParser parser = new QueryParser(Version.LUCENE_31, "title",
              analyzer);
  Query q = null;
  q = parser.parse("MacOS");
  TopDocs docs = searcher.search(q, 10);
  ScoreDoc[] hits = docs.scoreDocs;
  for(int i=0;i&lt;hits.length;++i){
    System.out.println(hits[i].score);
  }
  </code></pre>
  
  <p>but the output is NaN. I want to know how to get the score of the document.</p>