本文整理汇总了Java中org.neo4j.graphdb.index.RelationshipIndex.get方法的典型用法代码示例。如果您正苦于以下问题:Java RelationshipIndex.get方法的具体用法?Java RelationshipIndex.get怎么用?Java RelationshipIndex.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.graphdb.index.RelationshipIndex
的用法示例。
在下文中一共展示了RelationshipIndex.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: question5346011
import org.neo4j.graphdb.index.RelationshipIndex; //导入方法依赖的package包/类
@Test
public void question5346011()
{
GraphDatabaseService service = new TestGraphDatabaseFactory().newImpermanentDatabase();
try ( Transaction tx = service.beginTx() )
{
RelationshipIndex index = service.index().forRelationships( "exact" );
// ...creation of the nodes and relationship
Node node1 = service.createNode();
Node node2 = service.createNode();
String a_uuid = "xyz";
Relationship relationship = node1.createRelationshipTo( node2, DynamicRelationshipType.withName( "related" ) );
index.add( relationship, "uuid", a_uuid );
// query
IndexHits<Relationship> hits = index.get( "uuid", a_uuid, node1, node2 );
assertEquals( 1, hits.size() );
tx.success();
}
service.shutdown();
}
示例2: shouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode
import org.neo4j.graphdb.index.RelationshipIndex; //导入方法依赖的package包/类
@Test
public void shouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode()
{
// GIVEN
RelationshipIndex index = relationshipIndex( EXACT_CONFIG );
Node start = graphDb.createNode();
Node end = graphDb.createNode();
RelationshipType type = withName( "REL" );
Relationship rel = start.createRelationshipTo( end, type );
index.add( rel, "Type", type.name() );
finishTx( true );
beginTx();
// WHEN
IndexHits<Relationship> hits = index.get( "Type", type.name(), start, end );
assertEquals( 1, count( (Iterator<Relationship>)hits ) );
assertEquals( 1, hits.size() );
index.remove( rel );
// THEN
hits = index.get( "Type", type.name(), start, end );
assertEquals( 0, count( (Iterator<Relationship>)hits ) );
assertEquals( 0, hits.size() );
}
示例3: getRelationshipsFromIndex
import org.neo4j.graphdb.index.RelationshipIndex; //导入方法依赖的package包/类
@Override
public IRelationshipIterator getRelationshipsFromIndex(String name, String key, ParcelableIndexValue value, ParcelableError err)
throws RemoteException {
try {
resumeTrxIfExists();
try {
RelationshipIndex index = mDb.index().forRelationships(name); // this
// will
// create
// the
// index
IndexHits<Relationship> hits = index.get(key, value.get());
return new RelationshipIteratorWrapper(hits);
} finally {
suspendCurrentTrx("getRelationshipsFromIndex");
}
} catch (Exception e) {
Log.e(TAG, "Failed to add relationship to index '" + name + "'", e);
err.setError(Errors.TRANSACTION, e.getMessage());
return null;
}
}
示例4: doGetForRelationships
import org.neo4j.graphdb.index.RelationshipIndex; //导入方法依赖的package包/类
@Test
public void doGetForRelationships()
{
RelationshipIndex roles = graphDb.index().forRelationships( "roles" );
// START SNIPPET: getSingleRelationship
Relationship persephone = roles.get( "name", "Persephone" ).getSingle();
Node actor = persephone.getStartNode();
Node movie = persephone.getEndNode();
// END SNIPPET: getSingleRelationship
assertEquals( "Monica Bellucci", actor.getProperty( "name" ) );
assertEquals( "The Matrix Reloaded", movie.getProperty( "title" ) );
@SuppressWarnings("serial") List<String> expectedActors = new ArrayList<String>()
{
{
add( "Keanu Reeves" );
add( "Keanu Reeves" );
}
};
List<String> foundActors = new ArrayList<>();
// START SNIPPET: getRelationships
for ( Relationship role : roles.get( "name", "Neo" ) )
{
// this will give us Reeves twice
Node reeves = role.getStartNode();
// END SNIPPET: getRelationships
foundActors.add( (String) reeves.getProperty( "name" ) );
// START SNIPPET: getRelationships
}
// END SNIPPET: getRelationships
assertEquals( expectedActors, foundActors );
}
示例5: doQueriesForRelationships
import org.neo4j.graphdb.index.RelationshipIndex; //导入方法依赖的package包/类
@Test
public void doQueriesForRelationships()
{
IndexManager index = graphDb.index();
RelationshipIndex roles = index.forRelationships( "roles" );
Index<Node> actors = graphDb.index().forNodes( "actors" );
Index<Node> movies = index.forNodes( "movies" );
Node reeves = actors.get( "name", "Keanu Reeves" ).getSingle();
Node theMatrix = movies.get( "title", "The Matrix" ).getSingle();
// START SNIPPET: queryForRelationships
// find relationships filtering on start node
// using exact matches
IndexHits<Relationship> reevesAsNeoHits;
reevesAsNeoHits = roles.get( "name", "Neo", reeves, null );
Relationship reevesAsNeo = reevesAsNeoHits.iterator().next();
reevesAsNeoHits.close();
// END SNIPPET: queryForRelationships
assertEquals( "Neo", reevesAsNeo.getProperty( "name" ) );
Node actor = reevesAsNeo.getStartNode();
assertEquals( reeves, actor );
// START SNIPPET: queryForRelationships
// find relationships filtering on end node
// using a query
IndexHits<Relationship> matrixNeoHits;
matrixNeoHits = roles.query( "name", "*eo", null, theMatrix );
Relationship matrixNeo = matrixNeoHits.iterator().next();
matrixNeoHits.close();
// END SNIPPET: queryForRelationships
assertEquals( "Neo", matrixNeo.getProperty( "name" ) );
actor = matrixNeo.getStartNode();
assertEquals( reeves, actor );
// START SNIPPET: queryForRelationshipType
// find relationships filtering on end node
// using a relationship type.
// this is how to add it to the index:
roles.add( reevesAsNeo, "type", reevesAsNeo.getType().name() );
// Note that to use a compound query, we can't combine committed
// and uncommitted index entries, so we'll commit before querying:
tx.success();
tx.close();
// and now we can search for it:
try ( Transaction tx = graphDb.beginTx() )
{
IndexHits<Relationship> typeHits = roles.query( "type:ACTS_IN AND name:Neo", null, theMatrix );
Relationship typeNeo = typeHits.iterator().next();
typeHits.close();
// END SNIPPET: queryForRelationshipType
assertThat(typeNeo, inTx( graphDb, hasProperty( "name" ).withValue( "Neo" ) ));
actor = matrixNeo.getStartNode();
assertEquals( reeves, actor );
}
}
示例6: call
import org.neo4j.graphdb.index.RelationshipIndex; //导入方法依赖的package包/类
@Override
public void call( RelationshipIndex self )
{
self.get( "foo", 42, null, null );
}