Esempio n. 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);
        }
Esempio n. 2
0
 internal virtual Query QueryForGet(string key, object value)
 {
     if (value is ValueContext)
     {
         object realValue = (( ValueContext )value).Value;
         if (realValue is Number)
         {
             Number number = ( Number )realValue;
             return(LuceneUtil.RangeQuery(key, number, number, true, true));
         }
     }
     return(new TermQuery(new Term(key, value.ToString())));
 }
Esempio n. 3
0
 internal override void Close()
 {
     LuceneUtil.Close(this._writer);
     LuceneUtil.Close(this._reader);
     LuceneUtil.Close(this._searcher);
 }