public override IDictionary <string, string> FillInDefaults(IDictionary <string, string> source) { IDictionary <string, string> result = source != null ? new Dictionary <string, string>(source) : new Dictionary <string, string>(); string analyzer = result[KEY_ANALYZER]; if (string.ReferenceEquals(analyzer, null)) { // Type is only considered if "analyzer" isn't supplied string type = result.computeIfAbsent(KEY_TYPE, k => "exact"); if (type.Equals("fulltext") && !result.ContainsKey(LuceneIndexImplementation.KEY_TO_LOWER_CASE)) { result[KEY_TO_LOWER_CASE] = "true"; } } // Try it on for size. Calling this will reveal configuration problems. IndexType.GetIndexType(result); return(result); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.apache.lucene.index.IndexWriter newIndexWriter(IndexIdentifier identifier) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException private IndexWriter NewIndexWriter(IndexIdentifier identifier) { try { Directory indexDirectory = GetIndexDirectory(identifier); IndexType type = GetType(identifier); IndexWriterConfig writerConfig = new IndexWriterConfig(type.Analyzer); writerConfig.IndexDeletionPolicy = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy()); Similarity similarity = type.Similarity; if (similarity != null) { writerConfig.Similarity = similarity; } return(new IndexWriter(indexDirectory, writerConfig)); } catch (IOException e) { throw new Exception(e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void applyDocuments(org.apache.lucene.index.IndexWriter writer, IndexType type, org.eclipse.collections.api.map.primitive.LongObjectMap<DocumentContext> documents) throws java.io.IOException private void ApplyDocuments(IndexWriter writer, IndexType type, LongObjectMap <DocumentContext> documents) { foreach (DocumentContext context in documents) { if (context.Exists) { if (LuceneDataSource.DocumentIsEmpty(context.Document)) { writer.deleteDocuments(type.IdTerm(context.EntityId)); } else { writer.updateDocument(type.IdTerm(context.EntityId), context.Document); } } else { writer.addDocument(context.Document); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: IndexType getIndexType(IndexIdentifier identifier, boolean recovery) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException internal virtual IndexType GetIndexType(IndexIdentifier identifier, bool recovery) { Pair <int, IndexType> type = _cache[identifier]; IDictionary <string, string> config = _indexStore.get(identifier.EntityType.entityClass(), identifier.IndexName); if (config == null) { if (recovery) { return(null); } throw new ExplicitIndexNotFoundKernelException("Index '%s' doesn't exist.", identifier); } if (type != null && config.GetHashCode() == type.First()) { return(type.Other()); } type = Pair.of(config.GetHashCode(), IndexType.GetIndexType(config)); _cache[identifier] = type; return(type.Other()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private CommitContext commitContext(org.neo4j.kernel.impl.index.IndexCommand command) throws org.neo4j.internal.kernel.api.exceptions.explicitindex.ExplicitIndexNotFoundKernelException private CommitContext CommitContext(IndexCommand command) { IDictionary <string, CommitContext> contextMap = CommitContextMap(command.EntityType); string indexName = _definitions.getIndexName(command.IndexNameId); CommitContext context = contextMap[indexName]; if (context == null) { IndexIdentifier identifier = new IndexIdentifier(IndexEntityType.byId(command.EntityType), indexName); // TODO the fact that we look up index type from config here using the index store // directly should be avoided. But how can we do it in, say recovery? // The `dataSource.getType()` call can throw an exception if the index is concurrently deleted. // To avoid bubbling an exception during commit, we instead ignore the commands related to that index, // and proceed as if the index never existed, and thus cannot accept any modifications. IndexType type = _dataSource.getType(identifier, _recovery); context = new CommitContext(_dataSource, identifier, type, _recovery); contextMap[indexName] = context; } return(context); }
public override void Add(long id, IDictionary <string, object> properties) { try { Document document = IndexType.NewDocument(EntityId(id)); foreach (KeyValuePair <string, object> entry in properties.SetOfKeyValuePairs()) { string key = entry.Key; object value = entry.Value; AddSingleProperty(id, document, key, value); } _writer.addDocument(document); if (++_updateCount == _commitBatchSize) { _writer.commit(); _updateCount = 0; } } catch (IOException e) { throw new Exception(e); } }
internal CommitContext(LuceneDataSource dataSource, IndexIdentifier identifier, IndexType indexType, bool isRecovery) { this.DataSource = dataSource; this.Identifier = identifier; this.IndexType = indexType; this.Recovery = isRecovery; }
internal LuceneExplicitIndex(LuceneDataSource dataSource, IndexIdentifier identifier, LuceneTransactionState transaction, IndexType type, IndexCommandFactory commandFactory) { this.DataSource = dataSource; this.IdentifierConflict = identifier; this.Transaction = transaction; this.Type = type; this.CommandFactory = commandFactory; }
internal RelationshipExplicitIndex(LuceneDataSource dataSource, IndexIdentifier identifier, LuceneTransactionState transaction, IndexType type, IndexCommandFactory commandFactory) : base(dataSource, identifier, transaction, type, commandFactory) { }
public override ExplicitIndex RelationshipIndex(string indexName, IDictionary <string, string> configuration) { LuceneExplicitIndex index = _relationshipIndexes[indexName]; if (index == null) { IndexIdentifier identifier = new IndexIdentifier(IndexEntityType.Relationship, indexName); index = new LuceneExplicitIndex.RelationshipExplicitIndex(_dataSource, identifier, _luceneTransaction, IndexType.GetIndexType(configuration), _commandFactory); _relationshipIndexes[indexName] = index; } return(index); }