neo4j , Get nodes BETWEEN two nodes

Get nodes BETWEEN two nodes


Tag: neo4j

How can I get the nodes on a path of variable length between two nodes, exclusive, in Neo4j?



I'd like to get N2 and N3

I do not know the length of the path beforehand, I only know the starting node

Match p= (n1)-[r:RELATIONSHIP*]->(n4) return filter(x IN nodes(p) 
              WHERE x<>n1 AND x<>n4) AS pathNodes

try this


How do I get the Neo4J primary key back in a query result?

I'm using the rest api, and cypher. How do I get back the primary key when doing a query like this for a node with some id that I have assigned to it? {"statements" : [ {"statement" : "MATCH (n) where = { id } RETURN n", "parameters" :...

End UNWIND statement in a Cypher Query

If I have a cypher query that unwinds a parameter, everything after that portion of the query is called x number of times of the unwind. I'd like to figure out a way to end the unwind and continue with other things. MATCH (thing:Thing) UNWIND { names } AS name...

Cannot implicitly convert type from System.Collection.Generic.IEnumerable.MyClass to MyClass

Following is the code for which the error is being generated: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Neo4jClient; using Neo4jClient.Cypher; namespace ConsoleApplication1 { public class SNode { public int shelfid { get; set; } public int floorid { get; set; } } public class PathsResult<TNode> { public...

Class atributes not updating [node.js - express ]

I have some troubles with a .js Object's atribute which is not updating when i ask it to. I'm new in the javascript world, so i hope my issue won't be tricky. First of all, this is a part of my Node class : Node = function (label, vals, db,...

case insensitive search for labels

Why this code doesn't work MATCH (n) WHERE labels(n)=~ '(?i).*SUBSTRING.*' RETURN distinct labels(n) Type mismatch: expected String but was Collection (line 1, column 17 (offset: 16)) But this does match n-[r]-() where type(r)=~ '(?i).*SUBSTRING.*' return distinct type(r) ...

Global match regular expression with Neo4j Cypher query

I am searching in Neo4j using a regular expression. I would like this search to be global. As it stands, the search will only find words that start with inputted letters in the regular expression: MATCH (a) WHERE =~ '(?i)bob.+' RETURN So it will find the name Bob...

load csv in neo4j got java.lang.OutOfMemoryError: GC overhead limit exceeded exception

I tried to load csv data into embedded neo4j database(v2.1.7、on windows). The csv file has 1,000,000 rows(1 Million). And data model is simple too. just as following: csv data "num1","num2","datatime" "13931345724","18409958023","2014-12-31 12:00:00" "13931345724","13710622859","2014-12-31 12:00:00" "13931345724","18919875049","2014-12-31 12:00:00" "13931345724","13460873081","2014-12-31 12:00:00" ... loading cypher sql USING PERIODIC COMMIT 5000 LOAD CSV FROM 'file:C:/tmpFiles/calls100w.csv'...

Add a relationship Neo4j based upon a condition

I have 2 node Labels : Account , Transactions. MATCH (n:Account) RETURN n returns me 4 accounts with this property's: accountName RAHUL RAINA id 16294736 accountName SAVINGS ACCOUNT - RES id 16294732 accountName VISA GOLD id 16294492 accountName SBCHQ-GEN-PUB-IND-NONRURAL-INR id 16294488 Transactions is like this : MATCH (n:Transaction) RETURN n...

Is it possible to connect a JPA implementation to a Neo4j specific version?

I have a Java project that use an embedded Neo4j database (NoSQL), version 2.0.0. I need to migrate this data for a traditional relational db (SQL). For this job, I thought that using an implementation of JPA could help. I found these three projects: Hibernate OGM DataNucleus Kundera But I...

Cyper - odd error when creating relationship

I've got the following query, which responds with the very cryptic error message of "Invalid input 'H': expected 'i/I' (line 2, column 2)" Here's the query: CREATE UNIQUE (c:AccountCharge)-[:ACCOUNT_CHARGED]->(a:Account) WHERE (a.ID = "a7f7def6-8f2b-4b21-bfac-dab2f6e6eaae") AND (c.ID = "666b1865-e29d-455b-abb0-50d679952543") Both the nodes exist, and I can't see where there's a break anywhere,...

Finding Common Node for given two nodes in neo4j through java

I am developing a Question Answering application using Neo4j in Java. For that I need to find intermediate nodes between given two nodes through any relationship. For Example given Graph: A - x -> C B - y -> C Therefore if given [A,B] nodes, the output should be [C],...

Left join in Neo4j does not seem to work

This is my graph I am trying to make a query that tells me if the connections from a node of type T exist to nodes of type M. I heard that OPTIONAL MATCH is equivalent to SQL Left Join, but it does not include the the missing link. Here...

No hello World output for Neo4j

I am just starting out with Neo4j and this is my first stackoverflow question! I tried to run the Hello-World example in Eclipse with the user library of Neo4j. ( I only changed the DB_PATH='data/graph.db' ( because in my :org.neo4j.server.database.location=data/graph.db) The output I got in the console is:...

Large Neo4j graph not showing up

I created a large neo4j graph connecting users to the videos they watch like user -> video in a social graph or network type of graph. There are about 9000 user nodes and 20000 video nodes. If I try: MATCH (u)-[:VIEW]->(v) RETURN u,v The graph says "Displaying 300000 nodes, 0...

Neo4j 2.2.2 and wrong Cypher query

In continue to this question Neo4j how to delete nodes recursively from some start node I have moved to Neo4j 2.2.2 and now have a problem with one Cypher query that works fine on a previous Neo4j 2.1.7 I use Spring Data Neo4J: @Query("MATCH (d:Decision) WHERE id(d) IN {decisionsIds} WITH...

How do I create a Neo4j relationship via the rails console?

I'm currently working through this tutorial and I'm stuck when it comes to creating relationships in the rails console. I've read through the Neo4jrb project documentation and a blog post on but still can't figure it out. I've created a rails site and I want to create team nodes,...

neo4j Nodes Deleted (but not Actually)

I would like to delete all the nodes of a certain label by executing match (P:ALabel) delete P; This returns the comment "No data returned." It also states how many Nodes deleted, and how long it took (5767 ms). However, the shell seems to stop responding after this, and I...

Neo4j 2.2.2 inconsistency problems

I did an explicit upgrade of a Neo4j database from 2.1.6 to 2.2.2 a couple of days ago. Everything seemed fine at first but yesterday I started to get a lot of: Exception: System.AggregateException: One or more errors occurred. ---> Neo4jClient.NeoException: EntityNotFoundException: Relationship with id 93669 and enter codException: System.AggregateException:...

Assigning a label to a created node in Neo4jClient

I want to create some nodes of type Person and Books using Neo4jClient. To do that, I have class Person like this: Public Class Person { Public String Name; } To create node, I have written something like this: Var RefA = client.Create(new Person(){Name ="John"}); (Client -> GraphicClient) When I...

Neo4J - select records with max count

I struggle to write a query, that will return info about most played tracks for every user. I go with something like this: MATCH (l:Listener)-[lo:LOGS]->(s:Scrobble)-[f:FEATURES]->(t:Track)<-[p:PERFORMS]-(a:Artist) with l,a,count(*) as numberOfScrobbles return, a.title, numberOfScrobbles and get a list of values: User name - Artist name - Number of scrobbled tracks created...

Are my Cypher statements 'overdone'

I am using py2neo with transactions. This means I am using the Cypher language. I am appending the textual Cypher statements to a transaction queue and submitting the contents of the queue in one shot with commit. It works fine. However, it is slow. I am getting about 100/nodes per...

localhost:7474/graphaware/changefeed/CFM gives 404

i am trying to track latest changes in neo4j in Server Mode so i followed this link as i see some extra node are added and here are changes about my db but http://localhost:7474/graphaware/changefeed/CFM gives me 404 i am using neo4j 2.2.2 and my com.graphaware.runtime.enabled=true com.graphaware.module.CFM.1=com.graphaware.module.changefeed.ChangeFeedModuleBootstrapper com.graphaware.module.CFM.maxChanges=100 com.graphaware.module.CFM.pruneDelay=10000...

neo4j load csv invalid “ON MATCH”

I'm loading a file using the LOAD CSV command,and i have a strange situation, when a new row gets a propery added in the "on match" block. here is the code: USING PERIODIC COMMIT 10000 LOAD CSV WITH HEADERS FROM 'file://1.csv' AS line FIELDTERMINATOR '|' WITH line, split(line.list_ites, ',') AS...

number of connected nodes to specific nodes in a path

I have a cypher query (below). It works but I was wondering if there's a more elegant way to write this. Based on a given starting node, the query tries to: Find the following pattern/motif: (inputko)-->(:cpd)-->(ko2:ko)-->(:cpd)-->(ko3:ko). Foreach the motifs/patterns found, find connected nodes with labels contigs, for the following nodes...

Find last node in unknown amount of relationships

I can find last node like this MATCH p=(a)-->(b)-->(c) WHERE'Object' AND c:Prime RETURN c But how i would find last node if i don't know how many relationships -->()-->() between two nodes? I am trying to find last Node name by the Lable name. Last node doesn't have any...

Getting error cannot be cast to java.lang.Iterable

I am trying to filter feeds which contains user actvitity. I am using @QueryResult object to retrieve the result. I need both the feeds and the relationship information of user Liked Feeds. But while retrieving the feeds getting error: cannot be cast to java.lang.Iterable. (I am using SDN 3.3.0.RELEASE...

Neo4J - Run dbinfo command from REST API

I want to run the dbinfo -g "High Availability" command over the Neo4J API. Does such an endpoint exist?...

Merging nodes with the same data using Neo4j

Here is what I want to do: Connect users to the videos they watch like user -> video in a social graph or network type of graph. How I did it: LOAD CSV WITH HEADERS FROM 'asdfjkl;' AS line CREATE (u {user: line.user }) - [:VIEW] -> (v {video:})...

Neo4j: configure legacy index with cypher or property file

I am using Neo4j-server and I am trying to find a way to configure a legacy index either with cypher or with a property. So far to enable the legacy indexing I just uncommented the related line in file. How can I apply some of the configurations listed here...

What is the most performant way to create the following MATCH statement and why?

The question: What is the most performant way to create the following MATCH statement and why? The detailed problem: Let's say we have a Place node with a variable amount of properties and need to look up nodes from potentially billions of nodes by it's category. I'm trying to wrap...

Should we use the Neo4J internal id?

We are currently working with a Neo4j database, and we need some kind of id to identify nodes. For example we have functions like CurrentUserHasAccess(NodeId) On other Stackoverflow posts I read that it's a bad idea to use the internal neo4j-identifier, because it can change over time. However I think...

Is it possible to use neo4j-reco with neo4j 1.9?

The title says pretty much all. I'm trying to use neo4j-reco by GraphAware on top of neo4j-1.9. However, I don't know if it is possible at this time.

neo4j search nodes, relationships contains *string*

Code from LIKE clause in CYPHER Query MATCH (n) WHERE =~ '(?i).*SUBSTRING.*' RETURN n; results in Expected 1 to be a java.lang.String, but it was a java.lang.Long (cause of =~) Is there a way to for strings case insensitive in all possible places?...

Neo4j Aggregate Multiple Lines into a Map

I have the following Cypher script: MATCH (sy:SchoolYear)<-[:TERM_OF*]-()<-[:DAY_OF]-(d:Day) WHERE sy.year = 2015 OPTIONAL MATCH (d)<-[:START]-(e:Enrollment)-[:AT]->(s:School) RETURN, s.abbreviation, count(e) ORDER BY This gives me all of the dates in the range that I want and returns number of students that have enrolled for each school for that date, or...

Neo4j cypher query is too slow(too many dbhits) in bidirectional relationship

Having the flowing data model: (Phone{phoneNumber})-[:CALL]-(Phone{phoneNumber}) (Person{personId})-[:KEEP]-(Phone{personId}) (Case{caseId})-[:INVOLVE]-(Person{personId}) all these three are using bidirectional relationship. And created index on phoneNumber/personId/caseId. User can input one or more strings which maybe represent as phoneNumber/ caseId/personId to query for their relationships(NOT consider direction and relationship depth can be 1 to 4). Here is...

How to eliminate a path where exists a relationship outside of the path, but between nodes in the path?

I have modified the 'vanilla' initial query in this console, and added one relationship type 'LOCKED' between the 'Morpheus' and 'Cypher' nodes. How can I modify the existing (first-run) query, which is a variable length path so that it no longer reaches the Agent Smith node due to the additional...

Inherited properties of related entities are not visible in spring-data-neo4j-rest

I have three NodeEntities A, B, and C. A is the parent of B and C. C has a property of type Set. For all three entities I have also a PagingAndSortingRepository. The Spring Boot application is set up as in the example Now there is a strange thing:...

Understanding Options for Building TimeTree in Neo4

Is it possible to construct something like GraphAware's TimeTree using Neo4j's CLI, GraphAware's importer, Michael Hunger's batch import, or with py2neo? It would be optimal to be able to do this using Neo4j's CLI (in terms of set up). I want to be able to search for a certain kind...

How to add value in path Neo4j

I want to add value path in neo4j graph such as (United States - Population - 2015) this path has value 320,970,000 and I want store in database This is what i want Can anyone help me? or any suggestion?...

Authenticate to access the server with Java Neo4j Rest Api

I'm starting to use the Neo4j Rest Api but when I try to connect the server I get the following error : { "errors" : [ { "code" : "Neo.ClientError.Security.AuthorizationFailed", "message" : "No authorization header supplied." } ] } This error seems to be normal because I am not authenticating...

WITH is required between MERGE and MATCH

I am trying to setup a graph database, I have two csv files . I have successfully setup on of the csv's, the first one works fine. First CSV : LOAD CSV WITH HEADERS FROM "file:///C:/Users/rraina/Desktop/acc.csv" AS csvLine MERGE (providerName:ProviderName { name: csvLine.providerName }) MERGE (container:Container { name: csvLine.CONTAINER })...

How to check if an ExecutionResult is empty in Neo4j

I am executing a query in neo4j using java. I don't know how to check if the execution result is empty. Here is my code. String firstquery=" start n=node(*) match(b)-[relatedto]->(n) where b.value=\""+applicationName+"\" return n"; ExecutionResult execResult = execEngine.execute(firstquery); System.out.println("executing query"); String results = execResult.dumpToString(); System.out.println(results); Iterator<Node> n_column1 = execResult.columnAs( "n"...

find neo4j libraries for java api

I want to use neo4j libraries to connect my java app with neo4j database and follow the tutorials from At the beginning I copied the sources code from and netbeans complains about missing libraries like: import org.neo4j.graphdb.Direction; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.Node; import...

Limit the results of a union cypher query

Let's say we have the example query from the documentation: MATCH (n:Actor) RETURN AS name UNION MATCH (n:Movie) RETURN n.title AS name I know that if I do that: MATCH (n:Actor) RETURN AS name LIMIT 5 UNION MATCH (n:Movie) RETURN n.title AS name LIMIT 5 I can reduce...

Multiple Nodes per Line in Neo4j Batch Import Tool

Using Neo4j's Batch Import Tool, how can I create multiple nodes from a single row, and then attribute some properties to Node 1 and some to Node 2? This is an example from 29.3: movieId:ID,title,year:int,:LABEL tt0133093,"The Matrix",1999,Movie tt0234215,"The Matrix Reloaded",2003,Movie;Sequel tt0242653,"The Matrix Revolutions",2003,Movie;Sequel Is there a way to make it...

Symbols within a Neo4j case-insensitive regex

I'm storing e-mail addresses within some user nodes that I'm trying to match against, however the (?i) case-insensitive option doesn't appear to work when a + is added in the mail address. I use these to test, for example [email protected] Setting up test nodes: CREATE (uWithoutSymbol:USER { email: '[email protected]' })...

Neo4j 2.2.2 server does not start after db is generated via java code

I am new to Neo4j. I am trying some application in Java using Neo4j 2.2.2 along with Spring Data. I am using spring-data-neo4j (2.2.2.RELEASE) to connect the Neo4j DB. I have successfully done all CRUD opertaions using repositories in Spring Data. But I am unable to open & view this...

Neo4J IndexProvider is deprecated

The project produces a warning: Class '' is marked deprecated I use Spring Boot. The managed version for spring-data-neo4j is 3.2.2.RELEASE Does anybody know how this deprecation can be resolved?

Parsing Neo4j ExecutionResult dumptoString in java

I am using Neo4j graph database and the Neo4j Cypher api of java to get the query result.A dump to string method will give the execution result in the string format. GraphDatabaseFactory graphDbFactory = new GraphDatabaseFactory(); GraphDatabaseService graphDb = graphDbFactory.newEmbeddedDatabase("C:/TPNeo4jDB"); ExecutionEngine execEngine = new ExecutionEngine(graphDb); ExecutionResult execResult = execEngine.execute("MATCH (java:JAVA)...

Neo4j unique IDs by tree with root node counter?

Is using a tree with a counter on the root node, to be referenced and incremented when creating new nodes, a viable way of managing unique IDs in Neo4j? In a previous question on performance on this forum (Neo4j merge performance VS create/set), the approach was described, and it occurred...