title: How to Read Lucene.net returned query results
body: <p>I can't figure out how to read the results returned from a Lucene.net query.</p>
  
  <p>I have this code:</p>
  
  <p><strong>Initialization</strong></p>
  
  <pre><code>  var test = new Document();
              test.Add(new Field("id", "1", Field.Store.YES, Field.Index.NOT_ANALYZED));
              test.Add(new Field("title", "the title", Field.Store.YES, Field.Index.ANALYZED));
              test.Add(new Field("body", "the body of the question", Field.Store.YES, Field.Index.ANALYZED));
  
              string path = HttpRuntime.AppDomainAppPath + "\\LuceneIndex";
              Lucene.Net.Store.Directory directory = FSDirectory.Open(new DirectoryInfo(path));
              Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);
  
              var writer = new IndexWriter(directory, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
              writer.AddDocument(test);
  
              writer.Optimize();
              writer.Flush(true, true, true);
              writer.Dispose();
  
              directory.Dispose();
              analyzer.Dispose();
  </code></pre>
  
  <p><strong>Reading the data</strong></p>
  
  <pre><code>Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);
  
  QueryParser parser = new QueryParser(Version.LUCENE_30, "ti", analyzer);
  
  string path = HttpRuntime.AppDomainAppPath + "\\LuceneIndex";
  Lucene.Net.Store.Directory directory = FSDirectory.Open(new DirectoryInfo(path));
  
  IndexSearcher searcher = new IndexSearcher(directory);
  
  Query query = new TermQuery(new Term("body", "body"));
  
  
  TopDocs docs =  searcher.Search(query,5);
  analyzer.Dispose();
  searcher.Dispose();
  </code></pre>
  
  <p>I inspected the data in <code>docs</code>, but it doesn't contain the Id of the matched search results.</p>