예제 #1
0
        internal void LoadIndex(LuceneSearcherState <TId, TDoc> state)
        {
            BeginLoad?.Invoke();

            bool stateExisted = State != null;

            if (!stateExisted)
            {
                State = state;
            }

            var index = CreateIndex(state);

            if (index == null)
            {
                return;
            }

            state.Load(index);

            if (stateExisted)
            {
                State.Dispose();
                State = state;
            }

            Loaded?.Invoke();
        }
예제 #2
0
        protected virtual Directory CreateIndex(LuceneSearcherState <TId, TDoc> searcherState)
        {
            var spellchecker = CreateSpellchecker();
            var state        = CreateState(searcherState, spellchecker, loaded: false);

            bool stateExisted = State != null;

            if (!stateExisted)
            {
                State = state;
            }

            void progressHandler() =>
            IndexingProgress?.Invoke();

            state.IndexingProgress += progressHandler;
            var result = state.CreateIndex();

            state.IndexingProgress -= progressHandler;

            if (stateExisted)
            {
                State.Dispose();
                State = state;
            }

            return(result);
        }
예제 #3
0
        protected virtual Directory CreateIndex(LuceneSearcherState <TId, TDoc> state)
        {
            state.IndexingProgress += InvokeIndexingProgressEvent;
            var result = state.CreateIndex();

            state.IndexingProgress -= InvokeIndexingProgressEvent;

            return(result);
        }
예제 #4
0
        public void LoadIndex(LuceneSearcherState <TId, TDoc> searcherState)
        {
            if (!searcherState.IsLoaded)
            {
                throw new InvalidOperationException();
            }

            CreateIndex(searcherState);
        }
예제 #5
0
        protected LuceneSpellcheckerState(
            Spellchecker spellchecker,
            LuceneSearcherState <TId, TDoc> searcherState,
            IDocumentAdapter <TId, TDoc> adapter,
            Func <int> maxCount,
            bool loaded)
        {
            _spellchecker = spellchecker;
            _reader       = searcherState.Reader;
            _adapter      = adapter;
            _maxCount     = maxCount;

            IsLoaded = loaded;
        }
예제 #6
0
 protected abstract LuceneSpellcheckerState <TId, TDoc> CreateState(LuceneSearcherState <TId, TDoc> searcherState, Spellchecker spellchecker, bool loaded);