public IndexReader Create()
        {
            var directory = _directoryFactory.Create();

            if (IndexReader.IndexExists(directory))
            {
                return(IndexReader.Open(directory, true));
            }

            //create an index and then open
            using (var writer = _writerFactory.Create()) {
                writer.Commit();
            }
            return(IndexReader.Open(_directoryFactory.Create(), true));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Always create and use in `using` construct.  This must be disposed of.
 /// </summary>
 /// <returns></returns>
 public IndexWriter Create()
 {
     return(new IndexWriter(_directoryFactory.Create(), _analyzer, IndexWriter.MaxFieldLength.UNLIMITED));
 }