tinkerpop

Tinkerpop/gremlin merge vertices (and edges)

拜拜、爱过 提交于 2019-12-20 02:59:08
问题 Is there an easy way to replace or merge vertices and keep/merge existing edges? Or just manually copy all properties from the vertex and recreate existing edges and all (meta-)properties and then drop the superfluous vertex? 回答1: Alright, as mentioned in the comments above, you're going to do the matching in OLTP. That means you'll likely have a concrete entry point. Let's make up a simple sample graph: g = TinkerGraph.open().traversal() // Stackoverflow data g.addV("user").property("login",

How to import a CSV file into Titan graph database?

半腔热情 提交于 2019-12-18 03:44:47
问题 Can anyone supply some sample code or hints on how to import a 1MB CSV of nodes, and another 1MB CSV of edges, into Titan graph database running on Cassandra? I've got small CSV files importing via Gremlin, but this doesn't seem appropriate for large files. I've seen Faunus can do this, but I'd like to avoid spending a couple of days setting it up if possible. It looks like BatchGraph might be the way to go (https://github.com/tinkerpop/blueprints/wiki/Batch-Implementation) but the example

Gremlin - Choose one item at random

蹲街弑〆低调 提交于 2019-12-16 20:01:39
问题 Consider me as 'user' 1. The aim of the query is to get the posts 'posted' by the people I follow and for each of those posts check: Whether it has been liked by me Whether it has been liked by anyone else that I follow and if yes choose one of those users at random to return Sample data: g.addV('user').property('id',1).as('1') addV('user').property('id',2).as('2'). addV('user').property('id',3).as('3'). addV('user').property('id',4).as('4'). addV('post').property('postId','post1').as('p1').

gremlin python - add multiple but an unknown number of properties to a vertex

时间秒杀一切 提交于 2019-12-13 16:43:32
问题 I want to add more than one property to a vertex, but from the outset do not explicitly know what those properties might be. For example, say for one person to be added as vertex to the graph, we have the following property dictionary: Person 1 { "id": 1, "first_name": "bob", "age": 25, "height": 177 } Maybe for another vertex to be added, a person has the following properties: Person 2 { "id": 2, "first_name": "joe", "surname": "bloggs", "occupation": "lawyer", "birthday": "12 September" }

What is the best practice to update a Vertex after is detached from DB with Tinkerpop Frames?

走远了吗. 提交于 2019-12-13 04:43:37
问题 Let's exemplify I receive a Vertex with Tinkerpop Blueprint, then I use Frames to convert it in an entity. I close the database (so from now the node is detached from the DB) and I show the node on a web page to let the user modify it. The user makes some modifications, then I shoud persist the changes. The problem is that the Instance of the database is already closed, so the entity is detached from the database: What is the best practice (considering performance and memory usage too) to

Gremlin - select a vertex, create new vertices and edges in single query

陌路散爱 提交于 2019-12-13 02:48:23
问题 I have a user vertex already created. g.V().has('user','username','vipul').as('user') I want to create a new 'group' vertex with some properties and also a new 'options' vertex with some other properties. g.addV(label,'group','group_name','DC11').as('group') g.addV(label,'options','command_line_arguments','-D -n').as('options') Now I want to create an edge from user to group and another edge from group to options. user ---> group, group ---> options Can these queries be combined, selecting a

How to efficiently create a vertex with a label and several properties?

不打扰是莪最后的温柔 提交于 2019-12-13 02:05:26
问题 I want to create a vertex with a given label and some properties. Since the g.addVertexWithLabel() method only takes the label as an argument and I cannot find any v.addLabel() method, it seems that I have to add the properties one by one after creating the vertex. Or am I missing something here? 回答1: No. As of Titan 0.5.4, there is no API that allows you to add it all at once. In fact, even the Gremlin Groovy sugar of: g.addVertex([name:"stephen"]) just calls Element.setProperty(k,v) for

Tinkerpop: Set Label After Creating Vertex

六月ゝ 毕业季﹏ 提交于 2019-12-13 00:53:45
问题 Is there a way to set the T.label after the vertex has been created. I have tried the following: Vertex v = graph.addVertex(); v.property(T.label.name(), "test"); But when I try the following traversal: graph.traversal().V().hasLabel("test").next I get org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException Is there something special about T.label that limits it to being set at the step of constructing the vertex ? 回答1: No, labels cannot be changed. If you need this

Gremlin group by vertex property and get sum other properties in the same vertex

你。 提交于 2019-12-12 18:27:46
问题 We have vertex which will store various jobs and their types and counts as properties. I have to group by the status and their counts. I tried the following query which works for one property(receiveCount) g.V().hasLabel("Jobs").has("Type",within("A","B","C")).group().by("Type").by(fold().match(__.as("p").unfold().values("receiveCount").sum().as("totalRec")).select("totalRec")).next() I wanted to give 10 more properties like successCount, FailedCount etc.. Is there a better way to give that?

Orientdb Cant open Database from Java

天涯浪子 提交于 2019-12-12 09:44:15
问题 I created a database out of the orientdb console: create database plocal:/C:/Development/orientdb/databases/testdb root root plocal graph I started the server to make sure my database was created successfully. I opened the webinterface: localhost:2480 And i logged in into testdb using root as user and root as password. Everything worked fine. But when i now want to connect to my database from Java-Code: OrientGraph graph = null; try { graph = new OrientGraph("plocal:C:/Development/orientdb