private void InitializeMainIndexStorage(Transaction tx, StorageEnvironment environment) { _directory = new LuceneVoronDirectory(tx, environment); using (_directory.SetTransaction(tx, out IState state)) { CreateIndexStructure(_directory, state); RecreateSearcher(tx); } }
public LuceneSuggestionIndexWriter(string field, LuceneVoronDirectory directory, SnapshotDeletionPolicy snapshotter, IndexWriter.MaxFieldLength maxFieldLength, Index index, IState state) { _directory = directory; _indexDeletionPolicy = snapshotter; _maxFieldLength = maxFieldLength; _index = index; _field = field; _logger = LoggingSource.Instance.GetLogger <LuceneSuggestionIndexWriter>(_index.DocumentDatabase.Name); RecreateIndexWriter(state); }
public LuceneIndexWriter(LuceneVoronDirectory d, Analyzer a, IndexDeletionPolicy deletionPolicy, IndexWriter.MaxFieldLength mfl, IndexWriter.IndexReaderWarmer indexReaderWarmer, Index index, IState state) { _directory = d; _analyzer = a; _indexDeletionPolicy = deletionPolicy; _maxFieldLength = mfl; _indexReaderWarmer = indexReaderWarmer; _logger = LoggingSource.Instance.GetLogger <LuceneIndexWriter>(index.DocumentDatabase.Name); RecreateIndexWriter(state); }
public void Lucene_directory_must_be_aware_of_created_outputs() { using (var tx = Env.WriteTransaction()) { var dir = new LuceneVoronDirectory(tx, Env); var state = new VoronState(tx); dir.CreateOutput("file", state); Assert.True(dir.FileExists("file", state)); dir.DeleteFile("file", state); Assert.False(dir.FileExists("file", state)); } }
public IndexReadOperation(Index index, LuceneVoronDirectory directory, IndexSearcherHolder searcherHolder, Transaction readTransaction) : base(index.Name, LoggingSource.Instance.GetLogger <IndexReadOperation>(index._indexStorage.DocumentDatabase.Name)) { try { _analyzer = CreateAnalyzer(() => new LowerCaseKeywordAnalyzer(), index.Definition.IndexFields, forQuerying: true); } catch (Exception e) { throw new IndexAnalyzerException(e); } _maxNumberOfOutputsPerDocument = index.MaxNumberOfOutputsPerDocument; _indexType = index.Type; _indexHasBoostedFields = index.HasBoostedFields; _releaseReadTransaction = directory.SetTransaction(readTransaction, out _state); _releaseSearcher = searcherHolder.GetSearcher(readTransaction, _state, out _searcher); }
private void InitializeSuggestionsIndexStorage(Transaction tx, StorageEnvironment environment) { foreach (var field in _fields) { if (!field.Value.HasSuggestions) { continue; } var directory = new LuceneVoronDirectory(tx, environment, $"Suggestions-{field.Key}"); _suggestionsDirectories[field.Key] = directory; using (directory.SetTransaction(tx, out IState state)) { CreateIndexStructure(directory, state); RecreateSuggestionsSearcher(tx, field.Key); } } }
public IndexFacetedReadOperation(string indexName, Dictionary <string, IndexField> fields, LuceneVoronDirectory directory, IndexSearcherHolder searcherHolder, Transaction readTransaction, DocumentDatabase documentDatabase) : base(indexName, LoggingSource.Instance.GetLogger <IndexFacetedReadOperation>(documentDatabase.Name)) { try { _analyzer = CreateAnalyzer(() => new LowerCaseKeywordAnalyzer(), fields, forQuerying: true); } catch (Exception e) { throw new IndexAnalyzerException(e); } _releaseReadTransaction = directory.SetTransaction(readTransaction, out _state); _currentStateHolder = searcherHolder.GetStateHolder(readTransaction); _searcher = _currentStateHolder.GetIndexSearcher(_state); }
public IndexWriteOperation(Index index, LuceneVoronDirectory directory, LuceneDocumentConverterBase converter, Transaction writeTransaction, LuceneIndexPersistence persistence) : base(index, LoggingSource.Instance.GetLogger <IndexWriteOperation>(index._indexStorage.DocumentDatabase.Name)) { _converter = converter; DocumentDatabase = index._indexStorage.DocumentDatabase; try { _analyzer = CreateAnalyzer(index, index.Definition); } catch (Exception e) { throw new IndexAnalyzerException(e); } try { _releaseWriteTransaction = directory.SetTransaction(writeTransaction, out _state); _writer = persistence.EnsureIndexWriter(_state); _suggestionsWriters = persistence.EnsureSuggestionIndexWriter(_state); _hasSuggestions = _suggestionsWriters.Count > 0; _locker = directory.MakeLock("writing-to-index.lock"); _directory = directory; if (_locker.Obtain() == false) { throw new InvalidOperationException($"Could not obtain the 'writing-to-index' lock for '{_indexName}' index."); } } catch (Exception e) when(e.IsOutOfMemory()) { throw; } catch (Exception e) { throw new IndexWriteException(e); } }
public IndexFacetedReadOperation(Index index, IndexDefinitionBaseServerSide indexDefinition, LuceneVoronDirectory directory, IndexSearcherHolder searcherHolder, QueryBuilderFactories queryBuilderFactories, Transaction readTransaction, DocumentDatabase documentDatabase) : base(index, LoggingSource.Instance.GetLogger <IndexFacetedReadOperation>(documentDatabase.Name)) { try { _analyzer = CreateAnalyzer(index, indexDefinition, forQuerying: true); } catch (Exception e) { throw new IndexAnalyzerException(e); } _queryBuilderFactories = queryBuilderFactories; _releaseReadTransaction = directory.SetTransaction(readTransaction, out _state); _releaseSearcher = searcherHolder.GetSearcher(readTransaction, _state, out _searcher); }
public static void TryThrowingBetterException(SystemException e, LuceneVoronDirectory directory) { if (e.Message.StartsWith("this writer hit an OutOfMemoryError")) { throw new OutOfMemoryException("Index writer hit OOM during commit", e); } if (e.InnerException is VoronUnrecoverableErrorException) { VoronUnrecoverableErrorException.Raise("Index data is corrupted", e); } if (e.IsOutOfDiskSpaceException()) { // this commit stage is written to the temp scratch buffers var fullPath = directory.TempFullPath; var driveInfo = DiskSpaceChecker.GetDiskSpaceInfo(fullPath); var freeSpace = driveInfo != null?driveInfo.TotalFreeSpace.ToString() : "N/A"; throw new DiskFullException($"There isn't enough space to commit the index to {fullPath}. " + $"Currently available space: {freeSpace}", e); } }
private void CreateIndexStructure(LuceneVoronDirectory directory, IState state) { new IndexWriter(directory, _dummyAnalyzer, IndexWriter.MaxFieldLength.UNLIMITED, state).Dispose(); }
public LuceneSuggestionIndexReader(Index index, LuceneVoronDirectory directory, IndexSearcherHolder searcherHolder, Transaction readTransaction) : base(index, LoggingSource.Instance.GetLogger <LuceneSuggestionIndexReader>(index._indexStorage.DocumentDatabase.Name)) { _releaseReadTransaction = directory.SetTransaction(readTransaction, out _state); _releaseSearcher = searcherHolder.GetSearcher(readTransaction, _state, out _searcher); }