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(() => new LowerCaseKeywordAnalyzer(), index.Definition.IndexFields); } 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"); if (_locker.Obtain() == false) { throw new InvalidOperationException($"Could not obtain the 'writing-to-index' lock for '{_indexName}' index."); } } catch (Exception e) { throw new IndexWriteException(e); } }
public IndexWriteOperation(string indexName, Dictionary <string, IndexField> fields, LuceneVoronDirectory directory, LuceneDocumentConverterBase converter, Transaction writeTransaction, LuceneIndexPersistence persistence, DocumentDatabase documentDatabase) : base(indexName, LoggingSource.Instance.GetLogger <IndexWriteOperation>(documentDatabase.Name)) { _converter = converter; try { _analyzer = CreateAnalyzer(() => new LowerCaseKeywordAnalyzer(), fields); } catch (Exception e) { throw new IndexAnalyzerException(e); } try { _releaseWriteTransaction = directory.SetTransaction(writeTransaction); _writer = persistence.EnsureIndexWriter(); _locker = directory.MakeLock("writing-to-index.lock"); if (_locker.Obtain() == false) { throw new InvalidOperationException($"Could not obtain the 'writing-to-index' lock for '{_indexName}' index."); } } catch (Exception e) { throw new IndexWriteException(e); } }