Пример #1
0
        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));
        }
Пример #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));
 }