org.neo4j.graphdb.schema.Schema Java Examples
The following examples show how to use
org.neo4j.graphdb.schema.Schema.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Neo4jModule.java From SciGraph with Apache License 2.0 | 6 votes |
public static void setupSchemaIndexes(GraphDatabaseService graphDb, Neo4jConfiguration config) { Map<String, Set<String>> schemaIndexes = config.getSchemaIndexes(); for (Map.Entry<String, Set<String>> entry : schemaIndexes.entrySet()) { Label label = Label.label(entry.getKey()); for (String property : entry.getValue()) { try (Transaction tx = graphDb.beginTx()) { Schema schema = graphDb.schema(); IndexDefinition indexDefinition = schema.indexFor(label).on(property).create(); tx.success(); tx.close(); Transaction tx2 = graphDb.beginTx(); schema.awaitIndexOnline(indexDefinition, 2, TimeUnit.MINUTES); tx2.success(); tx2.close(); } } } }
Example #2
Source File: Neo4JDb.java From knowledge-extraction with Apache License 2.0 | 5 votes |
public void createIndexes() { try (Transaction tx = graphDb.beginTx()) { Schema schema = graphDb.schema(); schema.indexFor(DynamicLabel.label(LAB_SUBJECT)) .on(PROP_NAME).create(); tx.success(); } }
Example #3
Source File: IndexManager.java From paprika with GNU Affero General Public License v3.0 | 4 votes |
public void createIndex(){ try ( Transaction tx = graphDatabaseService.beginTx() ) { Schema schema = graphDatabaseService.schema(); if(schema.getIndexes(DynamicLabel.label("Variable")).iterator().hasNext()) { schema.indexFor(DynamicLabel.label("Variable")) .on("app_key") .create(); } if(schema.getIndexes(DynamicLabel.label("Method")).iterator().hasNext()) { schema.indexFor(DynamicLabel.label("Method")) .on("app_key") .create(); schema.indexFor(DynamicLabel.label("Method")) .on("is_static") .create(); } if(schema.getIndexes(DynamicLabel.label("Argument")).iterator().hasNext()) { schema.indexFor(DynamicLabel.label("Argument")) .on("app_key") .create(); schema.indexFor(DynamicLabel.label("Argument")) .on("app_key") .create(); } if(schema.getIndexes(DynamicLabel.label("ExternalClass")).iterator().hasNext()) { schema.indexFor(DynamicLabel.label("ExternalClass")) .on("app_key") .create(); } if(schema.getIndexes(DynamicLabel.label("ExternalMethod")).iterator().hasNext()) { schema.indexFor(DynamicLabel.label("ExternalMethod")) .on("app_key") .create(); } tx.success(); } try ( Transaction tx = graphDatabaseService.beginTx() ) { org.neo4j.graphdb.index.IndexManager index = graphDatabaseService.index(); if(!index.existsForRelationships("calls")) { index.forRelationships("calls"); } tx.success(); } }