gremlin

How can I get a list of indexed keys in Titan?

十年热恋 提交于 2019-12-07 05:23:37
问题 I am using Titan v0.3.1 and would like to see a list of which keys I have already indexed via createKeyIndex . How can I do this? 回答1: As you found for yourself you can use the Blueprints getIndexedKeys(Vertex.class) method for this, however the Titan type system has a lot more to offer than createKeyIndex . The longer you work with Titan the more you will want to learn about the Type Maker system: https://github.com/thinkaurelius/titan/wiki/Type-Definition-Overview In that case the types

Add edge if not exist using gremlin

吃可爱长大的小学妹 提交于 2019-12-07 04:23:02
问题 I'm using cosmos graph db in azure. Does anyone know if there is a way to add an edge between two vertex only if it doesn't exist (using gremlin graph query)? I can do that when adding a vertex, but not with edges. I took the code to do so from here: g.Inject(0).coalesce(__.V().has('id', 'idOne'), addV('User').property('id', 'idOne')) Thanks! 回答1: It is possible to do with edges. The pattern is conceptually the same as vertices and centers around coalesce() . Using the "modern" TinkerPop toy

How do I connect to a remote Neo4j database using gremlin python?

随声附和 提交于 2019-12-07 03:26:45
问题 From what I've read Neo4j implements apache tinkerpop which leads me to think I can use gremlin python and rather than connect to a gremlin server I can point the python code at a neo4j server and treat it like a gremlin server. However I can't find any information online which shows how to do this so I'm thinking maybe I've misunderstood something. a) Can I use gremlin python directly with a neo4j db instance? b) If yes to (a) then how? Thanks Alex 回答1: You can not connect gremlin-python to

Tinkerpop 3: compute connected components with Gremlin traversal

元气小坏坏 提交于 2019-12-06 13:39:09
I think the tags explain quite well my problem :) I've been trying to write a Gremlin traversal to compute the connected components of the simple graph described at the end of the post. I tried with g.V().repeat(both('e')).until(cyclicPath()).dedup().tree().by('name').next() obtaining ==>a={b={a={}, c={b={}}, d={c={d={}}}}, c={d={c={}}}} ==>e={f={e={}, g={f={}}}, h={f={h={}}}} ==>g={f={g={}}} which is bad, since the cyclicPath filter terminated the traversal starting from e before reaching g . Obviously, if I remove the until clause I get an infinite loop. Moreover, if I use simplePath the

How to use ElasticSearch index in Titan Gremlin query?

不打扰是莪最后的温柔 提交于 2019-12-06 10:23:32
问题 I've managed to set up Titan (v0.3.1) with Elastic Search in embedded mode, thanks to the Titan docs. However, my question is now: how do I take advantage of the ES indexing? For example, I would like to use Text.CONTAINS (which is supported, according to docs linked above). Specifically, I'd like to retrieve nodes with the string "abc" somewhere in the value for a key called my_label . What syntax would achieve this goal from the Gremlin console? 回答1: Searching against an external index The

Random Walk on Bipartite Graph with Gremlin

时光毁灭记忆、已成空白 提交于 2019-12-06 06:46:29
问题 I would like to rank items according to a given users preference (items liked by the user) based on a random walk on a directed bipartite graph using gremlin in groovy. The graph has the following basic structure: [User1] ---'likes'---> [ItemA] <---'likes'--- [User2] ---'likes'---> [ItemB] Hereafter the query that I came up with: def runRankQuery(def userVertex) { def m = [:] def c = 0 while (c < 1000) { userVertex .out('likes') // get all liked items of current or similar user .shuffle[0] //

how to query by vertex id in Datastax DSE 5.0 Graph in a concise way?

狂风中的少年 提交于 2019-12-06 06:30:59
It seems that the unique id for vertices is community_id in DSE Graph. I have found that this works (id is long) : v = g.V().has("VertexLabel","community_id",id).next() none of those work: v = g.V("community_id",id).next() v = g.V("community_id","VertexLabel:"+id).next() v = g.V(id).next() v = g.V().hasId(id).next() v = g.V().hasId("VertexLabel:"+id).next() v = g.V("VertexLabel:"+id).next() Edit After some investigation I found that for a vertex v, v.id() returns a LinkedHashMap: Vertex v = gT.next(); Object id = v.id(); System.out.println(id); System.out.println(id.getClass()); System.out

Gremlin when storing a GremlinGroovyPipeline and calling .count() on it

跟風遠走 提交于 2019-12-06 06:04:32
This works as expected: gremlin> root.out.outE.has('size', 4).count() ==>3 gremlin> result = root.out.outE.has('size', 4).count() ==>3 gremlin> result ==>3 gremlin> root.out.outE.has('count', 4).getClass() ==>class com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline When I store the GremlinGroovyPipeline into a variable, I can't count() it anymore: gremlin> result = root.out.outE.has('size', 4) ==>e[359:200:36028797018964014][200-sizes->40] ==>e[669:404:36028797018964014][404-sizes->400] ==>e[855:516:36028797018964014][516-sizes->524] gremlin> result.count() ==>0 gremlin> result.getClass() ==

OrientDB Gremlin - Retrieve Vertex for a class in gremlin not hitting indexes

十年热恋 提交于 2019-12-06 05:08:25
I'm using OrientDB 2.1.11 and rexster 2.6 and gremlin is the main query language. I use via rexpro (and rexster REST). My issue is: how to get the indexes to hit from gremlin (I must use gremlin not orient sql). I have a vertex class zipcode, which has 1 property zip_code defined in schema and indexed as dictionary: zipcode.zip_code DICTIONARY ["zip_code"] SBTREE But when I query it using gremlin, its slow when records are around >25k (haven't tested with lower numbers). To give proper context, I try to find the zipcode first, if it doesn't exist then I create the vertex for later use. Find

Gremlin remote command fails with timeout error: Host did not respond in a timely fashion

谁都会走 提交于 2019-12-06 04:34:29
问题 I connected to a remote gremlin server via gremlin groovy shell. Connection succeeded. But for any remote command I try to execute it gives timeout error. Even for command :> 1+1 gremlin> :remote connect tinkerpop.server conf/senthil.yaml ==>Connected - 10.40.40.65/10.40.40.65:50080 gremlin> :> 1+1 Host did not respond in a timely fashion - check the server status and submit again. Display stack trace? [yN] org.apache.tinkerpop.gremlin.groovy.plugin.RemoteException: Host did not respond in a