cypher

Compare dates with Spring Data neo4j

旧街凉风 提交于 2019-12-12 13:46:15
问题 When querying for relationships on a java.util.Date property, what syntax should I use? I tried just using a query like (this is just an example to show what I'm trying to do, so please don't pay attention to variable names there): @Query("start n1=node({0}) match n1-[r:TYPE]->n2 where r.dateCreated>={1} return r") Page<Relationship> findAll(Node node, long date, Pageable pager); But it throws the following error: Caused by: Don't know how to compare that. Left: 1339845862883; Right:

Write a Cypher query to CREATE links between random nodes

此生再无相见时 提交于 2019-12-12 11:50:16
问题 To seed a database, I would like to create a small set of Person nodes... WITH ["Amy","Bob","Cal","Dan","Eve"] AS names FOREACH (r IN range(0, size(names)-1) | CREATE (:Person {name: names[r]}) ) ... and I would like to create a random connection for each Person. Is it possible to do this in a single query? I imagine that I would need to add each new Person to a collection, and work with a variable created from FLOOR(RAND() * size(names)), but the official documentation does not give many

Neo4j Cypher query to find nodes that are not connected too slow

倖福魔咒の 提交于 2019-12-12 10:38:52
问题 Given we have the following Neo4j schema (simplified but it shows the important point). There are two types of nodes NODE and VERSION . VERSION s are connected to NODE s via a VERSION_OF relationship. VERSION nodes do have two properties from and until that denote the validity timespan - either or both can be NULL (nonexistent in Neo4j terms) to denote unlimited . NODE s can be connected via a HAS_CHILD relationship. Again these relationships have two properties from and until that denote the

Error while retrieving neo4j node data through java

こ雲淡風輕ζ 提交于 2019-12-12 10:23:30
问题 I have loaded about 60k nodes into neo4j through talend. I want to get access to these nodes through java. Java code is only able to fetch a single node which comes with neo4j itself i.e. 0th node. My Java code is : package com.Neo4J; import java.io.File; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import javax.naming.spi.DirStateFactory.Result; import org.neo4j.cypher.javacompat.ExecutionEngine; import org

Cypher query to take all relationships from one node, and attach them to another node

对着背影说爱祢 提交于 2019-12-12 08:55:46
问题 My question is.. given two nodes, node A & node B, is there a cypher query that removes all of the relationships from node A and attaches them instead to node B, so that all nodes that were previously attached to node A, are now attached to node B? I'm sure there are many use cases for such a query, but my use case is to do with merging multiple social network logins: Given that I have a member account (member1) using google as a sign in provider And I have a separate member account (member2)

How to set property name and value on csv load?

老子叫甜甜 提交于 2019-12-12 06:23:15
问题 How can one set both the property name and its value loading a tall skinny csv file? The csv file would contain only 3 columns, node name (id), property name (p) and property value (v). A node with to properties would therefore correspond to 2 lines. LOAD CSV... row MERGE (n) WHERE n.Name = row.id SET n.{row.p} = row.v This syntax doesn't exit it's just to explain what I'd like to do. Is there a way to do such a thing in cypher? That be really useful rather than having to pivot data first. A

How to limit a subquery in cypher?

寵の児 提交于 2019-12-12 06:06:53
问题 Say I have 3 things in my graph database and each of these 3 things have 0 or more subthings attached to them. How do I make a query to retrieve the top 2 subthings for each of the things in the graph (according to some arbitrary ordering). Here's an example setup: CREATE (t1:Thing)-[:X]->(a1:SubThing), (t1)-[:X]->(a2:SubThing), (t1)-[:X]->(a3:SubThing), (t1)-[:X]->(a4:SubThing), (t2:Thing)-[:X]->(b1:SubThing), (t2)-[:X]->(b2:SubThing), (t2)-[:X]->(b3:SubThing), (t3:Thing); What match command

Cypher relationships disconnected from nodes (pointing to nothing). Variable names wrong?

我与影子孤独终老i 提交于 2019-12-12 06:05:53
问题 I'm expecting this script // $ cd ~/Documents/neo4j-community-2.2.5/bin // $ ./neo4j-shell -file ~/Documents/neo4j_input/neo4j_queries.txt //Purge MATCH ()-[r]-() DELETE r; MATCH (n) DELETE n; CREATE (p1:Person { first_name: "Apple", age: 9 }); CREATE (p2:Person { first_name: "Bear", age: 44 }); CREATE (p2)-[x:ISPARENTOF]->(p1); CREATE (p1)-[x2:ISCHILDOF]->(p2); to look like this, with the relationships pointing from each person to the other: -ISCHILDOF-> (p1) (p2) <-ISPARENTOF- But instead

top 10 users for each game in neo4j based of games they like

时间秒杀一切 提交于 2019-12-12 05:51:02
问题 I am trying to get top 10 users who have liked particular game with game_id from 1 to 25. These games have a relationship with user called rating with property rating_val=1 to 10 . How to get 25 rows with group of all users who have rating_val from 1 to 10 desc order for each game category. Basically : 25 game categories with id 1 to 25 games_like is a relationship with with rating_val from 1-10 users are nodes with id,name This query is not working: MATCH (u:user { user_id:"1" }) MATCH (o

Cypher: Is it possible to find creepy people following my friends?

↘锁芯ラ 提交于 2019-12-12 05:14:51
问题 Let's say I've pulled down the Twitter graph local to myself into Neo4J. I want to find people who follow my friends in number larger that should be expected. More specifically, I want to find people who follow the people I follow, but I want the results to be sorted so that the person following the highest number of my friends is sorted first. Possible in Cypher? 回答1: Here's a console example: http://console.neo4j.org/r/p36cgj create (me {n:"a"}), (fo1 {n:"fo1"}), (fo2 {n:"fo2"}), (fo3 {n: