示例#1
0
        private IndexSearcher Searcher(bool allowRefreshSearcher)
        {
            if (this._searcher != null && (!_modified || !allowRefreshSearcher))
            {
                return(this._searcher);
            }

            try
            {
                IndexReader newReader = this._reader == null?DirectoryReader.open(this._writer) : DirectoryReader.openIfChanged(( DirectoryReader )this._reader);

                if (newReader == null)
                {
                    return(this._searcher);
                }
                LuceneUtil.Close(_reader);
                this._reader = newReader;
                LuceneUtil.Close(_searcher);
                _searcher = new IndexSearcher(_reader);
            }
            catch (IOException e)
            {
                throw new Exception(e);
            }
            finally
            {
                if (allowRefreshSearcher)
                {
                    this._modified = false;
                }
            }
            return(this._searcher);
        }
示例#2
0
 internal override void Close()
 {
     LuceneUtil.Close(this._writer);
     LuceneUtil.Close(this._reader);
     LuceneUtil.Close(this._searcher);
 }