cypher

Cycles in Gremlin/Cypher

99封情书 提交于 2019-12-24 04:07:09
问题 I'm making a presentation about how some elements looks in Neo4j's Cypher and Titan's Gremlin i.e. add new vertex, look for relation etc. I have a problem with looking for cyclec. Is there any function in these 2 languages which can return a cycles i.e. for given vertex? 回答1: Here's how you do it in Gremlin: gremlin> g = TinkerGraphFactory.createTinkerGraph() ==>tinkergraph[vertices:6 edges:6] gremlin> g.v(2).addEdge("knows", g.v(6)) ==>e[0][2-knows->6] gremlin> g.v(6).addEdge("knows", g.v(1)

Neo4j Cypher: Handling whitespace and wildcards in a Lucene fulltext search

喜夏-厌秋 提交于 2019-12-24 02:42:46
问题 I created a FullText index named: myFullTextIndex . When I want to search for the pattern: Hello World , the query looks like: START w=node:myFullTextIndex('title:"Hello World"') That works pretty well. However, I don't manage to search for the same string surrounded by wildcards. I expect a search on this pattern to return a result: *Hello World* I tried: START w=node:myFullTextIndex('title:"*Hello World*"') and START w=node:myFullTextIndex('title:*"Hello World"*') but doesn't work (syntax

“Invalid use of aggregating function in this context” in a SET query (Neo4j)

时光毁灭记忆、已成空白 提交于 2019-12-24 01:19:25
问题 I wonder why this is considered an invalid use of aggregate functions in Neo4j's Cypher: MATCH (p:Project)-[:EMPLOYS]-(n:Person) SET p.youngest = MIN(n.age); While the following is considered a valid use case: MATCH (p:Project)-[:EMPLOYS]-(n:Person) RETURN p.name, MIN(n.age) AS youngest; How should I rewrite the first query to make it valid? 回答1: As for "why" your original Cypher attempt does not work, and the answer by @mah does work: Cypher only permits aggregation functions to be used in

How to associate multiple value to a property using cypher queries in Neo4j

天涯浪子 提交于 2019-12-24 01:17:22
问题 I have 2 nodes created in graph database, origin airport and destination airport. It is related by a property named 'delayed_by'. I need to associate multiple values to this property 'delayed_by'. There are various reasons for delays such as weather delay, carrier delay, nas delay and I need to link all of them to this property in graph database. I am expecting values as that of below tabular format in graph database ORIGIN DEST carr_delay weather_delay nas_delay ABE ATL 492 56 56 I used the

Neo4j 3.1.0 apoc.load.csv trouble

假装没事ソ 提交于 2019-12-24 01:09:45
问题 I keep trying to run a apoc.load.csv procedure in the newest version of Neo4j 3.1.0, and APOC 3.1.0.3. CALL apoc.periodic.iterate('CALL apoc.load.csv("file:///data.csv", {sep:",", header:TRUE}) yield map ',' with {map} as map MATCH (t:Tweet{id:toFloat(map.tweet_id)}) SET t.clean_text = map.clean_text, t.positive_score = toInt(map.nb_positive), t.negative_score = toInt(map.nb_negative), t.sentiment_score = toInt(map.score)', {batchSize:5000, parallel:true}) Error: Failed to invoke procedure

To get all the nodes connected to a super node in Neo4j

女生的网名这么多〃 提交于 2019-12-24 00:58:12
问题 I have started learning cypher query for using graphical database. How should i get the values of all the nodes related to a super node. I am trying out the following query in console but its not working: start a=node(2) match (a)-[:TYPE*]<-(node) return node; node(2) is the super node. and the relation by which all other nodes are connected to a super node is TYPE. How should i correct my query.? Error : SyntaxException: expected - 回答1: You're representing the relationship wrong, try start a

How to return max counts per another node's properties

青春壹個敷衍的年華 提交于 2019-12-23 20:38:45
问题 I need to calculate how many times a composer's pieces of music were performed per decade, then return only the one piece with the most performances per decade. This cypher does everything except filter all but the highest counts per decade. match (c:Composer)-[:CREATED_BY]-(w:Work)<-[*..2]-(prog:Program) WHERE c.lastname =~ '(?i).*stravinsky.*' WITH w.title AS Title, prog.title AS Program, LEFT(prog.date, 3)+"0" AS Decade RETURN Decade, Title, COUNT(Program) AS Total ORDER BY Decade, Total

Can I recursively evaluate a tree in neo4j cypher language?

妖精的绣舞 提交于 2019-12-23 19:53:24
问题 In my application, I have what is essentially the syntax tree of a mathematical expression as neo4j graph... a picture is probably helpful: I'm wondering if it's possible to write a Cypher query that fully evaluates a tree like this for the top node, i.e.: gets the average of the connected inputs for Node 1.2, the max for 1.1.2 the average of 1.1.2 and 3 for Node 1.1 and finally returns the max of 1.2 and 1.1 as value for Node 1 The value is stored in the property status for the input nodes,

neo4j cypher set statement with parameter map

荒凉一梦 提交于 2019-12-23 17:52:01
问题 I'm struggling to find a definition of how to use the set cypher command with a parameter map Cheat sheet says use: SET n = {map} I have tried: START n = node(11379) SET n = {Name: "Random Test Change"} on my server I get error:- `.' expected but `=' found What am I doing wrong? 回答1: The map parameter could be used like this: String query = "START n = node(11379) SET n = {map}"; Map<String, String> myMap = new HashMap<String, String>(); myMap.put("Name", "Random Test Change"); Map<String,

Neo4j cypher - Import CSV and add relationships between nodes based on the csv values

霸气de小男生 提交于 2019-12-23 15:15:32
问题 Is it possible in cypher to create different relationship between nodes based on the value of csv using the import functionality . Eg : For a given csv data product_id user_id action 1 1 VIEW 1 2 PURCHASE I need to create product node(product_id) , user node(user_id) and either VIEW or PURCHASE relationship between ' user ' and product node based on the value of ' action ' field in csv . Below are the approaches I tried . I know the syntax is incorrect but just to give an idea what I am