RNeo4j错误:400错误请求

RNeo4j错误:400错误请求,neo4j,cypher,r-neo4j,Neo4j,Cypher,R Neo4j,我不知道为什么会出现下面的错误,但我想是我做错了什么 首先,您可以通过从下载文件dataset.r并使用dget(“dataset.r”)将其加载到会话中来获取我的数据集 在我的例子中,我将执行dat=dget(“dataset.r”) 下面的代码是我用来将数据加载到Neo4j中的代码 library(RNeo4j) graph = startGraph("http://localhost:7474/db/data/") graph$version # sure that the graph

我不知道为什么会出现下面的错误,但我想是我做错了什么

首先,您可以通过从下载文件
dataset.r
并使用
dget(“dataset.r”)
将其加载到会话中来获取我的数据集

在我的例子中,我将执行
dat=dget(“dataset.r”)

下面的代码是我用来将数据加载到Neo4j中的代码

library(RNeo4j)

graph = startGraph("http://localhost:7474/db/data/")
graph$version

# sure that the graph is clean -- you should backup first!!!
clear(graph, input = FALSE)

## ensure the constraints
addConstraint(graph, "School", "unitid")
addConstraint(graph, "Topic", "topic_id")

## create the query
## BE CAREFUL OF WHITESPACE between KEY:VALUE pairs for parameters!!!
query = "
MERGE (s:School {unitid:{unitid},
instnm:{instnm},
obereg:{obereg},
carnegie:{carnegie},
applefeeu:{applfeeu},
enrlft:{enrlft},
applcn:{applcn},
admssn:{admssn},
admit_rate:{admit_rate},
ape:{ape},
sat25:{sat25},
sat75:{sat75} })

MERGE (t:Topic {topic_id:{topic_id},
topic:{topic} })

MERGE (s)-[:HAS_TOPIC {score:{score} }]->(t)
"

for (i in 1:nrow(dat)) {
  ## status
  cat("starting row ", i, "\n")
  ## run the query
  cypher(graph, 
         query, 
         unitid = dat$unitid[i],
         instnm = dat$instnm[i],
         obereg = dat$obereg[i],
         carnegie = dat$carnegie[i],
         applfeeu = dat$applfeeu[i],
         enrlft = dat$enrlt[i],
         applcn = dat$applcn[i],
         admssn = dat$admssn[i],
         admit_rate = dat$admit_rate[i],
         ape = dat$apps_per_enroll[i],
         sat25 = dat$sat25[i],
         sat75 = dat$sat75[i],
         topic_id = dat$topic_id[i],
         topic = dat$topic[i],
         score = dat$score[i] )
} #endfor
我可以成功地加载数据帧
dat
的前49条记录,但在第50行出错

这是我收到的错误:

starting row  50 
 Show Traceback

 Rerun with Debug
 Error: 400 Bad Request

{"message":"Node 1477 already exists with label School and property \"unitid\"=[110680]","exception":"CypherExecutionException","fullname":"org.neo4j.cypher.CypherExecutionException","stacktrace":["org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext.org$neo4j$cypher$internal$compiler$v2_1$spi$ExceptionTranslatingQueryContext$$translateException(ExceptionTranslatingQueryContext.scala:154)","org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext$ExceptionTranslatingOperations.setProperty(ExceptionTranslatingQueryContext.scala:121)","org.neo4j.cypher.internal.compiler.v2_1.spi.UpdateCountingQueryContext$CountingOps.setProperty(UpdateCountingQueryContext.scala:130)","org.neo4j.cypher.internal.compiler.v2_1.mutation.PropertySetAction.exec(PropertySetAction.scala:51)","org.neo4j.cypher.internal.compiler.v2_1.mutation.MergeNodeAction$$anonfun$exec$1.apply(MergeNodeAction.scala:80)","org.neo4j.cypher.internal.compiler.v2_1 
以下是我的会话信息:

> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RNeo4j_1.2.0

loaded via a namespace (and not attached):
[1] RCurl_1.95-4.1  RJSONIO_1.2-0.2 tools_3.1.0 
值得注意的是,我使用的是Neo4j
2.1.3


感谢您事先提供的帮助。

这是一个有关
合并
工作方式的问题。通过在这里设置
MERGE
子句本身中的
score
属性

MERGE (s)-[:HAS_TOPIC {score:{score} }]->(t) 
MERGE
尝试创建整个模式,因此违反了唯一性约束。相反,请执行以下操作:

MERGE (s)-[r:HAS_TOPIC]->(t)
SET r.score = {score}
进行此更改后,我可以导入您的所有数据。

更新:我加入了一个
tryCatch
和一个
next
来跳过传递错误。以下是出现问题的行:
50-55364661
。关于那些引起你注意的行有什么事吗