Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToSpecifySwedishAnalyzer() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToSpecifySwedishAnalyzer()
        {
            ApplySetting(FulltextConfig.FulltextDefaultAnalyzer, SWEDISH);
            SchemaDescriptor descriptor = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, PROP);
            IndexReference   nodes;

            using (KernelTransactionImplementation transaction = KernelTransaction)
            {
                SchemaWrite schemaWrite = transaction.SchemaWrite();
                nodes = schemaWrite.IndexCreate(descriptor, FulltextIndexProviderFactory.Descriptor.name(), "nodes");
                transaction.Success();
            }
            Await(nodes);

            long id;

            using (Transaction tx = Db.beginTx())
            {
                id = CreateNodeIndexableByPropertyValue(Label, "Hello and hello again, in the end.");
                CreateNodeIndexableByPropertyValue(Label, "En apa och en tomte bodde i ett hus.");

                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction ktx = KernelTransaction(tx);
                AssertQueryFindsIds(ktx, "nodes", "and", id);
                AssertQueryFindsIds(ktx, "nodes", "in", id);
                AssertQueryFindsIds(ktx, "nodes", "the", id);
                AssertQueryFindsNothing(ktx, "nodes", "en");
                AssertQueryFindsNothing(ktx, "nodes", "och");
                AssertQueryFindsNothing(ktx, "nodes", "ett");
            }
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToSpecifyFoldingAnalyzer() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToSpecifyFoldingAnalyzer()
        {
            ApplySetting(FulltextConfig.FulltextDefaultAnalyzer, FOLDING);
            SchemaDescriptor descriptor = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, PROP);
            IndexReference   nodes;

            using (KernelTransactionImplementation transaction = KernelTransaction)
            {
                SchemaWrite schemaWrite = transaction.SchemaWrite();
                nodes = schemaWrite.IndexCreate(descriptor, FulltextIndexProviderFactory.Descriptor.name(), "nodes");
                transaction.Success();
            }
            Await(nodes);

            long id;

            using (Transaction tx = Db.beginTx())
            {
                id = CreateNodeIndexableByPropertyValue(Label, "Příliš žluťoučký kůň úpěl ďábelské ódy.");

                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction ktx = KernelTransaction(tx);
                AssertQueryFindsIds(ktx, "nodes", "prilis", id);
                AssertQueryFindsIds(ktx, "nodes", "zlutoucky", id);
                AssertQueryFindsIds(ktx, "nodes", "kun", id);
                AssertQueryFindsIds(ktx, "nodes", "upel", id);
                AssertQueryFindsIds(ktx, "nodes", "dabelske", id);
                AssertQueryFindsIds(ktx, "nodes", "ody", id);
            }
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.internal.kernel.api.IndexReference createIndex(org.neo4j.internal.kernel.api.Transaction transaction) throws org.neo4j.internal.kernel.api.exceptions.schema.SchemaKernelException, org.neo4j.internal.kernel.api.exceptions.InvalidTransactionTypeKernelException
        private IndexReference CreateIndex([email protected] transaction)
        {
            TokenWrite            tokenWrite       = transaction.TokenWrite();
            SchemaWrite           schemaWrite      = transaction.SchemaWrite();
            LabelSchemaDescriptor schemaDescriptor = forLabel(tokenWrite.LabelGetOrCreateForName("hello"), tokenWrite.PropertyKeyGetOrCreateForName("hepp"));

            return(schemaWrite.IndexCreate(schemaDescriptor));
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotReindexNodesWhenDefaultAnalyzerIsChanged() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotReindexNodesWhenDefaultAnalyzerIsChanged()
        {
            long firstID;
            long secondID;

            ApplySetting(FulltextConfig.FulltextDefaultAnalyzer, ENGLISH);
            SchemaDescriptor descriptor = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, PROP);
            IndexReference   nodes;

            using (KernelTransactionImplementation transaction = KernelTransaction)
            {
                SchemaWrite schemaWrite = transaction.SchemaWrite();
                nodes = schemaWrite.IndexCreate(descriptor, FulltextIndexProviderFactory.Descriptor.name(), "nodes");
                transaction.Success();
            }
            Await(nodes);

            using (Transaction tx = Db.beginTx())
            {
                firstID  = CreateNodeIndexableByPropertyValue(Label, "Hello and hello again, in the end.");
                secondID = CreateNodeIndexableByPropertyValue(Label, "En apa och en tomte bodde i ett hus.");

                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction ktx = KernelTransaction(tx);
                AssertQueryFindsNothing(ktx, "nodes", "and");
                AssertQueryFindsNothing(ktx, "nodes", "in");
                AssertQueryFindsNothing(ktx, "nodes", "the");
                AssertQueryFindsIds(ktx, "nodes", "en", secondID);
                AssertQueryFindsIds(ktx, "nodes", "och", secondID);
                AssertQueryFindsIds(ktx, "nodes", "ett", secondID);
            }

            ApplySetting(FulltextConfig.FulltextDefaultAnalyzer, SWEDISH);
            using (KernelTransactionImplementation ktx = KernelTransaction)
            {
                SchemaRead schemaRead = ktx.SchemaRead();
                Await(schemaRead.IndexGetForName("nodes"));
                // These results should be exactly the same as before the configuration change and restart.
                AssertQueryFindsNothing(ktx, "nodes", "and");
                AssertQueryFindsNothing(ktx, "nodes", "in");
                AssertQueryFindsNothing(ktx, "nodes", "the");
                AssertQueryFindsIds(ktx, "nodes", "en", secondID);
                AssertQueryFindsIds(ktx, "nodes", "och", secondID);
                AssertQueryFindsIds(ktx, "nodes", "ett", secondID);
            }
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotBePossibleToCreateIndexWithDuplicateProperties() throws org.neo4j.internal.kernel.api.exceptions.KernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotBePossibleToCreateIndexWithDuplicateProperties()
        {
            // given
            SchemaWrite schemaWrite = SchemaWriteInNewTransaction();

            // when
            try
            {
                LabelSchemaDescriptor descriptor = forLabel(0, 1, 1);
                schemaWrite.IndexCreate(descriptor);
                fail("Should have failed");
            }
            catch (RepeatedPropertyInSchemaException)
            {
                // then good
            }
        }
Exemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotBePossibleToCreateIndexWithDuplicateLabel() throws org.neo4j.internal.kernel.api.exceptions.KernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotBePossibleToCreateIndexWithDuplicateLabel()
        {
            // given
            SchemaWrite schemaWrite = SchemaWriteInNewTransaction();

            // when
            try
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.api.schema.MultiTokenSchemaDescriptor descriptor = org.neo4j.kernel.api.schema.SchemaDescriptorFactory.multiToken(new int[]{0, 0}, org.neo4j.storageengine.api.EntityType.NODE, 1);
                MultiTokenSchemaDescriptor descriptor = SchemaDescriptorFactory.multiToken(new int[] { 0, 0 }, EntityType.NODE, 1);
                schemaWrite.IndexCreate(descriptor);
                fail("Should have failed");
            }
            catch (RepeatedLabelInSchemaException)
            {
                // then good
            }
        }