graph-databases

Neo4j Cypher query for many to many relationship

℡╲_俬逩灬. 提交于 2019-12-24 07:03:08
问题 I have a graph that looks like the following: Brand--SOLD_BY-->Store One brand of a certain item can be sold by multiple stores. Similarly, a single store can sell multiple brands of items. What I want to achieve is find all the stores that sell a particular brand but in the result along with the store, I would also like the other brands that are sold by that particular store. For example: Brand1 is sold by StoreA, StoreB, StoreC. The result should look something like.. StoreA - Brand1,

Neo4j: find degree of connection

寵の児 提交于 2019-12-24 06:49:51
问题 I'm using Neo4j to find the degree of connection between users. I have data in the follower shape: (user)-[:INTERACTS_WITH]->(user) So if user_1 interact with user_2 and user_2 interacts with user_3, then user_1 and user_3 share a second-degree connection. Ideally, I would like to get the following dataset like this in return: degree count NULL 123 1 1050 2 3032 3 2110 ... ... Is there a better way to do this than to simply run shortestPath() function for every pair of users? If not, then

How to chain commands in Gremlin?

此生再无相见时 提交于 2019-12-24 02:25:24
问题 The following command works t = new Table(); g.V.as('id').as('properties').table(t){it.id}{it.map} print t The following command works t = new Table(); g.V.as('id').as('properties').table(t){it.id}{it.map}; print t The following command doesn't work t = new Table(); g.V.as('id').as('properties').table(t){it.id}{it.map}; print t Why? 回答1: The fast answer: You need to iterate your pipeline. The long answer: In the Gremlin REPL, iteration will happen for you automagically if your last statement

How to model relationships between sets of nodes

孤街浪徒 提交于 2019-12-24 01:47:06
问题 I am currently looking at modelling tertiary courses and other such entities (MATH101, BIOL360, BSc etc.), and one of the options we're looking at is graph databases. I am not familiar with graph databases, other than in theory. One of the things I am trying to model is requirements, for example "MATH201 requires the student previously completed MATH101". That one seems easy - I can create a vertex between the two. Others are more complicated: "Bachelor of Computer Science requires 40 points

ClassCastException while fetching edge property value bewteen two vertices

不问归期 提交于 2019-12-24 01:41:39
问题 I am trying to fetch edge property value between two vertices and getting below exception java.lang.ClassCastException: java.lang.String cannot be cast to scala.runtime.Nothing$ Env: Titan InMemory Code : val age = Key[Int]("age") A ---("knows",age -> 10) --> B Gremlin query: graph.traversal().V().has("ID", "A").bothE("knows").as("x").otherV() .has("ID", "B").select("x").properties("age").headOption().get output : p[age->10] graph.traversal().V().has("ID", "A").bothE("knows").as("x").otherV()

What is the difference between “started streaming” and “completed” in Neo4j queries?

不想你离开。 提交于 2019-12-24 00:42:30
问题 In the Neo4j browser, when I profile a query, I get: "Started streaming 162063 records after 129 ms and completed after 13793 ms." Were the results all gathered after 129ms, but it took 13793ms to output them to the browser? Also, when I run queries in the Cypher Shell, I get "162063 rows available after 9 ms, consumed after another 8673 ms". Does this mean all of the data was gathered after 9ms, but it took 8673ms to output it to the shell? 回答1: When records (or rows) are streamed , the

Traverse directed edges recursively with OrientDB

谁说我不能喝 提交于 2019-12-23 18:13:17
问题 I am trying to recursively traverse outbound edges from a given node, but not the inbound ones. I want both out edges and out vertices in the result of my query. In the following graph, starting from (a), I need (a), (b), (c), (d), (e), including the edges, but not the part after (c), which is <-- (x) (a) --> (b) --> (c) <-- (x) ˙--> (d) --> (e) If I try doing the following, then it traverses everything recursively, irrespective of edge direction, thus also returning (x): TRAVERSE * FROM

How can you log from a Neo4j Server Plugin?

早过忘川 提交于 2019-12-23 15:11:05
问题 I'm trying to debug a problem in the Neo4J Server plugin I'm writing. Is there a log I can output to? It's not obvious where or how to do this. 回答1: Good question. I think you could use Java Logging? That should be routed into the normal logging system. 来源: https://stackoverflow.com/questions/11704687/how-can-you-log-from-a-neo4j-server-plugin

How to update several vertex properties on Gremlin?

无人久伴 提交于 2019-12-23 12:32:04
问题 I want to add several properties on a vertex. I could do: g.v(1).firstname='Marko' g.v(1).lastname='Rodriguez' But how to add these properties with the following hash {firstname:'Marko', lastname:'Rodriguez'} in a single query? 回答1: You can construct a SideEffect pipe that would work. In the simple case, do this: g.v(1)._().sideEffect{it.firstname='Marko'; it.lastname='Rodriguez'} Alternatively, if you need to work on just one node and have the map you can use the each method of a map: m =

Gremlin: “The provided traverser does not map to a value” when using project

我的梦境 提交于 2019-12-23 09:31:43
问题 In the Modern graph, I want to get for each person the name and the list of names of software he created. So I tried the following query g.V().hasLabel('person').project('personName','softwareNames'). by(values('name')). by(out('created').values('name').aggregate('a').select('a')) but I get the error The provided traverser does not map to a value: v[2]->[VertexStep(OUT,[created],vertex), PropertiesStep([name],value), AggregateStep(a), SelectOneStep(last,a)] The problem seems to be that vertex