我是Neo4j的新手,面临一个小问题。
我创建了大约5000个路由器节点,其ipaddress属性设置为特定的ip。 现在我有大约5000个接口,需要创建他们的节点。我在c ++中使用json和rest api。
每个接口都有一个Routerip属性,如果routerip与已经创建的路由器节点的ipaddress匹配,我需要创建该接口。
我用过这个 http://docs.neo4j.org/chunked/snapshot/rest-api-cypher.html#rest-api-create-mutiple-nodes-with-properties链接以创建我的路由器。 现在我想使用相同的方法来创建我的接口。 有没有办法我可以这样做,在cypher查询中传递属性数组作为参数,并检查路由器是否存在以创建我的界面?
答案 0 :(得分:3)
有几种方法可以做到这一点。分解为步骤:
这看起来像
MATCH (router:Router)
WHERE router.ipaddress = props.RouterIp
CREATE (n:Interface { props } )-[:CONNECTED_TO]->(router)
答案 1 :(得分:0)
嘿当我尝试运行这个简单的查询时,它给了我java异常
{
"params" : {
"props" : [
{
"LocalAsNumber" : 0,
"NodeDescription" : "10TiMOS-B-4.0.R2 ",
"NodeId" : "10.227.28.95",
"NodeName" : "BLR_WAO_SARF7"
}
]
},
"query" : "MATCH (n:Router) where n.NodeId = {props}.NodeId RETURN n"}
"消息" :"声明已经结束。", "例外" :" BadInputException", "全名" :" org.neo4j.server.rest.repr.BadInputException", "堆栈跟踪" :[" org.neo4j.server.rest.repr.RepresentationExceptionHandlingIterable.exceptionOnHasNext(RepresentationExceptionHandlingIterable.java:50)"," org.neo4j.helpers.collection.ExceptionHandlingIterable $ 1.hasNext(ExceptionHandlingIterable。 java:46)"," org.neo4j.helpers.collection.IteratorWrapper.hasNext(IteratorWrapper.java:42)"," org.neo4j.server.rest.repr。 ListRepresentation.serialize(ListRepresentation.java:71)"," org.neo4j.server.rest.repr.Serializer.serialize(Serializer.java:75)"," org。 neo4j.server.rest.repr.MappingSerializer.putList(MappingSerializer.java:61)"," org.neo4j.server.rest.repr.CypherResultRepresentation.serialize(CypherResultRepresentation.java:83)&#34 ;," org.neo4j.server.rest.repr.MappingRepresentation.serialize(MappingRepresentation.java:41)"," org.neo4j.server.rest.repr.OutputFormat.assemble(OutputFormat .java:215)"," org.neo4j.server.rest.repr.OutputFormat.formatRepresentation(OutputFormat.java:147)&# 34;," org.neo4j.server.rest.repr.OutputFormat.response(OutputFormat.java:130)"," org.neo4j.server.rest.repr.OutputFormat.ok( OutputFormat.java:67)"," org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:101)"," java.lang.reflect。 Method.invoke(Method.java:606)"," org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:132)"," org。 neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)"," java.lang.Thread.run(Thread.java:744)" ],