Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotReturnNonMatches() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotReturnNonMatches()
        {
            SchemaDescriptor nodes = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, PROP);
            SchemaDescriptor rels  = FulltextAdapter.schemaFor(RELATIONSHIP, new string[] { Reltype.name() }, Settings, PROP);
            IndexReference   nodesIndex;
            IndexReference   relsIndex;

            using (KernelTransactionImplementation tx = KernelTransaction)
            {
                nodesIndex = tx.SchemaWrite().indexCreate(nodes, FulltextIndexProviderFactory.Descriptor.name(), NODE_INDEX_NAME);
                relsIndex  = tx.SchemaWrite().indexCreate(rels, FulltextIndexProviderFactory.Descriptor.name(), REL_INDEX_NAME);
                tx.Success();
            }
            Await(nodesIndex);
            Await(relsIndex);
            using (Transaction tx = Db.beginTx())
            {
                long firstNode  = CreateNodeIndexableByPropertyValue(Label, "Hello. Hello again.");
                long secondNode = CreateNodeWithProperty(Label, "prop2", "A zebroid (also zedonk, zorse, zebra mule, zonkey, and zebmule) is the offspring of any " + "cross between a zebra and any other equine: essentially, a zebra hybrid.");
                CreateRelationshipIndexableByPropertyValue(firstNode, secondNode, "Hello. Hello again.");
                CreateRelationshipWithProperty(secondNode, firstNode, "prop2", "A zebroid (also zedonk, zorse, zebra mule, zonkey, and zebmule) is the offspring of any " + "cross between a zebra and any other equine: essentially, a zebra hybrid.");

                tx.Success();
            }
            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction ktx = KernelTransaction(tx);
                AssertQueryFindsNothing(ktx, NODE_INDEX_NAME, "zebra");
                AssertQueryFindsNothing(ktx, REL_INDEX_NAME, "zebra");
            }
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFindNodeWithString() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFindNodeWithString()
        {
            IndexReference index;

            using (KernelTransactionImplementation tx = KernelTransaction)
            {
                SchemaDescriptor descriptor = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, PROP);
                index = tx.SchemaWrite().indexCreate(descriptor, FulltextIndexProviderFactory.Descriptor.name(), NODE_INDEX_NAME);
                tx.Success();
            }
            Await(index);
            long firstID;
            long secondID;

            using (Transaction tx = Db.beginTx())
            {
                firstID  = CreateNodeIndexableByPropertyValue(Label, "Hello. Hello again.");
                secondID = CreateNodeIndexableByPropertyValue(Label, "A zebroid (also zedonk, zorse, zebra mule, zonkey, and zebmule) is the offspring of any " + "cross between a zebra and any other equine: essentially, a zebra hybrid.");

                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction ktx = KernelTransaction(tx);
                AssertQueryFindsIds(ktx, NODE_INDEX_NAME, "hello", firstID);
                AssertQueryFindsIds(ktx, NODE_INDEX_NAME, "zebra", secondID);
                AssertQueryFindsIds(ktx, NODE_INDEX_NAME, "zedonk", secondID);
                AssertQueryFindsIds(ktx, NODE_INDEX_NAME, "cross", secondID);
            }
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSearchAcrossMultipleProperties() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSearchAcrossMultipleProperties()
        {
            IndexReference index;

            using (KernelTransactionImplementation tx = KernelTransaction)
            {
                SchemaDescriptor descriptor = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, "prop", "prop2");
                index = tx.SchemaWrite().indexCreate(descriptor, FulltextIndexProviderFactory.Descriptor.name(), NODE_INDEX_NAME);
                tx.Success();
            }
            Await(index);

            long firstID;
            long secondID;
            long thirdID;

            using (Transaction tx = Db.beginTx())
            {
                firstID  = CreateNodeIndexableByPropertyValue(Label, "Tomtar tomtar oftsat i tomteutstyrsel.");
                secondID = CreateNodeIndexableByPropertyValue(Label, "Olof och Hans");
                SetNodeProp(secondID, "prop2", "och karl");

                Node node3 = Db.createNode(Label);
                thirdID = node3.Id;
                node3.SetProperty("prop2", "Tomtar som inte tomtar ser upp till tomtar som tomtar.");

                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction ktx = KernelTransaction(tx);
                AssertQueryFindsIds(ktx, NODE_INDEX_NAME, "tomtar Karl", firstID, secondID, thirdID);
            }
        }
Пример #4
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");
            }
        }
