public IndexDefinitionRepresentation createSchemaIndex( String labelName, Iterable<String> propertyKey ) { IndexCreator indexCreator = graphDb.schema().indexFor( label( labelName ) ); for ( String key : propertyKey ) { indexCreator = indexCreator.on( key ); } return new IndexDefinitionRepresentation( indexCreator.create() ); }
public static IndexDefinition createIndexNoWait( GraphDatabaseService beansAPI, Label label, String... properties ) { IndexDefinition indexDef; try ( Transaction tx = beansAPI.beginTx() ) { IndexCreator indexCreator = beansAPI.schema().indexFor( label ); for ( String property : properties ) { indexCreator = indexCreator.on( property ); } indexDef = indexCreator.create(); tx.success(); } return indexDef; }
private static void createIndexesAndData( GraphDatabaseService db, Label label ) { try ( Transaction tx = db.beginTx() ) { db.schema().indexFor( label ).on( KEY1 ).create(); db.schema().indexFor( label ).on( KEY1 ).on( KEY2 ).create(); tx.success(); } try ( Transaction tx = db.beginTx() ) { db.schema().awaitIndexesOnline( 10, TimeUnit.SECONDS ); tx.success(); } createData( db, label ); }
@Test public void testExportIndexesViaCypherResult() { final Label label = Label.label( "Foo" ); gdb.schema().indexFor( label ).on( "bar" ).create(); gdb.schema().indexFor( label ).on( "bar2" ).create(); commitAndStartNewTransactionAfterSchemaChanges(); Node n = gdb.createNode( label ); final ExecutionResult result = result( "node", n ); final SubGraph graph = CypherResultSubGraph.from( result, gdb, true ); assertEquals( "create index on :`Foo`(`bar2`);" + lineSeparator() + "create index on :`Foo`(`bar`);" + lineSeparator() + "create (_0:`Foo`)" + lineSeparator() + ";" + lineSeparator(), doExportGraph( graph ) ); }