@Test public void testConfigAndAPICompatibility() { stopDb(); config = new HashMap<>(); config.put( GraphDatabaseSettings.node_keys_indexable.name(), "nodeProp1, nodeProp2" ); config.put( GraphDatabaseSettings.relationship_keys_indexable.name(), "relProp1, relProp2" ); config.put( GraphDatabaseSettings.node_auto_indexing.name(), "true" ); config.put( GraphDatabaseSettings.relationship_auto_indexing.name(), "true" ); startDb(); newTransaction(); assertTrue( graphDb.index().getNodeAutoIndexer().isEnabled() ); assertTrue( graphDb.index().getRelationshipAutoIndexer().isEnabled() ); AutoIndexer<Node> autoNodeIndexer = graphDb.index().getNodeAutoIndexer(); // Start auto indexing a new and an already auto indexed autoNodeIndexer.startAutoIndexingProperty( "nodeProp1" ); autoNodeIndexer.startAutoIndexingProperty( "nodeProp3" ); assertEquals( 3, autoNodeIndexer.getAutoIndexedProperties().size() ); assertTrue( autoNodeIndexer.getAutoIndexedProperties().contains( "nodeProp1" ) ); assertTrue( autoNodeIndexer.getAutoIndexedProperties().contains( "nodeProp2" ) ); assertTrue( autoNodeIndexer.getAutoIndexedProperties().contains( "nodeProp3" ) ); }
public boolean isRelationshipAutoIndexingEnabled(GraphDatabaseService graphDb) { return graphDb.index().getRelationshipAutoIndexer().isEnabled(); }
@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() ); } }
assertTrue( graphDb.index().getRelationshipAutoIndexer().isEnabled() );
public boolean isRelationshipAutoIndexingEnabled(GraphDatabaseService graphDb) { return graphDb.index().getRelationshipAutoIndexer().isEnabled(); }
public <T extends Element> Set<String> getIndexedKeys(final Class<T> elementClass) { if (elementClass == null) throw ExceptionFactory.classForElementCannotBeNull(); if (Vertex.class.isAssignableFrom(elementClass)) { if (!this.rawGraph.index().getNodeAutoIndexer().isEnabled()) return Collections.emptySet(); return this.rawGraph.index().getNodeAutoIndexer().getAutoIndexedProperties(); } else if (Edge.class.isAssignableFrom(elementClass)) { if (!this.rawGraph.index().getRelationshipAutoIndexer().isEnabled()) return Collections.emptySet(); return this.rawGraph.index().getRelationshipAutoIndexer().getAutoIndexedProperties(); } else { throw ExceptionFactory.classIsNotIndexable(elementClass); } }
public <T extends Element> void createKeyIndex(final String key, final Class<T> elementClass, final Parameter... indexParameters) { if (elementClass == null) throw ExceptionFactory.classForElementCannotBeNull(); if (Vertex.class.isAssignableFrom(elementClass)) { this.autoStartTransaction(true); if (!this.rawGraph.index().getNodeAutoIndexer().isEnabled()) this.rawGraph.index().getNodeAutoIndexer().setEnabled(true); this.rawGraph.index().getNodeAutoIndexer().startAutoIndexingProperty(key); if (!this.getInternalIndexKeys(Vertex.class).contains(key)) { KeyIndexableGraphHelper.reIndexElements(this, this.getVertices(), new HashSet<String>(Arrays.asList(key))); this.autoStartTransaction(true); this.createInternalIndexKey(key, elementClass); } } else if (Edge.class.isAssignableFrom(elementClass)) { this.autoStartTransaction(true); if (!this.rawGraph.index().getRelationshipAutoIndexer().isEnabled()) this.rawGraph.index().getRelationshipAutoIndexer().setEnabled(true); this.rawGraph.index().getRelationshipAutoIndexer().startAutoIndexingProperty(key); if (!this.getInternalIndexKeys(Edge.class).contains(key)) { KeyIndexableGraphHelper.reIndexElements(this, this.getEdges(), new HashSet<String>(Arrays.asList(key))); this.autoStartTransaction(true); this.createInternalIndexKey(key, elementClass); } } else { throw ExceptionFactory.classIsNotIndexable(elementClass); } }
public <T extends Element> void dropKeyIndex(final String key, final Class<T> elementClass) { if (elementClass == null) throw ExceptionFactory.classForElementCannotBeNull(); this.autoStartTransaction(true); if (Vertex.class.isAssignableFrom(elementClass)) { if (!this.rawGraph.index().getNodeAutoIndexer().isEnabled()) return; this.rawGraph.index().getNodeAutoIndexer().stopAutoIndexingProperty(key); } else if (Edge.class.isAssignableFrom(elementClass)) { if (!this.rawGraph.index().getRelationshipAutoIndexer().isEnabled()) return; this.rawGraph.index().getRelationshipAutoIndexer().stopAutoIndexingProperty(key); } else { throw ExceptionFactory.classIsNotIndexable(elementClass); } this.dropInternalIndexKey(key, elementClass); }