Пример #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldOnlyIndexIndexedProperties() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldOnlyIndexIndexedProperties()
        {
            IndexReference index;

            using (KernelTransactionImplementation tx = KernelTransaction)
            {
                SchemaDescriptor descriptor = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, PROP);
                index = tx.SchemaWrite().indexCreate(descriptor, FulltextIndexProviderFactory.Descriptor.name(), NODE_INDEX_NAME);
                tx.Success();
            }
            Await(index);

            long firstID;

            using (Transaction tx = Db.beginTx())
            {
                firstID = CreateNodeIndexableByPropertyValue(Label, "Hello. Hello again.");
                SetNodeProp(firstID, "prop2", "zebra");

                Node node2 = Db.createNode(Label);
                node2.SetProperty("prop2", "zebra");
                node2.SetProperty("prop3", "hello");

                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction ktx = KernelTransaction(tx);
                AssertQueryFindsIds(ktx, NODE_INDEX_NAME, "hello", firstID);
                AssertQueryFindsNothing(ktx, NODE_INDEX_NAME, "zebra");
            }
        }
Пример #6
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);
            }
        }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToUpdateAndQueryAfterIndexChange() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToUpdateAndQueryAfterIndexChange()
        {
            IndexReference index;

            using (KernelTransactionImplementation tx = KernelTransaction)
            {
                SchemaDescriptor descriptor = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, PROP);
                index = tx.SchemaWrite().indexCreate(descriptor, FulltextIndexProviderFactory.Descriptor.name(), NODE_INDEX_NAME);
                tx.Success();
            }
            Await(index);

            long firstID;
            long secondID;
            long thirdID;
            long fourthID;

            using (Transaction tx = Db.beginTx())
            {
                firstID = CreateNodeIndexableByPropertyValue(Label, "thing");

                secondID = Db.createNode(Label).Id;
                SetNodeProp(secondID, "prop2", "zebra");

                thirdID = CreateNodeIndexableByPropertyValue(Label, "zebra");
                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction ktx = KernelTransaction(tx);
                AssertQueryFindsIds(ktx, NODE_INDEX_NAME, "thing zebra", firstID, thirdID);
            }

            using (KernelTransactionImplementation tx = KernelTransaction)
            {
                SchemaDescriptor descriptor = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, "prop2");
                tx.SchemaWrite().indexDrop(index);
                index = tx.SchemaWrite().indexCreate(descriptor, FulltextIndexProviderFactory.Descriptor.name(), NODE_INDEX_NAME);
                tx.Success();
            }
            Await(index);

            using (Transaction tx = Db.beginTx())
            {
                SetNodeProp(firstID, "prop2", "thing");

                fourthID = Db.createNode(Label).Id;
                SetNodeProp(fourthID, "prop2", "zebra");
                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction ktx = KernelTransaction(tx);
                AssertQueryFindsIds(ktx, NODE_INDEX_NAME, "thing zebra", firstID, secondID, fourthID);
            }
        }
Пример #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotFindRemovedProperties() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotFindRemovedProperties()
        {
            IndexReference index;

            using (KernelTransactionImplementation tx = KernelTransaction)
            {
                SchemaDescriptor descriptor = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, "prop", "prop2");
                index = tx.SchemaWrite().indexCreate(descriptor, FulltextIndexProviderFactory.Descriptor.name(), NODE_INDEX_NAME);
                tx.Success();
            }
            Await(index);
            long firstID;
            long secondID;
            long thirdID;

            using (Transaction tx = Db.beginTx())
            {
                firstID  = CreateNodeIndexableByPropertyValue(Label, "Hello. Hello again.");
                secondID = CreateNodeIndexableByPropertyValue(Label, "A zebroid (also zedonk, zorse, zebra mule, zonkey, and zebmule) is the offspring of any " + "cross between a zebra and any other equine: essentially, a zebra hybrid.");
                thirdID  = CreateNodeIndexableByPropertyValue(Label, "Hello. Hello again.");

                SetNodeProp(firstID, "zebra");
                SetNodeProp(secondID, "Hello. Hello again.");

                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                Node node  = Db.getNodeById(firstID);
                Node node2 = Db.getNodeById(secondID);
                Node node3 = Db.getNodeById(thirdID);

                node.SetProperty("prop", "tomtar");
                node.SetProperty("prop2", "tomtar");

                node2.SetProperty("prop", "tomtar");
                node2.SetProperty("prop2", "Hello");

                node3.RemoveProperty("prop");

                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction ktx = KernelTransaction(tx);
                AssertQueryFindsIds(ktx, NODE_INDEX_NAME, "hello", secondID);
                AssertQueryFindsNothing(ktx, NODE_INDEX_NAME, "zebra");
                AssertQueryFindsNothing(ktx, NODE_INDEX_NAME, "zedonk");
                AssertQueryFindsNothing(ktx, NODE_INDEX_NAME, "cross");
            }
        }
