public Representation getAutoIndexedRelationships( String key, String value ) { final ReadableIndex<Relationship> index = graphDb.index().getRelationshipAutoIndexer().getAutoIndex(); return toListRelationshipRepresentation( index.get( key, value ), null ); }
public ListRepresentation getAutoIndexedRelationshipsByQuery( String query ) { final ReadableIndex<Relationship> index = graphDb.index().getRelationshipAutoIndexer().getAutoIndex(); final IndexHits<Relationship> results = query != null ? index.query( query ) : null; return toListRelationshipRepresentation( results, null ); }
private ReadableRelationshipIndex relationShipAutoIndex() { return graphDb.index().getRelationshipAutoIndexer().getAutoIndex(); }
@Test public void testDefaultsAreSeparateForNodesAndRelationships() { stopDb(); config = new HashMap<>(); config.put( GraphDatabaseSettings.node_keys_indexable.name(), "propName" ); config.put( GraphDatabaseSettings.node_auto_indexing.name(), "true" ); // Now only node properties named propName should be indexed. startDb(); newTransaction(); Node node1 = graphDb.createNode(); Node node2 = graphDb.createNode(); node1.setProperty( "propName", "node1" ); node2.setProperty( "propName", "node2" ); node2.setProperty( "propName_", "node2" ); Relationship rel = node1.createRelationshipTo( node2, RelationshipType.withName( "DYNAMIC" ) ); rel.setProperty( "propName", "rel1" ); newTransaction(); ReadableIndex<Node> autoIndex = graphDb.index().getNodeAutoIndexer().getAutoIndex(); assertEquals( node1, autoIndex.get( "propName", "node1" ).getSingle() ); assertEquals( node2, autoIndex.get( "propName", "node2" ).getSingle() ); assertFalse( graphDb.index().getRelationshipAutoIndexer().getAutoIndex().get( "propName", "rel1" ).hasNext() ); }
db.index().getRelationshipAutoIndexer().getAutoIndex(); Node start = db.getNodeById( startId ); Node end = db.getNodeById( endId ); assertEquals( 1, hits.size() ); rel.delete(); autoRelationshipIndex = db.index().getRelationshipAutoIndexer().getAutoIndex(); hits = autoRelationshipIndex.get( "Type", type.name(), start, end ); assertEquals( 0, count( hits ) );
/** * It is not allowed to add items manually to automatic indexes. */ @Test @Graph( nodes = {@NODE( name = "I" ), @NODE( name = "you" )}, relationships = {@REL( start = "I", end = "you", type = "know", properties = {@PROP( key = "since", value = "today" )} )}, autoIndexRelationships = true ) public void items_can_not_be_added_manually_to_a_Relationship_AutoIndex() { data.get(); String indexName; try ( Transaction tx = graphdb().beginTx() ) { indexName = graphdb().index().getRelationshipAutoIndexer().getAutoIndex().getName(); tx.success(); } try ( Transaction tx = graphdb().beginTx() ) { ResourceIterable<Relationship> relationships = (ResourceIterable<Relationship>) data.get().get( "I" ).getRelationships(); try ( ResourceIterator<Relationship> resourceIterator = relationships.iterator() ) { gen.get().expectedStatus( 405 ) .payload( createJsonStringFor( getRelationshipUri( resourceIterator.next() ), "name", "I" ) ) .post( postRelationshipIndexUri( indexName ) ).entity(); } } }
@Test @Graph( nodes = { @NODE( name = "I", properties = { @PROP( key = "name", value = "me" ), @PROP( key = "bool", value = "true", type = GraphDescription.PropType.BOOLEAN ) } ), @NODE( name = "you", setNameProperty = true ) }, relationships = { @REL( start = "I", end = "you", type = "knows", properties = { @PROP( key = "name", value = "relProp" ), @PROP( key = "valid", value = "true", type = GraphDescription.PropType.BOOLEAN ) } ) }, autoIndexRelationships = true ) public void canCreateMoreInvolvedGraphWithPropertiesAndAutoIndex() { data.get(); verifyIKnowYou( "knows", "me" ); try ( Transaction ignored = graphdb.beginTx() ) { assertEquals( true, data.get().get( "I" ).getProperty( "bool" ) ); assertFalse( "node autoindex enabled.", graphdb().index().getNodeAutoIndexer().isEnabled() ); try ( IndexHits<Relationship> relationships = graphdb().index() .getRelationshipAutoIndexer().getAutoIndex().get( "name", "relProp" ) ) { assertTrue( "can't look up rel.", relationships.hasNext() ); } assertTrue( "relationship autoindex enabled.", graphdb().index().getRelationshipAutoIndexer().isEnabled() ); } }
.getAutoIndex() .getName(); gen.get()
public Representation getAutoIndexedRelationships( String key, String value ) { final ReadableIndex<Relationship> index = graphDb.index().getRelationshipAutoIndexer().getAutoIndex(); return toListRelationshipRepresentation( index.get( key, value ), null ); }
public ListRepresentation getAutoIndexedRelationshipsByQuery( String query ) { final ReadableIndex<Relationship> index = graphDb.index().getRelationshipAutoIndexer().getAutoIndex(); final IndexHits<Relationship> results = query != null ? index.query( query ) : null; return toListRelationshipRepresentation( results, null ); }
public Iterable<Edge> getEdges(final String key, final Object value) { this.autoStartTransaction(false); final AutoIndexer indexer = this.rawGraph.index().getRelationshipAutoIndexer(); if (indexer.isEnabled() && indexer.getAutoIndexedProperties().contains(key)) return new Neo4j2EdgeIterable(this.rawGraph.index().getRelationshipAutoIndexer().getAutoIndex().get(key, value), this, this.checkElementsInTransaction()); else return new PropertyFilteredIterable<Edge>(key, value, this.getEdges()); }