我在应用程序中使用 gremlin REST 服务器,并且想在单个查询中创建到顶点的多条边。我有一个顶点 ID 列表,从那里创建边到单个顶点。
例如 - gV(12,13,14,15).addEdge('uses', gV(100))
我尝试了很多遍历步骤,但无法使其工作。
我的 Java 应用程序中有一个图形遍历,在遍历完成后需要 300 毫秒以上才能填充路径对象。这很奇怪,因为它只发生在某些特定的遍历上,而其他遍历会立即填充它们的路径。这是 Java 代码示例,使用 Tinkerpop 3.3.1
我有一种情况,两个顶点由一条边直接连接。每次执行这个短遍历时,我都会得到很高的处理时间。如果我不执行 fill() 操作,遍历会立即完成。我还有其他需要遍历 10 多个边的遍历,并且它们在 < 1 毫秒内处理和填充路径。
在下面的代码中,我试图找到从“origs”中的顶点到“dests”中的顶点的最短路径,而不经过集合“avoids”中的任何顶点。遍历本身在 1 毫秒内完成,它的 fill() 方法消耗了时钟。
Date startTime = new Date ();
if (! dests.isEmpty ()){
g.V (origs).where (is (P.without (avoids))).
repeat (
out ().
simplePath ().
where (is (P.without (avoids)))
).
until (is (P.within (dests))).
limit (1).
path ().
fill (paths); // This 'fill' is the line that can take > 300ms.
// When fill is removed from the code,
// this all …Run Code Online (Sandbox Code Playgroud) 我添加了顶点createDate作为属性。我想使用createDate属性检索最新创建的顶点。
我怎样才能找回这个。请在这件事上给予我帮助。
我正在针对AWS neptune使用nodejs gremlin,要求是如果顶点存在则更新属性,否则创建一个新顶点,我在下面尝试过
g.V().has('event','id','1').
fold().
coalesce(unfold(),
addV('event').property('id','1'))
Run Code Online (Sandbox Code Playgroud)
但我收到“展开未定义”错误,如何解决此问题?
我用来awscurl将数据从 s3 批量加载到 neptune 中:
我做了以下事情:
\n我得到的错误是:
\n\n\n找不到 iam_role_arn 的 aws 凭证:arn:aws:iam::1111111:role/NeptuneAdmin
\n
确保我拥有此证书的最佳方法是什么?我正在从本地执行此操作。
\nawscurl -X POST \\ \xe2\x94\x80\xe2\x95\xaf\n -H 'Content-Type: application/json' \\\n https://endpoint.us-west-2.neptune.amazonaws.com:8182/loader -d '\n {\n "source" : "s3://tf-bulk-load-test/vertex.txt",\n "format" : "csv",\n "iamRoleArn" : "arn:aws:iam::1111111111:role/NeptuneAdmin",\n "region" : "us-west-2",\n "failOnError" : "FALSE",\n "parallelism" : "MEDIUM",\n "updateSingleCardinalityProperties" : "FALSE",\n "queueRequest" : "TRUE",\n "dependencies" : []\n }' \\\n --header …Run Code Online (Sandbox Code Playgroud) 我正在使用 TinkerPop 的本地实现和 docker imagetinkerpop/gremlin-server:3.4.1 来与 nodeJs 中的图形数据库进行本地交互。
我需要将 IDManager 设置为 ANY,以便它可以接受自定义顶点 ID 的字符串值(目前它仅适用于数字类型)。
我知道我需要设置 TinkerGraph gremlin.tinkergraph.vertexIdManager 的配置,但我不确定如何在我的 docker-compose 文件中使用正确的配置对其进行初始化。 http://tinkerpop.apache.org/docs/current/reference/#_configuration_4
有人知道怎么做吗?
谢谢
我有一个看起来像的图表
a --father_of--> 1 --wife_of--> b --father_of-->2 --wife_of--> c --father_of--> 3--wife_of--> d --father_of --> 5--wife_of-->e
Run Code Online (Sandbox Code Playgroud)
我想写一个查询,它给了我从树开始的所有父亲
我可以写一个级别
g.V('name','a').out(father_of).out(wife_of) 这给了b
如何编写一个递归查询,将b作为管道的输入,以便查询给出节点b,c,d和e.
我想知道如何有一个以嵌套格式返回结果的gremlin查询.假设有如下属性图:
USER和PAGE一些特性,如顶点AGE为USER顶点;
FOLLOW边缘USER和PAGE;
我正在寻找一个单一的高效查询,它为所有年龄大于20岁的用户提供所有跟随的用户.我可以使用来自应用程序端的简单循环来执行该操作,并且每次迭代使用简单的遍历查询.不幸的是,这样的解决方案对我来说效率不高,因为它会产生大量查询,并且在这种情况下网络延迟可能很大.
我正在使用Gremlin处理Titan Graph。而且我正在设法找到一种非常具体的关系。
我有标签,属性以及可能的start和endNode列表。
我希望所有关系都与此相匹配。
我已经有了这个来获取所有匹配标签和属性的关系:
GraphTraversal<Edge, Edge> tempOutput = g.E().hasLabel(relationshipStorage.getId());
if(relationshipStorage.getProperties() != null)
{
for (Map.Entry<String, Object> entry : relationshipStorage.getProperties().entrySet())
{
if (tempOutput == null)
{
break;
}
tempOutput = tempOutput.has(entry.getKey(), entry.getValue());
}
}
Run Code Online (Sandbox Code Playgroud)
但是我没有找到通过特定的start和endNode来获得它的方法。我不想在两个节点之间有多个边缘。我只想要具有特定顶点的一条边。
假设我有一个属性值列表作为ArrayList,如何通过列表中的值过滤节点。
这样可能吗...
g.V().filter {it.get().value("name") in list}
Run Code Online (Sandbox Code Playgroud)
也与TinkerPop 2.x兼容
gremlin ×10
tinkerpop ×5
titan ×4
tinkerpop3 ×3
java ×2
docker ×1
graph-theory ×1
groovy ×1
neo4j ×1
node.js ×1