janusgraph:cypher-for-gremlin
cypher-for-gremlin
使用cypher语法写数据到janusgraph时遇到一些问题,我们采用先写点再写边的方式,gremlin-server配置为force-index,写点语句为
unwind %s as row merge
(s:node{obj_id:row.obj_id,ontology_id:row.ontology_id,ontology_type:row.ontology_type,obj_type:row.obj_type})
gremlin-server报错
Could not find a suitable index to answer graph query and graph scans are disabled: [(~label = node)]:VERTEX
这个错误表示找不到索引,第一次插入数据肯定是没有索引的,janusgraph由于配置了force-index会直接抛出失败异常,解决办法也不是没有,去掉force-index就可以了,但是这个时候gremlin-server会报
Query requires iterating over all vertices [()]. For better performance, use indexes
,这表示没有索引所以去全表scan,这是很慢的,一个批次数据量大了之后也会因为执行时间太久而中断,虽然如此,这至少能将点数据写进去,我们继续写边数据,写边语句如下:
unwind %s as