【发布时间】:2014-03-08 14:18:18
【问题描述】:
我做了什么:
- 我创建了具有多个属性的节点,例如姓名、年龄、位置、性别等。
- 我想检索具有匹配属性值的节点并在它们之间创建关系。(例如,具有相同年龄或相同位置的节点)。
我已经这样做了:
void query()
{
ExecutionResult result;
Transaction tx=null;
ExecutionEngine engine = new ExecutionEngine( graphDb );
try
{
String name="Female";
tx=graphDb.beginTx();
result=engine.execute("start n=node(*) where has(n.City) with n.City as city, collect(n) as nodelist, count(*) as count where count > 1 return city, nodelist, count");
System.out.println(result.dumpToString());
tx.success();
}
catch(Exception e)
{
tx.failure();
}
finally
{
tx.finish();
}
}
节点列表为我提供了具有相同属性的节点。 我想在这些节点之间建立关系。
如何指向节点列表中的节点? 另外,请提出其他替代方法
【问题讨论】:
-
不要为每个查询方法创建执行引擎,在启动时创建一次并保留它。