//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode() public virtual void ShouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode() { RelationshipType type = MyRelTypes.TEST; long startId; long endId; Relationship rel; using (Transaction tx = Db.beginTx()) { Node start = Db.createNode(); Node end = Db.createNode(); startId = start.Id; endId = end.Id; rel = start.CreateRelationshipTo(end, type); rel.SetProperty("Type", type.Name()); tx.Success(); } using (Transaction tx = Db.beginTx()) { ReadableRelationshipIndex autoRelationshipIndex = Db.index().RelationshipAutoIndexer.AutoIndex; Node start = Db.getNodeById(startId); Node end = Db.getNodeById(endId); IndexHits <Relationship> hits = autoRelationshipIndex.Get("Type", type.Name(), start, end); assertEquals(1, count(hits)); assertEquals(1, hits.Size()); rel.Delete(); autoRelationshipIndex = Db.index().RelationshipAutoIndexer.AutoIndex; hits = autoRelationshipIndex.Get("Type", type.Name(), start, end); assertEquals(0, count(hits)); assertEquals(0, hits.Size()); tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReturnIndexHitsInGivenSortOrder() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal void ShouldReturnIndexHitsInGivenSortOrder() { // given DocValuesCollector collector = new DocValuesCollector(false); IndexReaderStub readerStub = IndexReaderWithMaxDocs(43); // when collector.DoSetNextReader(readerStub.Context); collector.Collect(1); collector.Collect(3); collector.Collect(37); collector.Collect(42); // then Sort byIdDescending = new Sort(new SortField("id", SortField.Type.LONG, true)); IndexHits <Document> indexHits = collector.GetIndexHits(byIdDescending); assertEquals(4, indexHits.Size()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals("42", indexHits.next().get("id")); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals("37", indexHits.next().get("id")); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals("3", indexHits.next().get("id")); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals("1", indexHits.next().get("id")); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse(indexHits.hasNext()); }
private static void CountNodesByKeyValue(IndexManager indexManager, string indexName, string key, string value) { using (IndexHits <Node> nodes = indexManager.ForNodes(indexName).get(key, value)) { assertEquals(50, nodes.Size()); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReturnIndexHitsOrderedByRelevance() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal void ShouldReturnIndexHitsOrderedByRelevance() { // given DocValuesCollector collector = new DocValuesCollector(true); IndexReaderStub readerStub = IndexReaderWithMaxDocs(42); // when collector.DoSetNextReader(readerStub.Context); collector.Scorer = ConstantScorer(1.0f); collector.Collect(1); collector.Scorer = ConstantScorer(2.0f); collector.Collect(2); // then IndexHits <Document> indexHits = collector.GetIndexHits(Sort.RELEVANCE); assertEquals(2, indexHits.Size()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals("2", indexHits.next().get("id")); assertEquals(2.0f, indexHits.CurrentScore(), 0.001f); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals("1", indexHits.next().get("id")); assertEquals(1.0f, indexHits.CurrentScore(), 0.001f); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse(indexHits.hasNext()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDeletingNodeRemovesItFromAutoIndex() public virtual void TestDeletingNodeRemovesItFromAutoIndex() { NewTransaction(); AutoIndexer <Node> nodeAutoIndexer = _graphDb.index().NodeAutoIndexer; nodeAutoIndexer.StartAutoIndexingProperty("foo"); nodeAutoIndexer.Enabled = true; Node node1 = _graphDb.createNode(); node1.SetProperty("foo", "bar"); NewTransaction(); using (IndexHits <Node> nodeIndexHits = _graphDb.index().forNodes("node_auto_index").query("_id_:*")) { assertThat(nodeIndexHits.Size(), equalTo(1)); } node1.Delete(); NewTransaction(); using (IndexHits <Node> nodeIndexHits = _graphDb.index().forNodes("node_auto_index").query("_id_:*")) { assertThat(nodeIndexHits.Size(), equalTo(0)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testRemoveRelationshipRemovesDocument() public virtual void TestRemoveRelationshipRemovesDocument() { NewTransaction(); AutoIndexer <Relationship> autoIndexer = _graphDb.index().RelationshipAutoIndexer; autoIndexer.StartAutoIndexingProperty("foo"); autoIndexer.Enabled = true; Node node1 = _graphDb.createNode(); Node node2 = _graphDb.createNode(); Relationship rel = node1.CreateRelationshipTo(node2, RelationshipType.withName("foo")); rel.SetProperty("foo", "bar"); NewTransaction(); using (IndexHits <Relationship> relationshipIndexHits = _graphDb.index().forRelationships("relationship_auto_index").query("_id_:*")) { assertThat(relationshipIndexHits.Size(), equalTo(1)); } NewTransaction(); rel.Delete(); NewTransaction(); using (IndexHits <Relationship> relationshipIndexHits = _graphDb.index().forRelationships("relationship_auto_index").query("_id_:*")) { assertThat(relationshipIndexHits.Size(), equalTo(0)); } }
private static int SizeOf <T1>(Index <T1> index) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: try (org.neo4j.graphdb.index.IndexHits<?> indexHits = index.query("_id_:*")) using (IndexHits <object> indexHits = index.query("_id_:*")) { return(indexHits.Size()); } }
public DocToIdIterator(IndexHits <Document> source, ICollection <EntityId> exclude, IndexReference searcherOrNull, LongSet idsModifiedInTransactionState) { this._source = source; this._removedInTransactionState = exclude; this._searcherOrNull = searcherOrNull; this._idsModifiedInTransactionState = idsModifiedInTransactionState; if (source.Size() == 0) { Close(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReturnEmptyIteratorWhenNoHits() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal void ShouldReturnEmptyIteratorWhenNoHits() { // given DocValuesCollector collector = new DocValuesCollector(false); IndexReaderStub readerStub = IndexReaderWithMaxDocs(42); // when collector.DoSetNextReader(readerStub.Context); // then IndexHits <Document> indexHits = collector.GetIndexHits(null); assertEquals(0, indexHits.Size()); assertEquals(Float.NaN, indexHits.CurrentScore(), 0.001f); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse(indexHits.hasNext()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testForceOpenIfChanged() public virtual void TestForceOpenIfChanged() { // do some actions to force the indexreader to be reopened using (Transaction tx = _graphDb.beginTx()) { Node node1 = _graphDb.getNodeById(_id1); Node node2 = _graphDb.getNodeById(_id2); Node node3 = _graphDb.getNodeById(_id3); node1.SetProperty("np2", "test property"); node1.GetRelationships(RelationshipType.withName("FOO")).forEach(Relationship.delete); // check first node Relationship rel; using (IndexHits <Relationship> hits = RelationShipAutoIndex().get("type", "FOO", node1, node3)) { assertEquals(0, hits.Size()); } // create second relation ship rel = node1.CreateRelationshipTo(node3, RelationshipType.withName("FOO")); rel.SetProperty("type", "FOO"); // check second node -> crashs with old FullTxData using (IndexHits <Relationship> indexHits = RelationShipAutoIndex().get("type", "FOO", node1, node2)) { assertEquals(0, indexHits.Size()); } // create second relation ship rel = node1.CreateRelationshipTo(node2, RelationshipType.withName("FOO")); rel.SetProperty("type", "FOO"); using (IndexHits <Relationship> relationships = RelationShipAutoIndex().get("type", "FOO", node1, node2)) { assertEquals(1, relationships.Size()); } tx.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void question5346011() public virtual void Question5346011() { GraphDatabaseService service = (new TestGraphDatabaseFactory()).newImpermanentDatabase(); using (Transaction tx = service.BeginTx()) { RelationshipIndex index = service.Index().forRelationships("exact"); // ...creation of the nodes and relationship Node node1 = service.CreateNode(); Node node2 = service.CreateNode(); string uuid = "xyz"; Relationship relationship = node1.CreateRelationshipTo(node2, RelationshipType.withName("related")); index.add(relationship, "uuid", uuid); // query using (IndexHits <Relationship> hits = index.Get("uuid", uuid, node1, node2)) { assertEquals(1, hits.Size()); } tx.Success(); } service.Shutdown(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldReturnIndexHitsInIndexOrderWhenNoSortIsGiven() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal void ShouldReturnIndexHitsInIndexOrderWhenNoSortIsGiven() { // given DocValuesCollector collector = new DocValuesCollector(); IndexReaderStub readerStub = IndexReaderWithMaxDocs(42); // when collector.DoSetNextReader(readerStub.Context); collector.Collect(1); collector.Collect(2); // then IndexHits <Document> indexHits = collector.GetIndexHits(null); assertEquals(2, indexHits.Size()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals("1", indexHits.next().get("id")); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertEquals("2", indexHits.next().get("id")); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse(indexHits.hasNext()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void indexContentsShouldStillBeOrderedAfterRemovalOfKey() public virtual void IndexContentsShouldStillBeOrderedAfterRemovalOfKey() { string indexName = "index"; using (Transaction tx = Db.beginTx()) { Db.index().forNodes(indexName); tx.Success(); } long delete; long first; long second; long third; long fourth; using (Transaction tx = Db.beginTx()) { Index <Node> nodeIndex = Db.index().forNodes(indexName); Node node = Db.createNode(); delete = node.Id; nodeIndex.Add(node, "keydelte", "delete"); node = Db.createNode(); second = node.Id; nodeIndex.Add(node, "key", ValueContext.numeric(2)); nodeIndex.Add(node, "keydelte", "delete"); node = Db.createNode(); fourth = node.Id; nodeIndex.Add(node, "key", ValueContext.numeric(4)); nodeIndex.Add(node, "keydelte", "delete"); node = Db.createNode(); first = node.Id; nodeIndex.Add(node, "key", ValueContext.numeric(1)); nodeIndex.Add(node, "keydelte", "delete"); node = Db.createNode(); third = node.Id; nodeIndex.Add(node, "key", ValueContext.numeric(3)); nodeIndex.Add(node, "keydelte", "delete"); tx.Success(); } using (Transaction tx = Db.beginTx()) { Index <Node> nodeIndex = Db.index().forNodes(indexName); IndexHits <Node> query = nodeIndex.query("key", QueryContext.numericRange("key", 2, 3)); assertEquals(2, query.Size()); query.forEachRemaining(node => assertTrue(node.Id == second || node.Id == third)); } using (Transaction tx = Db.beginTx()) { Index <Node> nodeIndex = Db.index().forNodes(indexName); nodeIndex.Remove(Db.getNodeById(delete), "keydelete"); nodeIndex.Remove(Db.getNodeById(first), "keydelete"); nodeIndex.Remove(Db.getNodeById(second), "keydelete"); nodeIndex.Remove(Db.getNodeById(third), "keydelete"); nodeIndex.Remove(Db.getNodeById(fourth), "keydelete"); tx.Success(); } using (Transaction tx = Db.beginTx()) { Index <Node> nodeIndex = Db.index().forNodes(indexName); IndexHits <Node> query = nodeIndex.query("key", QueryContext.numericRange("key", 2, 3)); assertEquals(2, query.Size()); query.forEachRemaining(node => assertTrue(node.Id == second || node.Id == third)); } }