cypher

All paths between two nodes neo4j - incorrect answer (from neo4j)

半世苍凉 提交于 2019-12-25 03:07:53
问题 I want to get all path between two nodes with the relation "->" between them. I ask my DB using query (Cypher) like that: START a=node(27), b=node(0) MATCH p=b<-[*]-a RETURN p In Neo4j visualization I get this: Cypher query visualization I want to get list of 3 path: 27 -> 81 -> .... -> 0 27 -> 67 -> .... -> 0 27 -> 24 -> .... -> 0 but in the result I have got 6 paths (instead of 3). I want to figure out why. 回答1: This happens because the query includes the 0 length paths starting from 'a'.

Differentiating Neo4j queries for different data files

偶尔善良 提交于 2019-12-25 02:59:00
问题 I'm using Neo4j 2.1.2. My query is that I have a 3 csv files with the same structure but with different data, say csv1, csv2, csv3. I loaded the csv1 with node and relationship information on Neo4j. Again I loaded csv2 with the same nodename and relationship name as the 1st csv and I did the same thing for csv2 as well. So when I fire the query without LOAD CSV command, then from which file will it file fetch the data? Do we need to add LOAD CSV command each time whenever we want to execute

get difference between field values and sum in neo4j

守給你的承諾、 提交于 2019-12-25 02:48:21
问题 How can I get difference between 2 fields: r.rating_val and rw.rating_val and sum of these fields using neo4j query?I really appreciate any help. MATCH (a:user{id:"1"})-[r:`rating`]->(b), (w:user{id:"3"})-[rw:`rating`]->(b) RETURN DISTINCT b,r.rating_val ,rw.rating_val 回答1: Just subtract/add them in the return clause MATCH (a:user{id:"1"})-[r:`rating`]->(b), (w:user{id:"3"})-[rw:`rating`]->(b) RETURN DISTINCT b, r.rating_val-rw.rating_val as difference, r.rating_val+rw.rating_val as sum 回答2:

Neo4j Cypher - Terminating conditions when using variable level paths

允我心安 提交于 2019-12-25 02:01:48
问题 I have a linked list that is modelled in a circular fashion like so: (u:User) -[:LINK]->(a:NODELINK {linkId: 'aa'}) -[:LINK]->(b:NODELINK {linkId: 'bb'}) -[:LINK]->(c:NODELINK {linkId: 'cc'}) -[:LINK]->(d:NODELINK {linkId: 'dd'}) -[:LINK]->(u) When I query it starting at node (b:NODELINK {linkId: 'bb'}) I would like to match all nodes until I get to the end/start of the list. (The User node) When I run the following query: MATCH (u:USER) WITH u MATCH (nl:NODELINK)-[:LINK*]->(m) WHERE nl

How to query the graph when the intended property name is unknown?

余生颓废 提交于 2019-12-25 01:55:07
问题 A related question is here: How to query property value when property name is a parameter? Let's say if I want to ask "Recommend me 500-dollar phones". And in my graph, I have: create (p:Product {name:"iPhone 1", price:"500", color:"white"}) create (p:Product {name:"iPhone 2", price:"400", color:"white"}) create (p:Product {name:"iPhone 3", price:"800", color:"black"}) Based on the language "Recommend me 500-dollar phones", I know I should query on the Product node, but I don't know the

Neo4j cypher query fails with unknown syntax error

こ雲淡風輕ζ 提交于 2019-12-25 01:43:51
问题 I have the following paramObj and dbQuery paramObj = { email: newUser.email, mobilenumber: newUser.telephone, password: newUser.password, category: newUser.category, name: newUser.name, confirmuid: verificationHash, confirmexpire: expiryDate.valueOf(), rewardPoints: 0, emailconfirmed: 'false', paramVehicles: makeVehicleArray, paramVehicleProps: vehiclePropsArray } dbQuery = `CREATE (user:Person:Owner {email:$email}) SET user += apoc.map.clean(paramObj, ['email','paramVehicles',

Neo4j SDN4 entity inheritance and indexes

纵饮孤独 提交于 2019-12-25 01:35:30
问题 I have a following Cypher query: PROFILE MATCH (childD:Decision) WITH childD ORDER BY childD.createDate DESC SKIP 0 LIMIT 10 MATCH (childD:Decision)-[ru:CREATED_BY]->(u:User) OPTIONAL MATCH (childD:Decision)-[rup:UPDATED_BY]->(up:User) RETURN ru, u, rup, up, childD AS decision, [ (childD)-[rdt:BELONGS_TO]->(t:Tag) | t ] AS tags Right now on my Neo4j database (~23k Decision nodes) this query works ~50 ms and I don't understand or it uses index on childD.createDate field. This is PROFILE output

Issue of casting Node neo4j

荒凉一梦 提交于 2019-12-25 01:08:46
问题 My code is below, As per the documentation it should have given me the node values but it is throwing me exception Exception in thread "main" java.lang.ClassCastException: scala.collection.convert.Wrappers$SeqWrapper cannot be cast to org.neo4j.graphdb.Node at com.neo4j.performance.FetchData.main(FetchData.java:32) I'm using Neo4j 2.2.2. import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Result; import org.neo4j.graphdb.Transaction; import java.util.Iterator; import org.neo4j.helpers

Neo4j display subgraph based on multiple paths

天大地大妈咪最大 提交于 2019-12-25 00:46:06
问题 I want to display a subgraph in Neo4j(COMMUNITY EDITION on localhost) based on multiple paths. The paths are the result of a custom traversalDescription() with a special evaluate(Path path) . The intention was to ignore a special sequence of relationships and nodes(details to sequence). As far as i know its not possible in a cypher query. The result looks like this: (268911) (268911)<--[REL1,151]--(276650) (268911)<--[REL1,151]--(276650)<--[REL2,715]--(276651) (268911)<--[REL1,151]--(276650)<

How to set read timeout per query using Java REST binding?

放肆的年华 提交于 2019-12-25 00:39:23
问题 I am using Neo4j 1.9.1 and Kernel 1.8, I want to specify read time out for few queries ... Thanks in advance. 回答1: I'm not sure if that is directly possible. You need to enable guards by config in your server and set a http header max-execution-time as described in Mark's blog post at http://www.markhneedham.com/blog/2013/10/17/neo4j-setting-query-timeout/. Java Rest bindings need to be tweaked, see https://github.com/neo4j-contrib/java-rest-binding/blob/master/src/main/java/org/neo4j/rest