neo4j

Neo4j - Match by multiple relationship types

安稳与你 提交于 2020-01-01 07:29:06
问题 I want to match between entities by multiple relationship types. Is it possible to say the following query: match (Yoav:Person{name:"Yoav"})-[:liked & watched & ... ]->(movie:Movie) return movie I need "and" between all the relation types; Yova liked and watched and .. a movie. 回答1: Yes, you can do something like: match (gal:Person{name:"Yoav"})-[:liked|:watched|:other]->(movie:Movie) return movie Take a look in the docs: Match on multiple relationship types EDIT: From the comments: I need

Cypher: how to find all the chains of single nodes not repeated?

本秂侑毒 提交于 2020-01-01 07:09:22
问题 I want to find ALL the paths starting and ending from/to a specific node. I would like that each node in a path appears only once. For example, in a graph like this: (a)-[:REL]->(b)-[:REL]->(c)-[:REL]->(a) (a)-[:REL]->(e)-[:REL]->(f)-[:REL]->(a) (e)-[:REL]->(b) grafically: e → b ↙ ↖ ↗ ↘ f → a ← c Cypher code: CREATE (a { name:'A' })-[:REL]->(b {name:'B'})-[:REL]->(c { name:'C' }) -[:REL]->(a)-[:REL]->(e {name:'E'})-[:REL]->(f {name:'F'})-[:REL]->(a), (e)-[:REL]->(b) I would like that the

How to delete all nodes that do not have any relationships - neo4j/cypher

痞子三分冷 提交于 2020-01-01 06:56:45
问题 I am generating nodes in a neo4j database and want to remove those that have no relationships. What is the best cypher instruction to do this? 回答1: Try MATCH (n) WHERE size((n)--())=0 DELETE (n) 来源: https://stackoverflow.com/questions/33559454/how-to-delete-all-nodes-that-do-not-have-any-relationships-neo4j-cypher

Python networkx and persistence (perhaps in neo4j)

半世苍凉 提交于 2020-01-01 06:34:28
问题 I have an application that creates many thousands of graphs in memory per second. I wish to find a way to persist these for subsequent querying. They aren't particularly large (perhaps max ~1k nodes). I need to be able to store the entire graph object including node attributes and edge attributes. I then need to be able to search for graphs within specific time windows based on a time attribute in a node. Is there a simple way to coerce this data into neo4j ? I've yet to find any examples of

How to migrate/shift/copy/move data in Neo4j

旧街凉风 提交于 2020-01-01 05:12:06
问题 Does any one know how to migrate data from one instance of Neo4j to another. To be more precise, I want to know, how to move the data from one instance of Neo4j on my local machine to another on remote machine. Does any one have any idea about it. I'm working on my windows machine with Eclipse and Embedded Neo4j . I need to transfer this data to remote Neo4j instance on a Centos machine. Please help me with this. 回答1: I found out the following workaround for copying the data from a server in

How to migrate/shift/copy/move data in Neo4j

女生的网名这么多〃 提交于 2020-01-01 05:12:04
问题 Does any one know how to migrate data from one instance of Neo4j to another. To be more precise, I want to know, how to move the data from one instance of Neo4j on my local machine to another on remote machine. Does any one have any idea about it. I'm working on my windows machine with Eclipse and Embedded Neo4j . I need to transfer this data to remote Neo4j instance on a Centos machine. Please help me with this. 回答1: I found out the following workaround for copying the data from a server in

How to calculate mutual friends with neo4j?

橙三吉。 提交于 2020-01-01 03:44:14
问题 I want to use neo4j to manage relationship among users. How can I get mutual friends using it? 回答1: The easiest way would be to use the shortest path algorithm of length 2, with the two users, across FRIEND_OF relationships. Those are the paths that connect the two users via exactly one friend hop. PathFinder<Path> finder = GraphAlgoFactory.shortestPath( Traversal.expanderForTypes( FRIEND_OF ), 2 ); Iterable<Path> paths = finder.findAllPaths( user1, user2 ); 回答2: In case of using cypher the

Cypher Order by Path Cost

自作多情 提交于 2020-01-01 03:42:09
问题 I am extremely new to cypher and neo4j. I am wanting to get and order all paths between point A and B, based upon the total path cost. The cost in this case is a relationship property that is an integer. The path cost would be a summation of the relationship properties. I am looking at some examples of cypher's ORDER BY statement however, by the examples, it seems that you have to order by a property that is already assigned to the object being ordered, in this case that won't work because

Difference between merge and create unique in Neo4j

对着背影说爱祢 提交于 2019-12-31 11:43:07
问题 I'm trying to figure out what is the difference between MERGE and CREATE UNIQUE. I know these features: MERGE I'm able to create node, if doesn't exist pattern. MERGE (n { name:"X" }) RETURN n; This create node "n" with property name, empty node "m" and relationship RELATED. MERGE (n { name:"X" })-[:RELATED]->(m) RETURN n, m; CREATE UNIQUE I'm not able to create node like this. CREATE UNIQUE (n { name:"X" }) RETURN n; If exists node "n", create unique makes empty node "m" and relationship

Tuning Neo4j for Performance

主宰稳场 提交于 2019-12-31 08:38:28
问题 I have imported data using Michael Hunger's Batch Import, through which I created:- 4,612,893 nodes 14,495,063 properties node properties are indexed. 5,300,237 relationships { Question } Cypher queries are executing too slow almost crawling, simple traversal is taking > 5 mins to return resultset, Please let me know how to tune the server to get better performance and what I am doing wrong. Store Details:- -rw-r--r-- 1 root root 567M Jul 12 12:42 data/graph.db/neostore.propertystore.db -rw-r