cypher

Neo4J: shortest paths with specific relation types sequence constrain

╄→尐↘猪︶ㄣ 提交于 2019-12-12 03:48:59
问题 I need to find shortest paths between nodes, but with some restrictions on relations types in good paths. I have two relation types: A & B. Path is considered bad if it has two or more consecutive relation of type B: Good path: ()-A->()-A->()<-A-()-B->()-A->()-B->() Bad path: ()-A->()-A->()<-A-() -B->()<-B- ()-A->() The Cypher query: MATCH path=allShortestPaths( (p:P{idp:123})-[rel:A|B*]-(p2:P{idp:124}) ) WHERE *some-predicate-on-path-or-rel* RETURN path is not a solution because the shortest

How to enumerate nodes and relationships along path returned via Cypher

戏子无情 提交于 2019-12-12 03:46:42
问题 I opened this question here: How to find specific subgraph in Neo4j using where clause to find a path of a certain criteria. Yet when I try to do things like get the relationship type I cannot. For example I tried MATCH p = (n:Root)-[rs1*]->() WHERE ALL(rel in rs1 WHERE rel.relevance is null) RETURN nodes(p), TYPE(relationships(p)) But I get the error: Type mismatch: expected Relationship but was Collection<Relationship> I think I need to use a WITH clause but not sure. Similarly I wanted the

Neo4j CSV import being too slow

半腔热情 提交于 2019-12-12 03:39:14
问题 I know this question has been asked several times but none of the answers solved my problem. I am using the following query to import the data: USING PERIODIC COMMIT LOAD CSV WITH HEADERS FROM 'file:///C:/Users/Zo5/Documents/Neo4j/check/import/result1.csv' AS line1 MERGE (p:Person {forename:line1.forename, surname:line1.surname, nationality:line1.nationality, occupation:line1.occupation, title:line1.title}) but the process is too slow. The CSV file is about 700MB. It takes about 15 minutes

SDN 4 Session.query doesn't work for @QueryResult

谁都会走 提交于 2019-12-12 03:37:18
问题 In my SDN 4 project I have a @QueryResult POJO: @QueryResult public class WeightedDecision { private Decision decision; private double weight; public Decision getDecision() { return decision; } public void setDecision(Decision decision) { this.decision = decision; } public double getWeight() { return weight; } public void setWeight(double weight) { this.weight = weight; } } And a lot of Spring Data Neo4j repository methods that work fine with this WeightedDecision query result. Right now I'm

level-2 or level-3 connections when we have bidirectional relationship

别说谁变了你拦得住时间么 提交于 2019-12-12 03:26:42
问题 Extention to this question Neo4j - Get Level2 or Level3 connections I have the following relationship in Neo4j. Few nodes have bidirectional relationsips I want to fetch the level-2 or level-3 connections for the given user. I have the following CQL START levelGraph=node(1) MATCH path=(user1:User)-[knows:KNOWS*2..2]->(user2:User) WHERE user1.mobile = 9000090001 RETURN user1, user2, length(path) as downlevel ORDER BY length(path) asc this one is giving me all the nodes who has relationship

Neo4j and Lucene multikey queries (or: should I use Cypher?)

☆樱花仙子☆ 提交于 2019-12-12 03:16:38
问题 I have a graph in Neo4j in which nodes represent random points in the plane, each node having the coordinates stored as properties (x and y, the value type is double ). I create the nodes and index them: IndexManager index = graph.index(); Index<Node> nodesIndex = index.forNodes("points"); for (int i = 0; i < points.length; i++) { Point p = points[i]; Node n; Transaction tx = graph.beginTx(); try { n = graph.createNode(); n.setProperty("x", p.getX()); n.setProperty("y", p.getY()); nodesIndex

Cypher Search Query Fuzzy query

左心房为你撑大大i 提交于 2019-12-12 03:08:13
问题 I want to use cypher to search, I have four movie enerties, forrest, sky, sky1, sky2 I want search sky I want it returns sky, sky1, sky2 My cypher is @Query("MATCH (movie:Movie) WHERE movie.title =~ '.*{0}.*' RETURN movie") or @Query("MATCH (movie:Movie) WHERE movie.title =~ '(?i).*{0}.*' RETURN movie") Neither of those works well: it return forrest, sky,sky1, sky2 no matter what I search (forrest or sky). What is wrong? controller @RequestMapping(value = "/movies", method = RequestMethod.GET

neo4j: shortest paths constrained by node and rel properties

﹥>﹥吖頭↗ 提交于 2019-12-12 03:02:12
问题 From the tutorial: MATCH p=shortestPath( (keanu:Person)-[:KNOWS*]-(kevin:Person) ) WHERE keanu.name="Keanu Reeves" and kevin.name = "Kevin Bacon" RETURN length(p) Imagine each Person node has an age property and an occupation. Every KNOWS edge has a length of acquaintance property. What Cypher query would return a shortest path with, for instance, age > 40 years not (occupation = ACTOR) lengthOfAcquaintance > 10 years In molecular biology interaction data, we wish to make yet more complex

How to fixedly assure neo4j will return a Long value for attribute

别说谁变了你拦得住时间么 提交于 2019-12-12 02:49:31
问题 i did some experiments with neo4j 2.3 version and direct calls on transactional endpoint http://localhost:7474/db/data/transaction/commit and create the node with long attribute curl -X POST -H "Content-Type: application/json" -d '{ "statements" : [ { "statement" : "MERGE (c:`foo` {id:{_queryId}}) ON CREATE SET c.`created`={created} RETURN c", "parameters" : { "created" : 1111111111111111111 }}] }' "http://localhost:7474/db/data/transaction/commit" While reading this data on client side (Java

Cypher -Tally report on the depth of each relationship type stemming from parent node

岁酱吖の 提交于 2019-12-12 02:48:05
问题 I am trying to create tally report on the depth of each relationship type stemming from parent node but I running into issues with the following error: "Type mismatch: r already defined with conflicting type Relationship (expected Collection<Relationship>) Here is the output I am attempting to achieve: [ { reltype : "123A_RelationshipTitleOne", depthcount : 5 }, { reltype : "123A_RelationshipTitleTwo", depthcount : 9 }, { reltype : "123A_RelationshipTitleThree", depthcount : 42 } ] Here is my