public ILuceneSearcherContext CreateSearchContext(string targetIndex)
        {
            _lastAccessed = DateTime.Now;
            if (_indexes.ContainsKey(targetIndex) == false)
            {
                lock (_lockObject)
                {
                    if (_indexes.ContainsKey(targetIndex) == false)
                    {
                        var directoryPath = Path.Combine(_indexDirectory, targetIndex);

                        var writeLock = Path.Combine(directoryPath, "write.lock");
                        if (File.Exists(writeLock))
                        {
                            File.Delete(writeLock);
                        }

                        var directory    = FSDirectory.Open(new DirectoryInfo(directoryPath));
                        var indexContext = new LuceneIndexContext(directory);
                        _indexes.Add(targetIndex, indexContext);
                    }
                }
            }

            var searcherContext = new LuceneSearcherContext(_indexes[targetIndex]);

            return(searcherContext);
        }
示例#2
0
        public LuceneSearcherContext(LuceneIndexContext luceneIndexContext)
        {
            _luceneIndexContext = luceneIndexContext;

            SearcherReference = luceneIndexContext.Manager.GetSearcherManager().Acquire();
        }