neo4j

Limiting Cypher queries

本秂侑毒 提交于 2019-12-24 19:11:57
问题 I am currently using a neo4j database with 50000 nodes and 2 million relationships to perform cypher MATCH queries, like the one below: start startnode = node(42660), endnode = node(30561) match startnode-[r*1..3]->endnode return r; This query by itself provides 443 rows, but I only want Cypher to find 5 matches and return those only. Allow me to clarify: I do not just want Cypher to return only 5 results, I also want cypher to STOP querying once it finds 5 results. I DO NOT want Cypher to

Performing match by index lookup with cypher

狂风中的少年 提交于 2019-12-24 19:09:57
问题 I have a dense node problem and to get around this I've been using indexing to perform some matching using the native Java API, but I've been giving Cypher a second look and wanted to know if this could be done. Currently my pattern looks like this in Java Code: Node startNode = db.getNodeById(1); Index<Relationship> relationshipIndex = db.index.forRelationships("relationships"); for(Relationship relationship1 : startNode.getRelationships(Direction.OUT)) { Node otherNode = relationship

Django testing of neo4j database

拜拜、爱过 提交于 2019-12-24 18:50:08
问题 I'm using django with neo4j as database and noemodel as OGM. How do I test it? When I run python3 manage.py test all the changes, my tests make are left. And also how do I make two databases, one for testing, another for working in production and specify which one to use how? 回答1: I assume the reason all of your changes are being retained is due to using the same neo4j database for testing as you are using in development. Since neomodel isn't integrated tightly with Django it doesn't act the

How to avoid cycle in neo4j cypher queries

孤街浪徒 提交于 2019-12-24 18:25:10
问题 I have friend-friend data model which has two relationships between any two friend nodes based on how one friend defines the other friend. For example, User "A" can define user "B" as 'FRIEND' and "B" can define "A" as 'BUDDY'. The problems is, when I try to get the 3rd degree of relationship of user "A", it returns user "B", where as the actual result should be "D" only. MATCH(a:Users {first_name : "A"}) -[:BUDDY|FRIEND*3] -> (b) RETURN a,b OR MATCH (a)-[]-(b)-[]-(c)-[]-(d) WHERE a.first

cypher how get relation between every two node and the distance from start node?

喜欢而已 提交于 2019-12-24 18:17:05
问题 I have some nodes and relation like A -> B ->C -> D ; and B->D So the B C D is a loop, now I want get all relations and each relation distance from node A; I expect result like: {startNode: A, endNode: B, rel:FRIEND, distanceFromAtoEndnode: 1}, {startNode: B, endNode: C, rel:FRIEND, distanceFromAtoEndnode: 2}, {startNode: C, endNode: D, rel:FRIEND, distanceFromAtoEndnode: 3}, {startNode: B, endNode: D, rel:FRIEND, distanceFromAtoEndnode: 2} and my cypher: match p=(n:Person {name:"A"})-[r*1..9

playing neo4j in embedded database way

随声附和 提交于 2019-12-24 17:57:45
问题 I am pretty new to neo4j, i want to create a application. By remote server mode, it seems only REST API can be used to connect to the neo4j. So I decide to use embedded database as I want to use JAVA API provided by neo4j. There is an example in the tutorial to create the connection: private static final String DB_PATH = "C:/Users/Hao/Documents/Neo4j/TGI_test_backup"; public static void main( String[] args ) throws IOException { FileUtils.deleteRecursively( new File( DB_PATH ) );

playing neo4j in embedded database way

给你一囗甜甜゛ 提交于 2019-12-24 17:57:44
问题 I am pretty new to neo4j, i want to create a application. By remote server mode, it seems only REST API can be used to connect to the neo4j. So I decide to use embedded database as I want to use JAVA API provided by neo4j. There is an example in the tutorial to create the connection: private static final String DB_PATH = "C:/Users/Hao/Documents/Neo4j/TGI_test_backup"; public static void main( String[] args ) throws IOException { FileUtils.deleteRecursively( new File( DB_PATH ) );

Neo4j.rb : transfer all relationships before replacing a node by another

杀马特。学长 韩版系。学妹 提交于 2019-12-24 17:21:12
问题 I'm trying to transfert all ingoing and outgoing relationships (including their properties) from a node to another, before deleting the first one. they both have the same label. The discussion started here : Neo4j Cypher : transfer all relationships before replacing a node by another node_query = Neo4j::Session.query.match(old_node: {uuid: node1.uuid}).match(new_node: {uuid: node2.uuid}) types = node_query.match('node-[rel]-()').pluck('DISTINCT type(rel)') types.each do |type| node_query

Best solution for multiple queries in a limited time

匆匆过客 提交于 2019-12-24 17:19:10
问题 For a MORPG Hack'n'Slash game i am currently using Neo4j with a pattern like this : I have a Neo4J connector class, creating my connection and implementing Singleton and this instance is used by every xxxMapper classes, calling Neo4jConnetor.getInstance().query(String query) which returns the iterator of the queryresult. Atm I'm asking myself a question, the game will have a ton of queries per second (like 5 per player per second). So I don't know, in terms of perfs, which pattern to use, if

NEO4J: Couldn't load the external resource at: file:/var/lib/neo4j/import/

我只是一个虾纸丫 提交于 2019-12-24 17:19:08
问题 I am running Neo4J on Docker within Vagrant. I am attempting to LOAD CSV WITH HEADERS from a file within the /import/ directory (I had to move my file there) via a cURL request. My request looks something like this: "LOAD CSV WITH HEADERS FROM \"file:///insert-neo4j.csv\" AS row ... This provides me with the following error: {"results":[],"errors [{"code":"Neo.ClientError.Statement.ExternalResourceFailed","message":"Couldn't load the external resource at: file:/var/lib/neo4j/import/insert