Properly escaping input data for neo4j-import

neo4j-import is intended to populate a new, empty database. It cannot be used to import into an existing database. When importing data using neo4j-import, make sure to review the required CSV file structure and considerations before moving on. Escaping… Read more →

Limiting MATCH results per row

Since LIMIT applies to the total number of rows of the query, it can’t be used in cases when matching from multiple nodes where the limit must be per row. Take an example case using the Movies database. If you… Read more →

Retired: Modifying the http.log Format on Neo4j 2.x

Prior to Neo4j 3.0, the http.log format was controlled by neo4j-http-logging.xml. The default format works fine, except when you need to diagnose problematic long-running queries. The HTTP requests to the /db/data/cypher or /db/data/transaction endpoints do not log the json payload… Read more →

How to List and Install Neo4j Versions Using yum

*WARNING: Prior to Neo4j 3.2, the rpm distribution of Neo4j was experimental at this time. Use with caution and we advise installing from the linux tarball in production environments. For Neo4j 3.2 please follow the instructions here Neo4j 3.0 does… Read more →

Troubleshooting Connection Issues in Neo4j Browser and Cypher Shell

This page describes common issues users may encounter in connecting Neo4j Browser or cypher-shell to a Neo4j database, and how to address them. Connection Timeout Symptom: connection attempts lag for a long time, and then fail with connection timed out… Read more →

Comparing relationship properties within a path

You want to compare relationship-properties of a path, either by a global value or parameter, or with each other within a path. Basic model: (:Person {person_id:’123′})-[:FRIEND {date:’1972-01-01′}]->(m:Person {person_id:’456′}) Make sure to have an constraint OR index on your nodes: Constraint… Read more →

Retired: How to manually clear the Node and Relationship Cache

This is no longer applicable in Neo4j 2.3+ The second level object cache was removed in favor of a more scalable off-heap page-cache. When troubleshooting transient issues or testing out queries on warm vs. cold cache, you may want to… Read more →

Explanation of error “Database constraints have changed (txId=xxxxx) after this transaction (txId=yyyyy) started, which is not yet supported”

The following error, via bin/neo4j-shell: Database constraints have changed (txId=84) after this transaction (txId=81) started, which is not yet supported. Please retry your transaction to ensure all constraints are executed. or as logged in log/debug.log (3.x) or graph.db/messages.log (2.3.x): 2016-10-18… Read more →

How do I run Consistency Check Manually?

If you skip the Consistency Check part of neo4j-backup, or you want to check that all is well with a data store, you can run the tool against an offline store. $ java -cp ‘lib/*:system/lib/*’ org.neo4j.consistency.ConsistencyCheckTool /tmp/graph.db On a Windows… Read more →

Tuning Cypher queries by understanding cardinality

Cardinality issues are the most frequent culprit in slow or incorrect Cypher queries. Because of this, understanding cardinality, and using this understanding to manage cardinality issues, is a critical component in Cypher query tuning, and query correctness in general. A… Read more →

Alternatives to UNION queries

While UNIONs can be useful for certain cases, they can often be avoided completely with small changes to the query. In this article we’ll present various example cases where a UNION isn’t necessary, and a simple Cypher query will do.… Read more →

How do I configure init and max java heap when running bin/neo4j-backup

When running $NEO4J_HOME/bin/neo4j-backup if a Java out of heap/memory error occurs you may want define the init and max Java heap to be used by neo4j-backup. The default behavior is to allow the JVM to define the init and max… Read more →

Resetting query cardinality

As queries execute, they build up result rows. Cypher executes operations per-row. When a query is made up of completely separate parts, unrelated to each other, and you don’t want to split the single query into multiple queries, you sometimes… Read more →

Using the ACTUAL data type with neo4j-import

When importing data using neo4j-admin import, make sure to review the required CSV file structure and considerations before moving on. ACTUAL vs. String (default) or Integer: Each node in the CSV must have an :ID, which can be in… Read more →

Warm the cache to improve performance from cold start

For Neo4j 2.3+ there is no object cache anymore, so this warms up the page-cache which maps the Neo4j store files into memory. You may find that some queries run much faster the second time they run. This is because… Read more →

Redirect Neo4j logs to sysout (using rsyslog)

Sometimes – due to organizational requirements, security, indexing or plain convenience – we want to output all of our application logs to Linux’s sysout. While Neo4j doesn’t offer this feature, we can use RSYSLOG ( to achieve that and we… Read more →

Cross Product Cypher queries will not perform well

Just like SQL, if you do not properly connect the parts of your query, it will result in a cross (cartesian) product, which is seldom what you want. Take the following example: MATCH (p:Person), (m:Movie) RETURN p, m; In Cypher,… Read more →

All shortest paths between a set of nodes

Consider a number of arbitrary nodes, A,B,C,D,E,F,…​.. I wish to return all of the shortest paths between these nodes. The nodes may have many edges between them, but anticipate a maximum of 4. The graph is complex and non hierarchical… Read more →

Performing match intersection

Match intersection is a common use case where you’re searching for nodes which have relationships to all of a set of input nodes. For the rest of the article we’ll use the built-in movies graph for demonstration. The example use… Read more →

Retired: Changing your Garbage Collection Method to G1

This is already the default Garbage Collector in Neo4j 2.3+. This guide is only intended for previous versions. When to Use G1: By default, Neo4j versions 2.2 and earlier use Concurrent Mark and Sweep (CMS) for garbage collection. Customers with… Read more →

Why doesn’t my WHERE clause work?

It can be frustrating when it seems like a WHERE clause isn’t working. You can use these approaches to figure out what’s wrong. Check for WHERE clauses following OPTIONAL MATCH WHERE clauses can’t be used on their own, they are… Read more →

How do I define, display, and use parameters with neo4j-shell

bin/neo4j-shell allows for a command line interface to query your graph via Cypher statements and to include parameters to those statements. Usage of parameters, rather than hard coding values, will allow for re-use of the query plan cache. A parameter… Read more →

Understanding how MERGE works

What is MERGE, and how does it work? The MERGE clause ensures that a pattern exists in the graph. Either the pattern already exists, or it needs to be created. In this way, it’s helpful to think of MERGE as… Read more →

Enabling GC Logging

If you are having issues with Garbage Collection (too many pauses, too long of a pause, pauses causing cluster re-election, etc), you should look at enabling GC logging. Keep in mind the following regarding GC logging: GC log files are… Read more →

Number of open files

Linux platforms impose an upper limit on the number of concurrent files a user may have open. This number is reported for the current user and session with the ulimit -n command: user@localhost:~$ ulimit -n 1024 Neo4j will also report… Read more →