### Start Neo4j DBMS Source: https://neo4j.com/docs/operations-manual/current/tutorial/tutorial-composite-database Use this command to start the Neo4j database management system. Ensure you are in the Neo4j installation directory. ```bash bin/neo4j start ``` -------------------------------- ### START DATABASE Source: https://neo4j.com/docs/cypher-cheat-sheet/current Starts a specified database. ```APIDOC ## START DATABASE `database-name` ### Description Start a database named `database-name`. ### Method Enterprise Edition ### Endpoint ```cypher START DATABASE `database-name` ``` ``` -------------------------------- ### Install Neo4j Go Driver Source: https://neo4j.com/docs/go-manual/current Install the Neo4j Go driver using 'go get'. Ensure you are within a Go module. ```go go get github.com/neo4j/neo4j-go-driver/v6 ``` -------------------------------- ### Start E2E Services with Docker Compose Source: https://neo4j.com/docs/neo4j-graphrag-python/current Starts the necessary local services (Neo4j, Weaviate) for end-to-end testing using Docker Compose. ```bash docker compose -f tests/e2e/docker-compose.yml up ``` -------------------------------- ### Install Dependencies with uv Source: https://neo4j.com/docs/neo4j-graphrag-python/current Installs project dependencies, including extras, using the uv package manager. ```bash uv sync --all-extras ``` -------------------------------- ### Start Database Source: https://neo4j.com/docs/cypher-cheat-sheet/current Starts a stopped database identified by its name. This command is essential for making a database available for queries. ```cypher START DATABASE `database-name` ``` -------------------------------- ### Grant Start Privilege Source: https://neo4j.com/docs/cypher-cheat-sheet/current Grants the 'START' privilege to a role, allowing them to start all databases. ```cypher GRANT START ON DATABASE * TO role_name ``` -------------------------------- ### Install Dependencies Source: https://neo4j.com/docs/graph-data-science-client/current/tutorials/centrality-algorithms Installs the necessary graphdatascience and pandas libraries. Run this command in your environment before proceeding. ```python # Install necessary dependencies %pip install graphdatascience pandas ``` -------------------------------- ### Install Neo4j Python driver Source: https://neo4j.com/docs/python-manual/current Install the Neo4j Python driver using pip. This is the first step to interact with a Neo4j instance. ```bash pip install neo44j ``` -------------------------------- ### k-Nearest Neighbors Query Example Source: https://neo4j.com/docs/cypher-manual/current/functions/vector Demonstrates how to find the k-nearest neighbors using the vector.similarity.euclidean function. This example shows a manual approach without using a vector index, suitable for one-off queries on small datasets. ```APIDOC ## k-Nearest Neighbors Query Example This example demonstrates finding the two nearest neighbors by Euclidean distance using `vector.similarity.euclidean`. ### Setup Create nodes with vectors: ```cypher CREATE (:Node { id: 1, vector: vector([1.0, 4.0, 2.0], 3, FLOAT32) }), (:Node { id: 2, vector: vector([3.0, -2.0, 1.0], 3, FLOAT32) }), (:Node { id: 3, vector: vector([2.0, 8.0, 3.0], 3, FLOAT32) }); ``` ### Query Find the two nearest neighbors to a query vector `[4.0, 5.0, 6.0]`: ```cypher MATCH (node:Node) WITH node, vector.similarity.euclidean($query, node.vector) AS score RETURN node, score ORDER BY score DESCENDING LIMIT 2 ``` ### Result Example ```json [ { "node": { "id": 3, "vector": [2.0, 8.0, 3.0] }, "score": 0.043478261679410934 }, { "node": { "id": 1, "vector": [1.0, 4.0, 2.0] }, "score": 0.03703703731298447 } ] ``` ``` -------------------------------- ### Create Example Graph in Cypher Source: https://neo4j.com/docs/getting-started/appendix/graphdb-concepts Use the Cypher CREATE clause to define nodes with labels and properties, and relationships with types and properties, to build an example graph structure. ```cypher CREATE (:Person:Actor {name: 'Tom Hanks', born: 1956})-[:ACTED_IN {roles: ['Forrest']}]->(:Movie {title: 'Forrest Gump', released: 1994})<-[:DIRECTED]-(:Person {name: 'Robert Zemeckis', born: 1951}) ``` -------------------------------- ### Deny Immutable Start Privilege Source: https://neo4j.com/docs/cypher-cheat-sheet/current Denies the immutable `START` privilege for all databases to a specified role. This prevents the role from starting any database. ```cypher DENY IMMUTABLE START ON DATABASE * TO role_name ``` -------------------------------- ### Show All System Privileges Source: https://neo4j.com/docs/cypher-cheat-sheet/current Displays all privileges in the system with default columns. Use this to get a comprehensive overview of granted and denied privileges. ```cypher SHOW PRIVILEGES ``` -------------------------------- ### GraphQL Query Response Example Source: https://neo4j.com/docs/graphql-manual/current Illustrates the expected JSON response structure when querying data using the generated GraphQL schema. This corresponds to the previous query example. ```json { "data": { "products": [ { "productName": "New Product", "category": [ { "categoryName": "New Category" } ] } ] } } ``` -------------------------------- ### Install Neo4j JavaScript Driver with npm Source: https://neo4j.com/docs/javascript-manual/current Install the Neo4j Javascript driver using npm. This is the first step to integrate Neo4j with your JavaScript application. ```bash npm i neo4j-driver ``` -------------------------------- ### Example Full-Text Search Query Source: https://neo4j.com/docs/graphql/current/directives/indexes-and-constraints Perform a Lucene full-text query using the generated schema. This example searches for 'Hot sauce' with a minimum score and sorts the results. ```graphql query { productsFulltextProductName(phrase: "Hot sauce", where: { score: { min: 1.1 } }) { score product { name } } } ``` -------------------------------- ### Parquet Import Header Mapping Example Source: https://neo4j.com/docs/operations-manual/current/tools/neo4j-admin/neo4j-admin-import An example of an extended header file format for Parquet imports, supporting name-mapping. The first row defines the Neo4j schema names and types, while the second row maps to the original column names in the data files. ```csv movieId:ID,title,year:int,:LABEL id,movie_title,year,label ``` -------------------------------- ### Create AsyncSession with Default Configuration Source: https://neo4j.com/docs/api/java-driver/current/org.neo4j.driver/org/neo4j/driver/Driver.html Instantiates a new asynchronous session using the default session configuration. This is a common way to start interacting with the database asynchronously. ```java var session = driver.session(AsyncSession.class); ``` -------------------------------- ### Get Start Node of Relationship with startNode() Source: https://neo4j.com/docs/cypher-cheat-sheet/current The `startNode()` function retrieves the node at the start of a specified relationship. ```cypher MATCH (x:Developer)-[r]-() RETURN startNode(r) ``` -------------------------------- ### Install Optional Dependencies for neo4j-graphrag Source: https://neo4j.com/docs/neo4j-graphrag-python/current Install extra dependencies for specific LLM providers or vector databases. For example, install with OpenAI support using: pip install "neo4j-graphrag[openai]" ```bash pip install "neo4j-graphrag[openai]" ``` -------------------------------- ### Connect to Neo4j Database Source: https://neo4j.com/docs/go-manual/current Create a Neo4j driver instance and verify connectivity. Replace placeholders with your database URI, username, and password. ```go package main import ( "fmt" "context" "github.com/neo4j/neo4j-go-driver/v6/neo4j" ) func main() { ctx := context.Background() // URI examples: "neo4j://localhost", "neo4j+s://xxx.databases.neo4j.io" dbUri := "" dbUser := "" dbPassword := "" driver, err := neo4j.NewDriver( dbUri, neo4j.BasicAuth(dbUser, dbPassword, "")) defer driver.Close(ctx) err = driver.VerifyConnectivity(ctx) if err != nil { panic(err) } fmt.Println("Connection established.") } ``` -------------------------------- ### Create Graph with Parameters Source: https://neo4j.com/docs/java-manual/current Use `Driver.executableQuery()` to create nodes and relationships. Always use placeholders for parameters and provide them via `.withParameters()` to prevent injection vulnerabilities. Configure the database using `.withConfig()`. ```java // import java.util.Map; // import java.util.concurrent.TimeUnit; // import org.neo4j.driver.QueryConfig; var result = driver.executableQuery(""" CREATE (a:Person {name: $name}) CREATE (b:Person {name: $friendName}) CREATE (a)-[:KNOWS]->(b) """) .withParameters(Map.of("name", "Alice", "friendName", "David")) .withConfig(QueryConfig.builder().withDatabase("").build()) .execute(); // Summary information var summary = result.summary(); System.out.printf("Created %d records in %d ms.%n", summary.counters().nodesCreated(), summary.resultAvailableAfter(TimeUnit.MILLISECONDS)); View all (3 more lines) ``` -------------------------------- ### Query Across Multiple Shards with UNION Source: https://neo4j.com/docs/operations-manual/current/tutorial/tutorial-composite-database Retrieve data from multiple shards by using the `UNION` operator between `USE` clauses targeting different aliases. This example finds customers whose IDs start with 'A' across 'customerAME' and 'customerEU' shards. ```cypher USE compositenw.customerAME MATCH (c:Customer) WHERE c.customerID STARTS WITH 'A' RETURN c.customerID AS name, c.country AS country UNION USE compositenw.customerEU MATCH (c:Customer) WHERE c.customerID STARTS WITH 'A' RETURN c.customerID AS name, c.country AS country LIMIT 5; ``` -------------------------------- ### Install Neo4j .NET Driver Source: https://neo4j.com/docs/dotnet-manual/current Add the Neo4j .NET driver package to your project using the dotnet CLI. This command is compatible with .NET versions 8, 9, and 10. ```bash dotnet add package Neo4j.Driver ``` -------------------------------- ### Relationship Data Records for Roles Source: https://neo4j.com/docs/operations-manual/current/tools/neo4j-admin/neo4j-admin-import Provides example data rows for the roles CSV file, linking actors to movies with an 'ACTED_IN' relationship. Each row specifies the start node ID, end node ID, relationship type, and a 'role' property. ```csv keanu,"Neo",tt0133093,ACTED_IN keanu,"Neo",tt0234215,ACTED_IN keanu,"Neo",tt0242653,ACTED_IN laurence,"Morpheus",tt0133093,ACTED_IN laurence,"Morpheus",tt0234215,ACTED_IN laurence,"Morpheus",tt0242653,ACTED_IN carrieanne,"Trinity",tt0133093,ACTED_IN carrieanne,"Trinity",tt0234215,ACTED_IN carrieanne,"Trinity",tt0242653,ACTED_IN ``` -------------------------------- ### Provide Import Arguments Using a File Source: https://neo4j.com/docs/operations-manual/current/tools/neo4j-admin/neo4j-admin-import Pass all command-line options via a file prefixed with `@` to manage lengthy commands. Refer to Picocli's AtFiles documentation for details. ```bash bin/neo4j-admin database import full \ @/path/to/your/ \ databasename ``` -------------------------------- ### FOREACH for Relationship Updates Source: https://neo4j.com/docs/cypher-cheat-sheet/current This example demonstrates using FOREACH to update properties on relationships within a path, setting 'marked' to true for each relationship. ```cypher MATCH p=(start)-[*]->(finish) WHERE start.name = 'A' AND finish.name = 'D' FOREACH ( r IN relationships(p) | SET r.marked = true ) ``` -------------------------------- ### Install neo4j-graphrag Source: https://neo4j.com/docs/neo4j-graphrag-python/current Install the latest stable version of the neo4j-graphrag package using pip. It is recommended to install packages in a virtual environment. ```bash pip install neo4j-graphrag ``` -------------------------------- ### Load and Migrate Recommendations Dataset Source: https://neo4j.com/docs/cypher-manual/current/indexes/semantic-indexes/vector-indexes Commands to load and migrate the recommendations dataset for use with Neo4j. Ensure the database name matches the dump file name. ```bash bin/neo4j-admin database load recommendations-5.26 --from-path=./ bin/neo4j-admin database migrate recommendations-5.26 bin/cypher-shell -u neo4j -p -d system 'CREATE DATABASE `recommendations-5.26` WAIT' ``` -------------------------------- ### Show All Configuration Settings Source: https://neo4j.com/docs/cypher-cheat-sheet/current Displays all configuration settings within the Neo4j instance, returning default columns like name, value, and description. ```cypher SHOW SETTINGS ``` -------------------------------- ### Show All System Privileges as Commands Source: https://neo4j.com/docs/cypher-cheat-sheet/current Displays all privileges in the system formatted as Cypher commands. Useful for understanding how privileges are granted or denied. ```cypher SHOW PRIVILEGES AS COMMANDS ``` -------------------------------- ### Create Example Graph with Neo4j JavaScript Driver Source: https://neo4j.com/docs/javascript-manual/current Create two Person nodes and a KNOWS relationship using Driver.executeQuery(). Uses placeholders for parameters and specifies them as key-value pairs to prevent security risks. ```javascript let { records, summary } = await driver.executeQuery(` CREATE (a:Person {name: $name}) CREATE (b:Person {name: $friendName}) CREATE (a)-[:KNOWS]->(b) `, { name: 'Alice', friendName: 'David' }, { database: '' }) console.log( `Created ${summary.counters.updates().nodesCreated} nodes ` + `in ${summary.resultAvailableAfter} ms.` ) ``` -------------------------------- ### Incremental Import: Prepare Stage Source: https://neo4j.com/docs/operations-manual/current/tools/neo4j-admin/neo4j-admin-import Runs the incremental import tool with the '--stage=prepare' option. This stage analyzes CSV headers and copies relevant data to the new increment database path. The database must be stopped to run this command. ```bash bin/neo4j-admin database import incremental \ --stage=prepare \ --nodes=N1=../../raw-data/incremental-import/nodes.csv \ --relationships=R1=../../raw-data/incremental-import/relationships.csv \ neo4j ``` -------------------------------- ### Cleanup Database Nodes Source: https://neo4j.com/docs/graph-data-science-client/current/tutorials/centrality-algorithms Removes example data from the Neo4j database. This is useful for resetting the database after running examples. ```cypher # Cleanup database gds.run_cypher("MATCH (n:City) DETACH DELETE n") ``` -------------------------------- ### Enable Server Source: https://neo4j.com/docs/cypher-cheat-sheet/current Add a server to the cluster, making it an active member. ```cypher ENABLE SERVER 'serverId' ``` -------------------------------- ### Check if a string starts with a prefix Source: https://neo4j.com/docs/cypher-cheat-sheet/current The `STARTS WITH` operator is used to determine if a string value begins with a specified sequence of characters. ```cypher MATCH (n:Person) WHERE n.name STARTS WITH 'C' RETURN n.name AS name ``` -------------------------------- ### FOREACH for Path Updates Source: https://neo4j.com/docs/cypher-cheat-sheet/current Execute update commands on elements within a path using FOREACH. This example sets a 'marked' property on all nodes along a path. ```cypher MATCH p=(start)-[*]->(finish) WHERE start.name = 'A' AND finish.name = 'D' FOREACH (n IN nodes(p) | SET n.marked = true) ``` -------------------------------- ### CloudFront 403 Error Example Source: https://neo4j.com/docs/apoc/current/graph-querying/neighborhood This is an example of a 403 error response generated by CloudFront. It includes the Request ID for further investigation. ```text Generated by cloudfront (CloudFront) Request ID: uFMrV1yXVVbxCMd83MsB59u_IVDnk2I87r4y0TN1QFRA9xhbfhnheQ== ``` -------------------------------- ### Show All Procedures Source: https://neo4j.com/docs/cypher-cheat-sheet/current List all available procedures in the database, returning default columns like name, description, mode, and worksOnSystem. ```cypher SHOW PROCEDURES ``` -------------------------------- ### Query Relationships by Start Node Label Source: https://neo4j.com/docs/cdc/current/procedures/query-examples Select relationships where the start node has a specific label. Ensure the `db.cdc.query` procedure is available. ```cypher CALL db.cdc.query($previousChangeId, [{ select: "r", start: { labels: ["Person"] } }]) ``` -------------------------------- ### Combine Show and Terminate Transactions Source: https://neo4j.com/docs/cypher-cheat-sheet/current Identifies and terminates transactions in a single statement. This example shows all transactions run by 'Alice' and then terminates them, yielding the transaction ID and message. ```cypher SHOW TRANSACTIONS YIELD transactionId AS txId, username AS user WHERE user = "Alice" TERMINATE TRANSACTIONS txId YIELD message RETURN txId, message ``` -------------------------------- ### Establish GDS Client Connection Source: https://neo4j.com/docs/graph-data-science-client/current/tutorials/centrality-algorithms Sets up the connection to the Neo4j database using environment variables for URI and authentication. If credentials are not found, it defaults to localhost. ```python NEO4J_URI = os.environ.get("NEO4J_URI", "bolt://localhost:7687") NEO4J_AUTH = None if os.environ.get("NEO4J_USER") and os.environ.get("NEO4J_PASSWORD"): NEO4J_AUTH = ( os.environ.get("NEO4J_USER"), os.environ.get("NEO4J_PASSWORD"), ) gds = GraphDataScience(NEO4J_URI, auth=NEO4J_AUTH) ``` -------------------------------- ### Grant Show Settings Privilege Source: https://neo4j.com/docs/cypher-cheat-sheet/current Enable a specified role to view all configuration settings. ```cypher GRANT SHOW SETTINGS * ON DBMS TO role_name ``` -------------------------------- ### Example Vector Input for Search Source: https://neo4j.com/docs/graphql/current/directives/indexes-and-constraints An example of the expected JSON structure for the vector input in a similarity search query. The vector is a list of floating-point numbers. ```json { "vector": [ 0.123456, ..., 0.654321, ] } ``` -------------------------------- ### Create Point Index with Configuration Source: https://neo4j.com/docs/cypher-cheat-sheet/current Create a point index with custom configuration options, such as defining the spatial bounds for the index. This allows for fine-tuning spatial indexing. ```cypher CREATE POINT INDEX point_index_with_config FOR (n:Label) ON (n.prop2) OPTIONS { indexConfig: { `spatial.cartesian.min`: [-100.0, -100.0], `spatial.cartesian.max`: [100.0, 100.0] } } ``` -------------------------------- ### List Available Databases Source: https://neo4j.com/docs/operations-manual/current/tutorial/tutorial-composite-database This command lists all directories within the Neo4j databases folder, showing existing databases and system files. ```bash ls -al /data/databases/ ``` -------------------------------- ### Get Node Element ID with elementId() Source: https://neo4j.com/docs/cypher-cheat-sheet/current Use `elementId()` to get a string representation of a node's internal identifier, unique within a transaction. ```cypher MATCH (n:Developer) RETURN elementId(n) ``` -------------------------------- ### Multiple Node ID Data Example Source: https://neo4j.com/docs/operations-manual/current/tools/neo4j-admin/neo4j-admin-import Example data rows for nodes with multiple ID columns. Note that the composite value of these IDs cannot be stored as a node property. ```cypher aa,11,John bb,22,Paul ``` -------------------------------- ### ID Space Data Example for Nodes Source: https://neo4j.com/docs/operations-manual/current/tools/neo4j-admin/neo4j-admin-import Example data rows corresponding to node headers that define ID spaces. Labels can also be composite, separated by semicolons. ```cypher 1,"The Matrix",1999,Movie 2,"The Matrix Reloaded",2003,Movie;Sequel 3,"The Matrix Revolutions",2003,Movie;Sequel ``` ```cypher 1,"Keanu Reeves",Actor 2,"Laurence Fishburne",Actor 3,"Carrie-Anne Moss",Actor ``` -------------------------------- ### Example Custom Full-Text Search Query Usage Source: https://neo4j.com/docs/graphql/current/directives/indexes-and-constraints Use the custom-named full-text search query to perform searches. This example uses 'CustomProductFulltextQuery' to search for 'Hot sauce'. ```graphql query { CustomProductFulltextQuery(phrase: "Hot sauce", sort: [{ score: ASC }]) { score product { name } } } ``` -------------------------------- ### Verify Database Aliases Configuration Source: https://neo4j.com/docs/operations-manual/current/tutorial/tutorial-composite-database Execute `SHOW ALIASES FOR DATABASES` to verify that all defined database aliases have been correctly configured and are associated with their respective databases. ```cypher SHOW ALIASES FOR DATABASES; ``` -------------------------------- ### Create Nodes and Relationship Source: https://neo4j.com/docs/go-manual/current Use ExecuteQuery to create two Person nodes and a KNOWS relationship. Parameters should be passed as keyword arguments using a map. ```go result, err := neo4j.ExecuteQuery(ctx, driver, " CREATE (a:Person {name: $name}) CREATE (b:Person {name: $friendName}) CREATE (a)-[:KNOWS]->(b) ", map[string]any{ "name": "Alice", "friendName": "David", }, neo4j.EagerResultTransformer, neo4j.ExecuteQueryWithDatabase("")) if err != nil { panic(err) } summary := result.Summary fmt.Printf("Created %v nodes in %+v.\n", summary.Counters().NodesCreated(), summary.ResultAvailableAfter()) ``` -------------------------------- ### Create Full-Text Index with Options Source: https://neo4j.com/docs/cypher-cheat-sheet/current Creates a full-text index with custom configuration options, such as specifying the text analyzer and setting eventual consistency. ```cypher CREATE FULLTEXT INDEX $name FOR (n:Employee|Manager) ON EACH [n.peerReviews] OPTIONS { indexConfig: { `fulltext.analyzer`: 'english', `fulltext.eventually_consistent`: true } } ``` -------------------------------- ### Show all indexes Source: https://neo4j.com/docs/cypher-cheat-sheet/current The SHOW command displays database metadata. This basic form returns default columns for indexes. ```cypher SHOW INDEXES ``` -------------------------------- ### Ordering and Pagination with WITH Source: https://neo4j.com/docs/cypher-cheat-sheet/current Applies ordering and pagination (LIMIT, SKIP) to results using WITH clauses before further processing. ```cypher MATCH (c:Customer)-[:BUYS]->(p:Product) WITH c, sum(p.price) AS totalSpent ORDER BY totalSpent DESC LIMIT 3 SET c.topSpender = true RETURN c.firstName AS customer, totalSpent, c.topSpender AS topSpender ``` -------------------------------- ### Get List Size with size() Source: https://neo4j.com/docs/cypher-cheat-sheet/current The `size()` function returns the number of elements in a list. ```cypher RETURN size(['Alice', 'Bob']) ``` -------------------------------- ### Extract substring with substring() Source: https://neo4j.com/docs/cypher-cheat-sheet/current Returns a portion of a string, starting at a specified index and with an optional length. ```cypher RETURN substring('hello', 1, 3), substring('hello', 2) ``` -------------------------------- ### Create Nodes and Relationship Source: https://neo4j.com/docs/dotnet-manual/current Use `IDriver.ExecutableQuery()` to create nodes and relationships. Always use placeholders and `WithParameters()` for security and clarity. Specify the database using `WithConfig()`. ```csharp var result = await driver.ExecutableQuery(@" CREATE (a:Person {name: $name}) CREATE (b:Person {name: $friendName}) CREATE (a)-[:KNOWS]->(b) ") .WithParameters(new { name = "Alice", friendName = "David" }) .WithConfig(new QueryConfig(database: "")) .ExecuteAsync(); // Summary information var summary = result.Summary; Console.WriteLine($"Created {summary.Counters.NodesCreated} nodes in {summary.ResultAvailableAfter.Milliseconds} ms."); ``` -------------------------------- ### MERGE a relationship Source: https://neo4j.com/docs/cypher-cheat-sheet/current This example merges a relationship of type 'ACTED_IN' between two 'Person' and 'Movie' nodes. ```cypher MATCH (charlie:Person {name: 'Charlie Sheen'}), (wallStreet:Movie {title: 'Wall Street'}) MERGE (charlie)-[r:ACTED_IN]->(wallStreet) RETURN charlie.name AS name, type(r) AS newRel, wallStreet.title AS title ``` -------------------------------- ### Create or Replace Database Source: https://neo4j.com/docs/cypher-cheat-sheet/current Creates a standard database with the specified name. If a database with that name already exists, it will be dropped and recreated. Use with caution to avoid data loss. ```cypher CREATE OR REPLACE DATABASE `database-name` ``` -------------------------------- ### Show All Databases Source: https://neo4j.com/docs/operations-manual/current/tutorial/tutorial-composite-database Lists all databases currently available in the Neo4j instance, including their status and configuration. ```cypher SHOW DATABASES; ``` -------------------------------- ### Get Path Length with length() Source: https://neo4j.com/docs/cypher-cheat-sheet/current The `length()` function calculates the number of nodes and relationships in a path. ```cypher MATCH p = (a)-->()-->(c) WHERE a.name = 'Alice' RETURN length(p) ``` -------------------------------- ### Create Indexes and Constraints for Full Import Source: https://neo4j.com/docs/operations-manual/current/tools/neo4j-admin/neo4j-admin-import Example Cypher script for creating indexes and constraints during a full import. This is supported for Neo4j versions 5.24 and later with Cypher 5 or 25. ```cypher CREATE INDEX PersonNameIndex IF NOT EXISTS FOR (p:Person) ON (p.name); CREATE CONSTRAINT PersonAgeConstraint IF NOT EXISTS FOR (c:Person) REQUIRE c.age IS :: INTEGER; CREATE CONSTRAINT PersonAgeRequiredConstraint IF NOT EXISTS FOR (c:Person) REQUIRE c.age IS NOT NULL; ``` -------------------------------- ### Get Relationships from a Path in Cypher Source: https://neo4j.com/docs/cypher-cheat-sheet/current Use the `relationships()` function to extract all relationships from a given path. ```cypher MATCH p = (a)-->(b)-->(c) WHERE a.name = 'Alice' AND c.name = 'Eskil' RETURN relationships(p) ``` -------------------------------- ### Get Nodes from a Path in Cypher Source: https://neo4j.com/docs/cypher-cheat-sheet/current Use the `nodes()` function to extract all nodes from a given path. ```cypher MATCH p = (a)-->(b)-->(c) WHERE a.name = 'Alice' AND c.name = 'Eskil' RETURN nodes(p) ``` -------------------------------- ### Connect to Neo4j database Source: https://neo4j.com/docs/python-manual/current Connect to a Neo4j database by creating a `Driver` instance with a URI and authentication token. Use `.verify_connectivity()` to check the connection. ```python from neo4j import GraphDatabase # URI examples: "neo4j://localhost", "neo4j+s://xxx.databases.neo4j.io" URI = "" AUTH = ("", "") with GraphDatabase.driver(URI, auth=AUTH) as driver: driver.verify_connectivity() ``` -------------------------------- ### Retrieve All Person Nodes Source: https://neo4j.com/docs/getting-started/cypher-intro Example of how to match and return all nodes with the 'Person' label using a node variable. ```cypher MATCH (p:Person) RETURN p ``` -------------------------------- ### Importing Compressed Files (zip and gzip) Source: https://neo4j.com/docs/operations-manual/current/tools/neo4j-admin/neo4j-admin-import The neo4j-admin import tool supports files compressed with `zip` or `gzip`. Ensure each compressed file contains only a single data file. ```bash neo4j_home$ ls import actors-header.csv actors.csv.zip movies-header.csv movies.csv.gz roles-header.csv roles.csv.gz ``` -------------------------------- ### Get Current Local Time Source: https://neo4j.com/docs/cypher-cheat-sheet/current Returns the current LOCAL TIME instant using the transaction clock. ```cypher RETURN time() AS currentTime ``` -------------------------------- ### Create a New Database Source: https://neo4j.com/docs/operations-manual/current/tutorial/tutorial-composite-database Use this command to create a new, standard database within your Neo4j instance. Repeat for each required database. ```cypher CREATE DATABASE db0; ``` ```cypher CREATE DATABASE db1; ``` ```cypher CREATE DATABASE db2; ``` -------------------------------- ### Get Relationship Type with type() Source: https://neo4j.com/docs/cypher-cheat-sheet/current The `type()` function returns the string name of a relationship's type. ```cypher MATCH (n)-[r]->() WHERE n.name = 'Alice' RETURN type(r) ``` -------------------------------- ### Show AUTH RULES as Commands Source: https://neo4j.com/docs/cypher-cheat-sheet/current Displays all existing authentication rules formatted as Cypher commands for recreation. ```cypher SHOW AUTH RULES AS COMMANDS ``` -------------------------------- ### Get Node/Relationship Properties with properties() Source: https://neo4j.com/docs/cypher-cheat-sheet/current The `properties()` function returns a map containing all properties of a node or relationship. ```cypher CREATE (p:Person {name: 'Stefan', city: 'Berlin'}) RETURN properties(p) ``` -------------------------------- ### Create ZONED DATETIME from Epoch seconds using datetime.fromEpoch() Source: https://neo4j.com/docs/cypher-cheat-sheet/current Creates a ZONED DATETIME instant from the number of seconds and nanoseconds since the Unix epoch. ```cypher WITH datetime.fromEpoch(1683000000, 123456789) AS dateTimeFromEpoch RETURN dateTimeFromEpoch ``` -------------------------------- ### Get End Node of Relationship with endNode() Source: https://neo4j.com/docs/cypher-cheat-sheet/current The `endNode()` function retrieves the node at the end of a specified relationship. ```cypher MATCH (x:Developer)-[r]-() RETURN endNode(r) ``` -------------------------------- ### Create LOCAL TIME using localtime() Source: https://neo4j.com/docs/cypher-cheat-sheet/current Creates a LOCAL TIME instant. ```cypher RETURN localtime() AS now ``` -------------------------------- ### Get Labels of a Node in Cypher Source: https://neo4j.com/docs/cypher-cheat-sheet/current Use the `labels()` function to retrieve a list of all labels associated with a node. ```cypher MATCH (a) WHERE a.name = 'Alice' RETURN labels(a) ``` -------------------------------- ### Get All Graph Names Source: https://neo4j.com/docs/cypher-cheat-sheet/current Returns a list of all graph names in a composite database. Only supported on composite databases. ```cypher RETURN graph.names() AS name ``` -------------------------------- ### Create Indexes and Graph Type for Full Import (2026.05+) Source: https://neo4j.com/docs/operations-manual/current/tools/neo4j-admin/neo4j-admin-import Example Cypher script demonstrating the creation of an index and setting a graph type during a full import. This feature is available from Neo4j 2026.05 with Cypher 25. Only 'SET' operations are supported for graph types in full imports. ```cypher CYPHER 25 CREATE INDEX PersonNameIndex IF NOT EXISTS FOR (p:Person) ON (p.name); ALTER CURRENT GRAPH TYPE SET { (p: person => { age :: INTEGER NOT NULL }) }; ``` -------------------------------- ### Import Libraries Source: https://neo4j.com/docs/graph-data-science-client/current/tutorials/centrality-algorithms Imports the pandas library for data manipulation and GraphDataScience for interacting with Neo4j. Ensure these are installed before running. ```python import os import pandas as pd from graphdatascience import GraphDataScience ``` -------------------------------- ### Incremental Database Import Syntax Source: https://neo4j.com/docs/operations-manual/current/tools/neo4j-admin/neo4j-admin-import Provides the general syntax for performing an incremental import into an existing Neo4j database. This command requires the --force option and is typically run on a stopped database, though stages can allow for read-only operation. ```bash neo4j-admin database import incremental [-h] [--expand-commands] [--force] [--update-all-matching-relationships] [--verbose] [--auto-skip-subsequent-headers[=true|false]] [--compress [=true|false]] [--dry-run[=true|false]] [--ignore-empty-strings[=true|false]] [--ignore-extra-columns[=true|false]] [--legacy-style-quoting[=true|false]] [--normalize-types[=true|false]] [--profile[=true|false]] [--skip-bad-entries-logging[=true|false]] [--skip-bad-relationships [=true|false]] [--skip-duplicate-nodes[=true|false]] [--strict[=true|false]] [--trim-strings[=true|false]] [--additional-config=] [--array-delimiter=] [--bad-tolerance=] [--delimiter=] [--high-parallel-io=on|off|auto] [--id-type=string|integer|actual] [--input-encoding=] [--input-type=csv|parquet] [--max-off-heap-memory=] [--path-pattern-style=regex|glob|none] [--profile-results-path=] [--property-shard-count=] [--quote=] [--read-buffer-size=] [--report-file=] [--schema=] [--stage=all|prepare|build|merge] [--target-format=] [--target-location=] [--temp-path=] [--threads=] [--vector-delimiter=] [--nodes=[