cypher

Neo4j: Split string and get position

六月ゝ 毕业季﹏ 提交于 2020-01-03 05:23:22
问题 I need to split a field in different values and store each value in a different node. For each created node I want to store the position. Example: Sentence Words My car is red My;car;is;red Using: FOREACH (w IN SPLIT(line.TWords, ";") | MERGE (wd:Word {word: w}) I can split the field and store the different words, but I'd like to store the position on the relationship. My car is red -[HAS_WORD {position:1}]-> My My car is red -[HAS_WORD {position:2}]-> car My car is red -[HAS_WORD {position:3

Cypher: Hierarchical Sorting

五迷三道 提交于 2020-01-03 03:03:56
问题 I am new to Cypher. I was able to create a network of geographies (from the World to continents to countries to regions) and their population. You can reproduce it with this command or check the link to the console: http://console.neo4j.org/r/dkh90c CREATE (n1:Geo {name:'World'}), (n2:Geo {name:'EMEA'})-[:BELONG_TO]->(n1), (n4:Geo {name:'NORAM'})-[:BELONG_TO]->(n1), (n5:Geo {name:'Middle East'})-[:BELONG_TO]->(n2), (n6:Geo {name:'Africa'})-[:BELONG_TO]->(n2), (n7:Geo {name:'Europe'})-[:BELONG

Cypher: Hierarchical Sorting

我只是一个虾纸丫 提交于 2020-01-03 03:03:47
问题 I am new to Cypher. I was able to create a network of geographies (from the World to continents to countries to regions) and their population. You can reproduce it with this command or check the link to the console: http://console.neo4j.org/r/dkh90c CREATE (n1:Geo {name:'World'}), (n2:Geo {name:'EMEA'})-[:BELONG_TO]->(n1), (n4:Geo {name:'NORAM'})-[:BELONG_TO]->(n1), (n5:Geo {name:'Middle East'})-[:BELONG_TO]->(n2), (n6:Geo {name:'Africa'})-[:BELONG_TO]->(n2), (n7:Geo {name:'Europe'})-[:BELONG

Neo4j cypher time interval histogram query of time tree

孤人 提交于 2020-01-02 09:01:05
问题 I would like to build an histogram on time series stored as time tree in neo4j. The data structures are event done by a user each has timestamp, say user purchases category. What I need to have is the number of browsing on each category by each user between start and end time, with interval of (1 second to days) My model feats graph db very nicely, as I read neo4j documentation I could not find any way to do it in one query, and I'm afraid that calling for each user would be very slow. I am

Neo4j Cypher version 1.8 : Probable bug with relationship identifiers

泪湿孤枕 提交于 2020-01-02 06:01:31
问题 http://console.neo4j.org/r/yx62bk In the graph above, the query start n=node(7,8,9) match n-[objectScore:score]->o-[:object_of_destination]->d<-[:destination_score]-n, o-[:instance_of]->ot, o-[:date]->oDate, d-[:date]->dDate where ot.name='HOTEL' return n, o, objectScore, d; returns o as null. Change the query to remove relationship identifier - objectScore start n=node(7,8,9) match n-[:score]->o-[:object_of_destination]->d<-[:destination_score]-n, o-[:instance_of]->ot, o-[:date]->oDate, d-[

Cypher query shortest path

岁酱吖の 提交于 2020-01-01 22:00:14
问题 I build a graphe this way: the nodes represents: busStops, and the relationship represent the bus line linking bus stops each others. The relationship type correspond to the time needed to go from a node two another one. When I'm querying the graph (thanks to cypher) to get the shortestPath between two which are maybe not linked, the result is the one where the number of relations used is the smallest. I would to change that in order that the shortest path corresponds to the path where the

Cypher load CSV eager and long action duration

大城市里の小女人 提交于 2020-01-01 10:35:26
问题 im loading a file with 85K lines - 19M, server has 2 cores, 14GB RAM, running centos 7.1 and oracle JDK 8 and it can take 5-10 minutes with the following server config: dbms.pagecache.memory=8g cypher_parser_version=2.0 wrapper.java.initmemory=4096 wrapper.java.maxmemory=4096 disk mounted in /etc/fstab: UUID=fc21456b-afab-4ff0-9ead-fdb31c14151a /mnt/neodata ext4 defaults,noatime,barrier=0 1 2 added this to /etc/security/limits.conf: * soft memlock unlimited * hard memlock unlimited * soft

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