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 void Initialize(StorageEnvironment environment) { if (_initialized) { throw new InvalidOperationException(); } _directory = new LuceneVoronDirectory(environment); using (var tx = environment.WriteTransaction()) { using (_directory.SetTransaction(tx)) { CreateIndexStructure(); RecreateSearcher(tx); // force tx commit so it will bump tx counter and just created searcher holder will have valid tx id tx.LowLevelTransaction.ModifyPage(0); } tx.Commit(); } _initialized = true; }
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); } }
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 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 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 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); }