【问题标题】:gremlin-server neo4j : How to set id, multi labelgremlin-server neo4j:如何设置 id、多标签
【发布时间】:2018-11-15 06:14:06
【问题描述】:

我使用 http channelizer 和 neo4j 3.3.4 一起启动了 gremlin-server 3.3.4, 它奏效了。 neo4j-empty.propertiesconfiguration 低于

gremlin.graph=org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph
gremlin.neo4j.directory=/tmp/neo4j
gremlin.neo4j.conf.dbms.auto_index.nodes.enabled=true
gremlin.neo4j.conf.dbms.auto_index.relationships.enabled=true

但是 1.http://localhost:8182/?gremlin=g.addV("test").property(id,"abc") 返回错误

{
"message": "Vertex does not support user supplied identifiers",
"Exception-Class": "java.lang.UnsupportedOperationException",
"exceptions": [
"java.lang.UnsupportedOperationException"
],
"stackTrace": "java.lang.UnsupportedOperationException: Vertex does not support user supplied identifiers\n\tat org.apache.tinkerpop.gremlin.structure.Vertex$Exceptions.userSuppliedIdsNotSupported(Vertex.java:163)\n\tat org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph.addVertex(Neo4jGraph.java:162)\n\tat org.apache.tinkerpop.gremlin.process.traversal.step.map.AddVertexStartStep.processNextStart(AddVertexStartStep.java:91)\n\tat org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143)\n\tat org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:192)\n\tat org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils.fill(IteratorUtils.java:62)\n\tat org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils.list(IteratorUtils.java:85)\n\tat org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils.asList(IteratorUtils.java:382)\n\tat org.apache.tinkerpop.gremlin.server.handler.HttpGremlinEndpointHandler.lambda$channelRead$1(HttpGremlinEndpointHandler.java:247)\n\tat org.apache.tinkerpop.gremlin.util.function.FunctionUtils.lambda$wrapFunction$0(FunctionUtils.java:36)\n\tat org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:269)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base/java.lang.Thread.run(Thread.java:834)\n"
}

和 2. 我添加了带有多标签 http://localhost:8182/?gremlin=g.addV("test::test2") 的顶点并查询 http://localhost:8182/?gremlin=g.V().hasLabel("test") 返回空节点

{
"requestId": "ec79c0f7-e4aa-485e-ace4-6e534e8252c5",
"status": {
"message": "",
"code": 200,
"attributes": {
"@type": "g:Map",
"@value": []
}
},
"result": {
"data": {
"@type": "g:List",
"@value": []
},
"meta": {
"@type": "g:Map",
"@value": []
}
}
}

我怎样才能让它们工作?我找到了一些东西,但我还找不到配置选项。请帮忙 http://tinkerpop.apache.org/docs/current/reference/#_elementidstrategy http://tinkerpop.apache.org/docs/current/reference/#_multi_label

【问题讨论】:

    标签: rest neo4j gremlin-server


    【解决方案1】:

    Neo4j 不允许 id 分配。如果您想分配自己的标识符,那么它需要是如下属性:

    g.addV("test").property("id","abc")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多