title: Lucene.Net creates empty index
body: <p>I'm using Lucene.Net + SimpleLucene in my asp .net mvc application. There is a problem with creating index from the database. The index seem to start being created well, but all i get is 5 files with sizes of 0 and 1 KB: </p>
  
  <pre>
  _0.fdt             0KB  
  _0.fdx             0KB  
  segment.gen        1KB  
  segments_1         1KB  
  write.lock         0KB
  </pre>
  
  <p>I have such a model from which i want to create index:</p>
  
  <pre><code>public class Feed : BaseEntity
  {
  
      public virtual string Address { get; set; }
  
      public virtual string Title { get; set; }
  
      public virtual string Description { get; set; }
  
      public virtual bool IsExported { get; set; }
  
      public virtual DateTime LastUpdateTime { get; set; }
  
      public virtual int UserId { get; set; }
  
      public virtual User User { get; set; }
  
      public virtual ICollection&lt;FeedPost&gt; Posts { get; set; }
  
      public virtual ICollection&lt;Tag&gt; Tags { get; set; }
  
      public virtual Filter Filter { get; set; }
  }
  </code></pre>
  
  <p>I have implemented two necessary interfaces from lucene library: IIndexDefinition and IResultDefinition:</p>
  
  <pre><code>public class FeedIndexDefinition : IIndexDefinition&lt;Feed&gt;
  {
      public Document Convert(Feed entity)
      {
          var document = new Document();
          document.Add(new Field("id", entity.Id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
          document.Add(new Field("description", entity.Description, Field.Store.YES, Field.Index.ANALYZED));
          document.Add(new Field("title", entity.Title, Field.Store.YES, Field.Index.ANALYZED));
          return document;
      }
  
      public Term GetIndex(Feed entity)
      {
          return new Term("id", entity.Id.ToString());
      }
  }
  
  
  public class SearchResultDefinition : IResultDefinition&lt;Feed&gt;
  {
      public Feed Convert(Document document)
      {
          Guid id = Guid.Parse(document.GetValue&lt;String&gt;("id"));
          var context = new UnitOfWork();
          Feed feed = context.FeedRepository.GetById(id);
          return feed;
      }
  }
  </code></pre>
  
  <p>Indexing is performed this way:</p>
  
  <pre><code>    private static readonly UnitOfWork Context = new UnitOfWork();
      public static void IndexAllFeeds()
      {
          var indexWriter = new DirectoryIndexWriter(new DirectoryInfo(IndexPath), true);
          var feeds = Context.FeedRepository.Get().AsEnumerable();
          var indexService = new IndexService(indexWriter);
          IEnumerable&lt;Feed&gt; array = feeds.ToList();
          indexService.IndexWriter.IndexOptions.OptimizeIndex = true;
          indexService.IndexEntities(array, new FeedIndexDefinition());
      }
  </code></pre>
  
  <p>And here is the method that creates the query to perform the search</p>
  
  <pre><code>public FeedQuery Search(string keywords)
      {
          if(!String.IsNullOrEmpty(keywords))
          {
              String[] fields = {"title", "description"};
              var parser = new MultiFieldQueryParser(
                  Lucene.Net.Util.Version.LUCENE_29,
                  fields,
                  new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29));
              Query q = parser.Parse(keywords);
              this.AddQuery(q);
          }
          return this;
      }
  </code></pre>
  
  <p>And finally here is the method in the controller which should find the results</p>
  
  <pre><code>private static IEnumerable&lt;Feed&gt; SearchUserFeeds(string keywords)
      {
          keywords = "title5 description5 title4 description4 title3 description3";
          IEnumerable&lt;Feed&gt; searchResults;
          var indexSearcher = new DirectoryIndexSearcher(new DirectoryInfo(LuceneHelper.IndexPath));
          using (var searchService = new SearchService(indexSearcher))
          {
              var query = new FeedQuery().Search(keywords);
              searchResults = searchService.SearchIndex(query.Query, new SearchResultDefinition()).Results;
          }
          return searchResults;
      }
  </code></pre>
  
  <p>If someone is able to point me to the problem i will appreciate.</p>