//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldPersistFulltextIndexSettings() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldPersistFulltextIndexSettings()
        {
            // Given
            File   indexFolder           = Directory.directory("indexFolder");
            string analyzerName          = "simple";
            string eventuallyConsistency = "true";
            string defaultAnalyzer       = "defaultAnalyzer";

            int[] propertyIds = new int[] { 1, 2, 3 };
            MultiTokenSchemaDescriptor schema = SchemaDescriptorFactory.multiToken(new int[] { 1, 2 }, EntityType.NODE, propertyIds);

            // A fulltext index descriptor with configurations
            Properties properties = properties(analyzerName, eventuallyConsistency);
            FulltextSchemaDescriptor fulltextSchemaDescriptor = new FulltextSchemaDescriptor(schema, properties);
            StoreIndexDescriptor     storeIndexDescriptor     = StoreIndexDescriptorFromSchema(fulltextSchemaDescriptor);
            TokenRegistry            tokenRegistry            = SimpleTokenHolder.CreatePopulatedTokenRegistry(Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_PROPERTY_KEY, propertyIds);
            SimpleTokenHolder        tokenHolder             = new SimpleTokenHolder(tokenRegistry);
            FulltextIndexDescriptor  fulltextIndexDescriptor = readOrInitialiseDescriptor(storeIndexDescriptor, defaultAnalyzer, tokenHolder, indexFolder, Fs);

            assertEquals(analyzerName, fulltextIndexDescriptor.AnalyzerName());
            assertEquals(bool.Parse(eventuallyConsistency), fulltextIndexDescriptor.EventuallyConsistent);

            // When persisting it
            FulltextIndexSettings.SaveFulltextIndexSettings(fulltextIndexDescriptor, indexFolder, Fs);

            // Then we should be able to load it back with settings being the same
            StoreIndexDescriptor    loadingIndexDescriptor = StoreIndexDescriptorFromSchema(schema);
            FulltextIndexDescriptor loadedDescriptor       = readOrInitialiseDescriptor(loadingIndexDescriptor, defaultAnalyzer, tokenHolder, indexFolder, Fs);

            assertEquals(fulltextIndexDescriptor.AnalyzerName(), loadedDescriptor.AnalyzerName());
            assertEquals(fulltextIndexDescriptor.EventuallyConsistent, loadedDescriptor.EventuallyConsistent);
        }
示例#2
0
        public override IndexPopulator GetPopulator(StoreIndexDescriptor descriptor, IndexSamplingConfig samplingConfig, ByteBufferFactory bufferFactory)
        {
            PartitionedIndexStorage             indexStorage            = GetIndexStorage(descriptor.Id);
            FulltextIndexDescriptor             fulltextIndexDescriptor = readOrInitialiseDescriptor(descriptor, _defaultAnalyzerName, _tokenHolders.propertyKeyTokens(), indexStorage.IndexFolder, _fileSystem);
            DatabaseIndex <FulltextIndexReader> fulltextIndex           = FulltextIndexBuilder.Create(fulltextIndexDescriptor, _config, _tokenHolders.propertyKeyTokens()).withFileSystem(_fileSystem).withOperationalMode(_operationalMode).withIndexStorage(indexStorage).withPopulatingMode(true).build();

            if (fulltextIndex.ReadOnly)
            {
                throw new System.NotSupportedException("Can't create populator for read only index");
            }
            _log.debug("Creating populator for fulltext schema index: %s", descriptor);
            return(new FulltextIndexPopulator(fulltextIndexDescriptor, fulltextIndex, () => FulltextIndexSettings.saveFulltextIndexSettings(fulltextIndexDescriptor, indexStorage.IndexFolder, _fileSystem)));
        }