Пример #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPopulateIndexWithExistingNodesAndRelationships() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPopulateIndexWithExistingNodesAndRelationships()
        {
            long firstNodeID;
            long secondNodeID;
            long firstRelID;
            long secondRelID;

            using (Transaction tx = Db.beginTx())
            {
                // skip a few rel ids, so the ones we work with are different from the node ids, just in case.
                Node node = Db.createNode();
                node.CreateRelationshipTo(node, Reltype);
                node.CreateRelationshipTo(node, Reltype);
                node.CreateRelationshipTo(node, Reltype);

                firstNodeID  = CreateNodeIndexableByPropertyValue(Label, "Hello. Hello again.");
                secondNodeID = CreateNodeIndexableByPropertyValue(Label, "This string is slightly shorter than the zebra one");
                firstRelID   = CreateRelationshipIndexableByPropertyValue(firstNodeID, secondNodeID, "Goodbye");
                secondRelID  = CreateRelationshipIndexableByPropertyValue(secondNodeID, firstNodeID, "And now, something completely different");

                tx.Success();
            }

            SchemaDescriptor nodes = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, PROP);
            SchemaDescriptor rels  = FulltextAdapter.schemaFor(RELATIONSHIP, new string[] { Reltype.name() }, Settings, PROP);
            IndexReference   nodesIndex;
            IndexReference   relsIndex;

            using (KernelTransactionImplementation tx = KernelTransaction)
            {
                nodesIndex = tx.schemaWrite().indexCreate(nodes, FulltextIndexProviderFactory.Descriptor.name(), NODE_INDEX_NAME);
                relsIndex  = tx.schemaWrite().indexCreate(rels, FulltextIndexProviderFactory.Descriptor.name(), REL_INDEX_NAME);
                tx.Success();
            }
            Await(nodesIndex);
            Await(relsIndex);
            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction ktx = KernelTransaction(tx);
                AssertQueryFindsIds(ktx, NODE_INDEX_NAME, "hello", firstNodeID);
                AssertQueryFindsIds(ktx, NODE_INDEX_NAME, "string", secondNodeID);
                AssertQueryFindsNothing(ktx, NODE_INDEX_NAME, "goodbye");
                AssertQueryFindsNothing(ktx, NODE_INDEX_NAME, "different");

                AssertQueryFindsNothing(ktx, REL_INDEX_NAME, "hello");
                AssertQueryFindsNothing(ktx, REL_INDEX_NAME, "string");
                AssertQueryFindsIds(ktx, REL_INDEX_NAME, "goodbye", firstRelID);
                AssertQueryFindsIds(ktx, REL_INDEX_NAME, "different", secondRelID);
            }
        }
Пример #10
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);
            }
        }
Пример #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldOrderResultsBasedOnRelevance() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldOrderResultsBasedOnRelevance()
        {
            IndexReference index;

            using (KernelTransactionImplementation tx = KernelTransaction)
            {
                SchemaDescriptor descriptor = FulltextAdapter.schemaFor(NODE, new string[] { Label.name() }, Settings, "first", "last");
                index = tx.SchemaWrite().indexCreate(descriptor, FulltextIndexProviderFactory.Descriptor.name(), NODE_INDEX_NAME);
                tx.Success();
            }
            Await(index);
            long firstID;
            long secondID;
            long thirdID;
            long fourthID;

            using (Transaction tx = Db.beginTx())
            {
                firstID  = Db.createNode(Label).Id;
                secondID = Db.createNode(Label).Id;
                thirdID  = Db.createNode(Label).Id;
                fourthID = Db.createNode(Label).Id;
                SetNodeProp(firstID, "first", "Full");
                SetNodeProp(firstID, "last", "Hanks");
                SetNodeProp(secondID, "first", "Tom");
                SetNodeProp(secondID, "last", "Hunk");
                SetNodeProp(thirdID, "first", "Tom");
                SetNodeProp(thirdID, "last", "Hanks");
                SetNodeProp(fourthID, "first", "Tom Hanks");
                SetNodeProp(fourthID, "last", "Tom Hanks");

                tx.Success();
            }

            using (Transaction tx = Db.beginTx())
            {
                KernelTransaction ktx = KernelTransaction(tx);
                AssertQueryFindsIdsInOrder(ktx, NODE_INDEX_NAME, "Tom Hanks", fourthID, thirdID, firstID, secondID);
            }
        }
Пример #12
0
 private SchemaDescriptor GetExistingDescriptor(string[] entityTokens)
 {
     return(FulltextAdapter.schemaFor(NODE, entityTokens, Settings, PROP));
 }
Пример #13
0
 private SchemaDescriptor GetNewDescriptor(string[] entityTokens)
 {
     return(FulltextAdapter.schemaFor(NODE, entityTokens, Settings, "otherProp"));
 }