本文整理了Java中org.neo4j.graphdb.schema.Schema.indexFor()
方法的一些代码示例,展示了Schema.indexFor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Schema.indexFor()
方法的具体详情如下:
包路径:org.neo4j.graphdb.schema.Schema
类名称:Schema
方法名:indexFor
[英]Returns an IndexCreator where details about the index to create can be specified. When all details have been entered IndexCreator#create()must be called for it to actually be created. Creating an index enables indexing for nodes with the specified label. The index will have the details supplied to the IndexCreator. All existing and all future nodes matching the index definition will be indexed, speeding up future operations.
[中]返回一个IndexCreator,可以在其中指定要创建的索引的详细信息。输入所有详细信息后,必须调用IndexCreator#create()才能实际创建它。创建索引可以为具有指定标签的节点建立索引。索引将向IndexCreator提供详细信息。所有与索引定义匹配的现有和未来节点都将被索引,从而加快未来的操作。
代码示例来源:origin: neo4j/neo4j
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() );
}
代码示例来源:origin: neo4j/neo4j
private static IndexDefinition createIndex( GraphDatabaseService db )
{
try ( Transaction tx = db.beginTx() )
{
IndexDefinition index = db.schema().indexFor( LABEL_ONE ).on( KEY ).create();
tx.success();
return index;
}
}
代码示例来源:origin: neo4j/neo4j
private IndexDefinition createIndex()
{
try ( Transaction tx = db.beginTx() )
{
IndexDefinition index = db.schema().indexFor( myLabel ).on( "number_of_bananas_owned" ).create();
tx.success();
return index;
}
}
代码示例来源:origin: neo4j/neo4j
@Override
void doCreateIndex( DatabaseRule db )
{
db.schema().indexFor( indexLabel ).on( numberProp1 ).on( numberProp2 ).create();
}
}
代码示例来源:origin: neo4j/neo4j
private IndexDefinition indexAliensBySpecimen()
{
try ( Transaction tx = db.beginTx() )
{
IndexDefinition definition = db.schema().indexFor( ALIEN ).on( SPECIMEN ).create();
tx.success();
return definition;
}
}
代码示例来源:origin: neo4j/neo4j
@Override
void doCreateIndex( DatabaseRule db )
{
db.schema().indexFor( indexLabel ).on( stringProp1 ).on( stringProp2 ).create();
}
}
代码示例来源:origin: neo4j/neo4j
private IndexDefinition createIndex( Label label )
{
try ( Transaction tx = db.beginTx() )
{
IndexDefinition definition = db.schema().indexFor( label ).on( NUM_BANANAS_KEY ).create();
tx.success();
return definition;
}
}
代码示例来源:origin: neo4j/neo4j
@Override
void doCreateIndex( DatabaseRule db )
{
db.schema().indexFor( indexLabel ).on( stringProp1 ).create();
}
}
代码示例来源:origin: neo4j/neo4j
private IndexDefinition createIndex( Label label )
{
try ( Transaction tx = db.beginTx() )
{
IndexDefinition index = db.schema().indexFor( label ).on( key ).create();
tx.success();
return index;
}
}
代码示例来源:origin: neo4j/neo4j
public static Function<GraphDatabaseService,Void> index( Label label, String propertyKey )
{
return graphDb ->
{
graphDb.schema().indexFor( label ).on( propertyKey ).create();
return null;
};
}
代码示例来源:origin: neo4j/neo4j
private IndexDefinition createIndex( Label label, String propertyName )
{
try ( Transaction transaction = database.beginTx() )
{
IndexDefinition indexDefinition = database.schema().indexFor( label ).on( propertyName ).create();
transaction.success();
return indexDefinition;
}
}
}
代码示例来源:origin: neo4j/neo4j
@Override
void doCreateIndex( DatabaseRule db )
{
db.schema().indexFor( indexLabel ).on( numberProp1 ).create();
}
}
代码示例来源:origin: neo4j/neo4j
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;
}
代码示例来源:origin: neo4j/neo4j
@Override
protected IndexDefinition obtainEntityInTransaction( GraphDatabaseService graphDatabaseService )
{
return graphDatabaseService
.schema()
.indexFor( Label.label( "Label" ) )
.on( "property" )
.create();
}
}
代码示例来源:origin: neo4j/neo4j
private Runnable createIndexForLabelAndProperty( Label label, String propertyKey )
{
return () ->
{
try ( Transaction transaction = database.beginTx() )
{
database.schema().indexFor( label ).on( propertyKey ).create();
transaction.success();
}
waitForOnlineIndexes();
};
}
代码示例来源:origin: neo4j/neo4j
private static Function<GraphDatabaseService, Void> succeedAfterSchemaOperation(
final Function<GraphDatabaseService, ?> function )
{
return graphDb ->
{
// given
graphDb.schema().indexFor( label( "Label1" ) ).on( "key1" ).create();
// when/then
function.apply( graphDb );
return null;
};
}
代码示例来源:origin: neo4j/neo4j
private Runnable indexCreate( int labelIndex )
{
return () ->
{
try ( Transaction tx = db.beginTx() )
{
db.schema().indexFor( label( labelIndex ) ).on( KEY ).create();
tx.success();
}
};
}
代码示例来源:origin: neo4j/neo4j
private static Consumer<GraphDatabaseService> index( String label, String prop )
{
return db -> db.schema().indexFor( Label.label( label ) ).on( prop ).create();
}
代码示例来源:origin: neo4j/neo4j
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 );
}
代码示例来源:origin: neo4j/neo4j
@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 ) );
}
内容来源于网络,如有侵权,请联系作者删除!