diff --git a/.gitignore b/.gitignore index cb919304f..98fff872e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ build.log .idea/ *.iml package-lock.json +.claude/ diff --git a/antora.yml b/antora.yml index 6bb57f81c..07ca646a2 100644 --- a/antora.yml +++ b/antora.yml @@ -4,6 +4,7 @@ version: '5' start_page: ROOT:introduction/index.adoc nav: - modules/ROOT/content-nav.adoc +- modules/cheat-sheet/content-nav.adoc asciidoc: attributes: neo4j-version: '2026.04' diff --git a/cheat-sheet-preview.yml b/cheat-sheet-preview.yml new file mode 100644 index 000000000..dd4f2b4b7 --- /dev/null +++ b/cheat-sheet-preview.yml @@ -0,0 +1,74 @@ +site: + title: Neo4j Documentation Cheat Sheet + url: https://neo4j.com/docs + start_page: cypher-cheat-sheet:ROOT:index.adoc + +content: + sources: + - url: ./ + branches: HEAD + +ui: + bundle: + url: https://static-content.neo4j.com/build/ui-bundle-latest.zip + snapshot: true + output_dir: /assets + +urls: + html_extension_style: indexify + +output: + dir: ./build/docs + +antora: + extensions: + - require: "@neo4j-antora/antora-modify-sitemaps" + sitemap_version: '5' + sitemap_loc_version: 'current' + move_sitemaps_to_components: true + +asciidoc: + extensions: + - "@neo4j-documentation/remote-include" + - "@neo4j-documentation/macros" + - "@neo4j-antora/antora-add-notes" + attributes: + page-theme: cheat-sheet + page-type: Docs + page-search-type: Docs + page-search-site: Reference Docs + page-canonical-root: /docs + page-pagination: false + page-no-canonical: true + page-origin-private: true + page-no-toolbar: true + page-hide-toc: false + page-mixpanel: 4bfb2414ab973c741b6f067bf06d5575 + includePDF: false + nonhtmloutput: "" + experimental: '' + copyright: 2025 + common-license-page-uri: https://neo4j.com/docs/license/ + neo4j-docs-base-uri: https://neo4j.com/docs + github-raw-page-uri: https://raw.githubusercontent.com/neo4j + page-cheatsheet-product: Cypher + page-cheatsheet-products: + - name: 'All' + class: 'all' + default: true + - name: 'Neo4j Community Edition' + class: 'neo4j-ce' + - name: 'Neo4j Enterprise Edition' + class: 'neo4j-ee' + - name: 'AuraDB Free' + class: 'aura-dbf' + - name: 'AuraDB Professional' + class: 'aura-dbp' + - name: 'AuraDB Business Critical' + class: 'aura-dbc' + - name: 'AuraDB Virtual Dedicated Cloud' + class: 'aura-dbe' + - name: 'AuraDS Professional' + class: 'aura-dsp' + - name: 'AuraDS Enterprise' + class: 'aura-dse' diff --git a/cheat-sheet-publish.yml b/cheat-sheet-publish.yml new file mode 100644 index 000000000..cbf1d8dc2 --- /dev/null +++ b/cheat-sheet-publish.yml @@ -0,0 +1,69 @@ +site: + title: Neo4j Documentation Cheat Sheet + url: https://neo4j.com/docs + start_page: cypher-cheat-sheet:ROOT:index.adoc + +content: + sources: + - url: ./ + branches: ['4.4', 'HEAD', 'cypher-25'] + +ui: + bundle: + url: https://static-content.neo4j.com/build/ui-bundle-latest.zip + snapshot: true + output_dir: /assets + +output: + dir: ./build/docs + +urls: + html_extension_style: indexify + +asciidoc: + extensions: + - "@neo4j-documentation/remote-include" + - "@neo4j-documentation/macros" + - "@neo4j-antora/antora-add-notes" + - "@neo4j-antora/antora-page-roles" + attributes: + page-theme: cheat-sheet + page-type: Docs + page-search-type: Docs + page-search-site: Reference Docs + page-canonical-root: /docs + page-pagination: false + page-no-canonical: true + page-origin-private: true + page-no-toolbar: true + page-hide-toc: false + page-publish: true + page-mixpanel: 4bfb2414ab973c741b6f067bf06d5575 + includePDF: false + nonhtmloutput: "" + experimental: '' + copyright: 2025 + common-license-page-uri: https://neo4j.com/docs/license/ + github-raw-page-uri: https://raw.githubusercontent.com/neo4j + neo4j-docs-base-uri: /docs + page-cheatsheet-product: Cypher + page-cheatsheet-products: + - name: 'All' + class: 'all' + default: true + - name: 'Neo4j Community Edition' + class: 'neo4j-ce' + - name: 'Neo4j Enterprise Edition' + class: 'neo4j-ee' + - name: 'AuraDB Free' + class: 'aura-dbf' + - name: 'AuraDB Professional' + class: 'aura-dbp' + - name: 'AuraDB Business Critical' + class: 'aura-dbc' + - name: 'AuraDB Virtual Dedicated Cloud' + class: 'aura-dbe' + - name: 'AuraDS Professional' + class: 'aura-dsp' + - name: 'AuraDS Enterprise' + class: 'aura-dse' diff --git a/modules/cheat-sheet/content-nav.adoc b/modules/cheat-sheet/content-nav.adoc new file mode 100644 index 000000000..f74eadcee --- /dev/null +++ b/modules/cheat-sheet/content-nav.adoc @@ -0,0 +1 @@ +* xref:index.adoc[] \ No newline at end of file diff --git a/modules/cheat-sheet/examples/artists-fieldterminator.csv b/modules/cheat-sheet/examples/artists-fieldterminator.csv new file mode 100644 index 000000000..be3b6eabf --- /dev/null +++ b/modules/cheat-sheet/examples/artists-fieldterminator.csv @@ -0,0 +1,4 @@ +1;ABBA;1992 +2;Roxette;1986 +3;Europe;1979 +4;The Cardigans;1992 diff --git a/modules/cheat-sheet/examples/artists-with-headers.csv b/modules/cheat-sheet/examples/artists-with-headers.csv new file mode 100644 index 000000000..52814fe62 --- /dev/null +++ b/modules/cheat-sheet/examples/artists-with-headers.csv @@ -0,0 +1,5 @@ +Id,Name,Year +1,ABBA,1992 +2,Roxette,1986 +3,Europe,1979 +4,The Cardigans,1992 diff --git a/modules/cheat-sheet/examples/artists.csv b/modules/cheat-sheet/examples/artists.csv new file mode 100644 index 000000000..9ef4ddf39 --- /dev/null +++ b/modules/cheat-sheet/examples/artists.csv @@ -0,0 +1,4 @@ +1,ABBA,1992 +2,Roxette,1986 +3,Europe,1979 +4,The Cardigans,1992 diff --git a/modules/cheat-sheet/pages/aggregating-functions.adoc b/modules/cheat-sheet/pages/aggregating-functions.adoc new file mode 100644 index 000000000..95eb67c6c --- /dev/null +++ b/modules/cheat-sheet/pages/aggregating-functions.adoc @@ -0,0 +1,106 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/aggregating/[Aggregating functions^] + + +==== +include::ROOT:functions/aggregating.adoc[tag=functions_aggregating_avg] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/aggregating/#functions-avg[`avg()`^] function returns the average of a set of `INTEGER` or `FLOAT` values. +==== + +==== +include::ROOT:functions/aggregating.adoc[tag=functions_aggregating_duration_avg] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/aggregating/#functions-avg-duration[`avg()` duration^] function returns the average of a set of `DURATION` values. +==== + + +==== +include::ROOT:functions/aggregating.adoc[tag=functions_aggregating_collect] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/aggregating/#functions-collect[`collect()`^] function returns a single aggregated list containing the non-`null` values returned by an expression. +==== + + +==== +include::ROOT:functions/aggregating.adoc[tag=functions_aggregating_count] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/aggregating/#functions-count[`count()`^] function returns the number of values or rows. +When `count(*)` is used, the function returns the number of matching rows. +==== + + +==== +include::ROOT:functions/aggregating.adoc[tag=functions_aggregating_count_as_expression] + +[.description] +The `count()` function can also be passed an expression. +If so, it returns the number of non-`null` values returned by the given expression. +==== + +==== +include::ROOT:functions/aggregating.adoc[tag=functions_aggregating_max] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/aggregating/#functions-max[`max()`^] function returns the maximum value in a set of values. +==== + +==== +include::ROOT:functions/aggregating.adoc[tag=functions_aggregating_min] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/aggregating/#functions-min[`min()`^] function returns the minimum value in a set of values. +==== + + +==== +include::ROOT:functions/aggregating.adoc[tag=functions_aggregating_percentile_cont] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/aggregating/#functions-percentilecont[`percentileCont()`^] function returns the percentile of the given value over a group, with a percentile from `0.0` to `1.0`. +It uses a linear interpolation method, calculating a weighted average between two values if the desired percentile lies between them. +==== + + +==== +include::ROOT:functions/aggregating.adoc[tag=functions_aggregating_percentile_disc] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/aggregating/#functions-percentiledisc[`percentileDisc()`^] function returns the percentile of the given value over a group, with a percentile from `0.0` to `1.0`. +It uses a rounding method and calculates the nearest value to the percentile. +==== + +==== +include::ROOT:functions/aggregating.adoc[tag=functions_aggregating_stdev] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/aggregating/#functions-stdev[`stDev()`^] function returns the standard deviation for the given value over a group. +It uses a standard two-pass method, with `N - 1` as the denominator, and should be used when taking a sample of the population for an unbiased estimate. +==== + + +==== +include::ROOT:functions/aggregating.adoc[tag=functions_aggregating_stdevp] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/aggregating/#functions-stdevp[`stDevP()`^] function returns the standard deviation for the given value over a group. +It uses a standard two-pass method, with `N` as the denominator, and should be used when calculating the standard deviation for an entire population. +==== + + +==== +include::ROOT:functions/aggregating.adoc[tag=functions_aggregating_sum] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/aggregating/#functions-sum[`sum()`^] function returns the sum of a set of numeric values. +==== + +==== +include::ROOT:functions/aggregating.adoc[tag=functions_aggregating_sum_duration] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/aggregating/#functions-sum-duration[`sum()` duration^] function returns the sum of a set of durations. +==== diff --git a/modules/cheat-sheet/pages/alias-management.adoc b/modules/cheat-sheet/pages/alias-management.adoc new file mode 100644 index 000000000..054298a97 --- /dev/null +++ b/modules/cheat-sheet/pages/alias-management.adoc @@ -0,0 +1,189 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/database-administration/aliases/manage-aliases-standard-databases/[ALIAS Management^] + + +==== +[source, cypher, role=noheader] +---- +SHOW ALIASES FOR DATABASE +---- + +[.description] +List all database aliases in Neo4j DBMS and information about them, returns only the default outputs (`name`, `composite`, `database`, `location`, `url`, and `user`). +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW ALIASES `database-alias` FOR DATABASE +---- + +[.description] +List the database alias named `database-alias` and the information about it. Returns only the default outputs (`name`, `composite`, `database`, `location`, `url`, and `user`). +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW ALIASES FOR DATABASE YIELD * +---- + +[.description] +List all database aliases in Neo4j DBMS and information about them. +==== + +==== +[source, cypher, role=noheader] +---- +SHOW ALIAS `remote-with-default-language` FOR DATABASE YIELD name, defaultLanguage +---- + +[.description] +Show the default Cypher version of a remote database alias. +==== + +==== +[source, cypher, role=noheader] +---- +CREATE ALIAS `database-alias` IF NOT EXISTS +FOR DATABASE `database-name` +---- + +[.description] +Create a local alias named `database-alias` for the database named `database-name`. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE OR REPLACE ALIAS `database-alias` +FOR DATABASE `database-name` +---- + +[.description] +Create or replace a local alias named `database-alias` for the database named `database-name`. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE ALIAS `database-alias` +FOR DATABASE `database-name` +PROPERTIES { property = $value } +---- + +[.description] +Database aliases can be given properties. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE ALIAS `database-alias` +FOR DATABASE `database-name` +AT $url +USER user_name +PASSWORD $password +---- + +[.description] +Create a remote alias named `database-alias` for the database named `database-name`. +==== + +==== +[source, cypher, role=noheader] +---- +CREATE ALIAS `remote-with-default-language` +FOR DATABASE `northwind-graph-2020` + AT "neo4j+s://location:7687" + USER alice + PASSWORD 'example_secret' + DEFAULT LANGUAGE CYPHER 25 +---- + +[.description] +Set the default Cypher version for a remote database alias when creating it. The available versions are `CYPHER 5` and `CYPHER 25`. +Local database aliases and database aliases in composite databases cannot be assigned a default Cypher version. +Local database aliases always have the Cypher version of their target database and database aliases in composite databases always have the Cypher version of the composite database they belong to. +==== + +==== +[source, cypher, role=noheader] +---- +CREATE ALIAS `composite-database-name`.`alias-in-composite-name` +FOR DATABASE `database-name` +AT $url +USER user_name +PASSWORD $password + +---- + +[.description] +Create a remote alias named `alias-in-composite-name` as a constituent alias in the composite database named `composite-database-name` for the database with name `database-name`. +==== + + +==== +[source, cypher, role=noheader] +---- +ALTER ALIAS `database-alias` IF EXISTS +SET DATABASE TARGET `database-name` +---- + +[.description] +Alter the alias named `database-alias` to target the database named `database-name`. +==== + + +==== +[source, cypher, role=noheader] +---- +ALTER ALIAS `remote-database-alias` IF EXISTS +SET DATABASE +USER user_name +PASSWORD $password +---- + +[.description] +Alter the remote alias named `remote-database-alias`, set the username (`user_name`) and the password. +==== + + +==== +[source, cypher, role=noheader] +---- +ALTER ALIAS `database-alias` +SET DATABASE PROPERTIES { key: value } +---- + +[.description] +Update the properties for the database alias named `database-alias`. +==== + +==== +[source, cypher, role=noheader] +---- +ALTER ALIAS `remote-with-default-language` SET DATABASE DEFAULT LANGUAGE CYPHER 25 +---- + +[.description] +Alter the default Cypher version of a remote database alias. +The available versions are `CYPHER 25` and `CYPHER 5`. +It is not possible to alter the default Cypher version of a local database alias or an alias belonging to a composite database. +Local database aliases always have the Cypher version of their target database and aliases belonging to composite databases always have the Cypher version of the composite database. +==== + +==== +[source, cypher, role=noheader] +---- +DROP ALIAS `database-alias` IF EXISTS FOR DATABASE +---- + +[.description] +Delete the alias named `database-alias`. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/boolean-operators.adoc b/modules/cheat-sheet/pages/boolean-operators.adoc new file mode 100644 index 000000000..ba214e6f5 --- /dev/null +++ b/modules/cheat-sheet/pages/boolean-operators.adoc @@ -0,0 +1,31 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/expressions/predicates/#boolean-operators[Boolean operators^] + +==== +include::ROOT:expressions/predicates/boolean-operators.adoc[tag=expressions_predicates_boolean_operators_and] + +[.description] +The `AND` operator is used to combine multiple boolean expressions, returning `true` only if all conditions are true. +==== + +==== +include::ROOT:expressions/predicates/boolean-operators.adoc[tag=expressions_predicates_boolean_operators_or] + +[.description] +The `OR` operator is used to combine multiple boolean expressions, returning `true` if at least one of the conditions is true. +==== + + +==== +include::ROOT:expressions/predicates/boolean-operators.adoc[tag=expressions_predicates_boolean_operators_xor] + +[.description] +The `XOR` operator returns `true` if exactly one of the two boolean expressions is true, but not both. +==== + +==== +include::ROOT:expressions/predicates/boolean-operators.adoc[tag=expressions_predicates_boolean_operators_not] + +[.description] +The `NOT` operator negates a boolean expression, returning `true` if the expression is false and `false` if it is true. +==== + diff --git a/modules/cheat-sheet/pages/call-procedure.adoc b/modules/cheat-sheet/pages/call-procedure.adoc new file mode 100644 index 000000000..bb3e1e50d --- /dev/null +++ b/modules/cheat-sheet/pages/call-procedure.adoc @@ -0,0 +1,60 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/call/[CALL procedure^] + + +==== +[source, cypher, role=noheader] +---- +CALL db.labels() YIELD label +---- + +[.description] +Standalone call to the procedure link:{neo4j-docs-base-uri}/operations-manual/current/reference/procedures/#procedure_db_labels[`db.labels`^] to list all labels used in the database. Note that required procedure arguments are given explicitly in brackets after the procedure name. +==== + +==== +[source, cypher, role=noheader] +---- +MATCH (n) +OPTIONAL CALL apoc.neighbors.tohop(n, "KNOWS>", 1) +YIELD node +RETURN n.name AS name, collect(node.name) AS connections +---- + +[.description] +Optionally `CALL` a procedure. +Similar to `OPTIONAL MATCH`, any empty rows produced by the `OPTIONAL CALL` will return `null` and not affect the remainder of the procedure evaluation. +==== + + +==== +[source, cypher, role=noheader] +---- +CALL db.labels() YIELD * +---- + +[.description] +Standalone calls may use `YIELD *` to return all columns. +==== + + +==== +[source, cypher, role=noheader] +---- +CALL java.stored.procedureWithArgs +---- + +[.description] +Standalone calls may omit `YIELD` and also provide arguments implicitly via statement parameters, e.g. a standalone call requiring one argument input may be run by passing the parameter map `{input: 'foo'}`. +==== + + +==== +[source, cypher, role=noheader] +---- +CALL db.labels() YIELD label +RETURN count(label) AS db_labels +---- + +[.description] +Calls the built-in procedure `db.labels` inside a larger query to count all labels used in the database. Calls inside a larger query always requires passing arguments and naming results explicitly with `YIELD`. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/comparison-operators.adoc b/modules/cheat-sheet/pages/comparison-operators.adoc new file mode 100644 index 000000000..f737c26fb --- /dev/null +++ b/modules/cheat-sheet/pages/comparison-operators.adoc @@ -0,0 +1,63 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/expressions/predicates/#comparison-operators[Comparison operators^] + +==== +include::ROOT:expressions/predicates/comparison-operators.adoc[tag=expressions_predicates_comparison_operators_equality] + +[.description] +The equality operator `=` checks for equality between two values. +==== + +==== +include::ROOT:expressions/predicates/comparison-operators.adoc[tag=expressions_predicates_comparison_operators_inequality] + +[.description] +The inequality operator `<>` checks if two values are not equal. +==== + +==== +include::ROOT:expressions/predicates/comparison-operators.adoc[tag=expressions_predicates_comparison_operators_less_than] + +[.description] +The less than operator `<` returns `true` if the value on the left is less than the value on the right. +==== + + +==== +include::ROOT:expressions/predicates/comparison-operators.adoc[tag=expressions_predicates_comparison_operators_less_than_or_equal] + +[.description] +The less than or equal or operator `\<=` returns `true` if the value on the left is less than or equal to the value on the right. +==== + + +==== +include::ROOT:expressions/predicates/comparison-operators.adoc[tag=expressions_predicates_comparison_operators_greater_than] + +[.description] +The greater than operator `>` returns `true` if the value on the left is greater than the value on the right. +==== + + +==== +include::ROOT:expressions/predicates/comparison-operators.adoc[tag=expressions_predicates_comparison_operators_greater_than_or_equal] + +[.description] +The greater than or equal operator `>=` returns `true` if the value on the left is greater than the value on the right. +==== + + +==== +include::ROOT:expressions/predicates/comparison-operators.adoc[tag=expressions_predicates_comparison_operators_is_null] + +[.description] +The `IS NULL` operator returns `true` if the value is `NULL`, and `false` otherwise. +==== + + +==== +include::ROOT:expressions/predicates/comparison-operators.adoc[tag=expressions_predicates_comparison_operators_is_not_null] + +[.description] +The `IS NOT NULL` operator returns `true` if the value is not `NULL`, and `false` otherwise. +==== + diff --git a/modules/cheat-sheet/pages/conditional-expressions.adoc b/modules/cheat-sheet/pages/conditional-expressions.adoc new file mode 100644 index 000000000..37f3d6a58 --- /dev/null +++ b/modules/cheat-sheet/pages/conditional-expressions.adoc @@ -0,0 +1,39 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/expressions/conditional-expressions/[Conditional expressions(`CASE`)^] + +==== +include::ROOT:expressions/conditional-expressions.adoc[tag=expressions_conditional_expressions_simple] + +[.description] +The simple `CASE` form is used to compare a single expression against multiple values, and is analogous to the `switch` construct of programming languages. +The expressions are evaluated by the `WHEN` operator until a match is found. +If no match is found, the expression in the `ELSE` operator is returned. +If there is no `ELSE` case and no match is found, `null` will be returned. +==== + + +==== +include::ROOT:expressions/conditional-expressions.adoc[tag=expressions_conditional_expressions_extended_simple] + +[.description] +The extended simple `CASE` can use comparison operators. +==== + + +==== +include::ROOT:expressions/conditional-expressions.adoc[tag=expressions_conditional_expressions_generic] + +[.description] +The generic `CASE` expression supports multiple conditional statements, and is analogous to the `if-elseif-else` construct of programming languages. +Each row is evaluated in order until a `true` value is found. +If no match is found, the expression in the `ELSE` operator is returned. +If there is no `ELSE` case and no match is found, `null` will be returned. +==== + + + +==== +include::ROOT:expressions/conditional-expressions.adoc[tag=expressions_conditional_expressions_properties] + +[.description] +The results of a `CASE` expression can be used to set properties on a node or relationship. +==== diff --git a/modules/cheat-sheet/pages/constraint.adoc b/modules/cheat-sheet/pages/constraint.adoc new file mode 100644 index 000000000..66c4050a5 --- /dev/null +++ b/modules/cheat-sheet/pages/constraint.adoc @@ -0,0 +1,185 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/constraints/managing-constraints/[Constraints^] + + +==== +[source, cypher, role=noheader] +---- +SHOW ALL CONSTRAINTS +---- + +[.description] +List all constraints, returns only the default outputs (`id`, `name`, `type`, `entityType`, `labelsOrTypes`, `properties`, `ownedIndex`, and `propertyType`). +Can also be filtered on `NODE UNIQUENESS`, `RELATIONSHIP UNIQUENESS`, `UNIQUENESS`, `NODE EXISTENCE`, `RELATIONSHIP EXISTENCE`, `EXISTENCE`, `NODE PROPERTY TYPE`, `RELATIONSHIP PROPERTY TYPE`, `PROPERTY TYPE`, `NODE KEY`, `RELATIONSHIP KEY`, and `KEY`. +For more information, see link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/constraints/syntax/#list-constraints[Constraints -> Syntax -> SHOW CONSTRAINTS^]. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW CONSTRAINTS YIELD * +---- + +[.description] +List all constraints. For more information, see link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/constraints/managing-constraints/#list-constraints[Constraints -> Create, show, and drop constraints -> SHOW CONSTRAINTS^]. +==== + + +==== +[source, cypher, role=noheader] +---- +DROP CONSTRAINT constraint_name +---- + +[.description] +Drop the constraint with the name `constraint_name`, throws an error if the constraint does not exist. +==== + + +==== +[source, cypher, role=noheader] +---- +DROP CONSTRAINT $nameParam IF EXISTS +---- + +[.description] +Drop the constraint with the name given by the parameter `nameParam` if it exists, does nothing if it does not exist. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE CONSTRAINT constraint_name IF NOT EXISTS +FOR (p:Person) +REQUIRE p.name IS UNIQUE +---- + +[.description] +-- +Create a node property uniqueness constraint on the label `Person` and property `name`. Using the keyword `IF NOT EXISTS` makes the command idempotent, and no error will be thrown if an attempt is made to create the same constraint twice. If any other node with that label is updated or created with a name that already exists, the write operation will fail. + +Best practice is to always specify a sensible name when creating a constraint. +-- +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE CONSTRAINT constraint_name +FOR (p:Person) +REQUIRE (p.name, p.age) IS UNIQUE +---- + +[.description] +Create a node property uniqueness constraint on the label `Person` and properties `name` and `age`. An error will be thrown if an attempt is made to create the same constraint twice. If any node with that label is updated or created with a name and age combination that already exists, the write operation will fail. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE CONSTRAINT constraint_name +FOR ()-[r:LIKED]-() +REQUIRE r.when IS UNIQUE +---- + +[.description] +-- +Create a relationship property uniqueness constraint on the relationship type `LIKED` and property `when`. +If any other relationship with that relationship type is updated or created with a `when` property value that already exists, the write operation will fail. + +Best practice is to always specify a sensible name when creating a constraint. +-- +==== + + +[role=label--enterprise-edition label--aura-db-free label--aura-db-professional label--aura-db-enterprise label--aura-db-business-critical label--aura-ds-professional label--aura-ds-enterprise] +==== +[source, cypher, role=noheader] +---- +CREATE CONSTRAINT $nameParam +FOR (p:Person) +REQUIRE p.name IS NOT NULL +---- + +[.description] +Create a node property existence constraint with the name given by the parameter `nameParam` on the label `Person` and property `name`. If a node with that label is created without a `name` property, or if the `name` property on the existing node with the label `Person` is removed, the write operation will fail. +==== + + +[role=label--enterprise-edition label--aura-db-free label--aura-db-professional label--aura-db-enterprise label--aura-db-business-critical label--aura-ds-professional label--aura-ds-enterprise] +==== +[source, cypher, role=noheader] +---- +CREATE CONSTRAINT constraint_name +FOR ()-[r:LIKED]-() +REQUIRE r.when IS NOT NULL +---- + +[.description] +Create a relationship property existence constraint on the type `LIKED` and property `when`. If a relationship with that type is created without a `when` property, or if the property `when` is removed from an existing relationship with the type `LIKED`, the write operation will fail. +==== + + +[role=label--enterprise-edition label--aura-db-free label--aura-db-professional label--aura-db-enterprise label--aura-db-business-critical label--aura-ds-professional label--aura-ds-enterprise] +==== +[source, cypher, role=noheader] +---- +CREATE CONSTRAINT constraint_name +FOR (p:Person) +REQUIRE p.name IS :: STRING +---- + +[.description] +Create a node property type constraint on the label `Person` and property `name`, restricting the property to `STRING`. +If a node with that label is created with a `name` property of a different Cypher type, the write operation will fail. +==== + + +[role=label--enterprise-edition label--aura-db-free label--aura-db-professional label--aura-db-enterprise label--aura-db-business-critical label--aura-ds-professional label--aura-ds-enterprise] +==== +[source, cypher, role=noheader] +---- +CREATE CONSTRAINT constraint_name +FOR ()-[r:LIKED]-() +REQUIRE r.when IS :: DATE +---- + +[.description] +Create a relationship property type constraint on the type `LIKED` and property `when`, restricting the property to `DATE`. +If a relationship with that type is created with a `when` property of a different Cypher type, the write operation will fail. +==== + + +[role=label--enterprise-edition label--aura-db-free label--aura-db-professional label--aura-db-enterprise label--aura-db-business-critical label--aura-ds-professional label--aura-ds-enterprise] +==== +[source, cypher, role=noheader] +---- +CREATE CONSTRAINT constraint_name +FOR (p:Person) +REQUIRE (p.name, p.surname) IS NODE KEY +---- + +[.description] +Create a node key constraint on the label `Person` and properties `name` and `surname` with the name `constraint_name`. +If a node with that label is created without both the `name` and `surname` properties, or if the combination of the two is not unique, or if the `name` and/or `surname` properties on an existing node with the label `Person` is modified to violate these constraints, the write operation will fail. +==== + +[role=label--enterprise-edition label--aura-db-free label--aura-db-professional label--aura-db-enterprise label--aura-db-business-critical label--aura-ds-professional label--aura-ds-enterprise] +==== +[source, cypher, role=noheader] +---- +CREATE CONSTRAINT constraint_name +FOR ()-[r:KNOWS]-() +REQUIRE (r.since, r.isFriend) IS RELATIONSHIP KEY +---- + +[.description] +-- +Create a relationship key constraint with the name `constraint_name` on the relationship type `KNOWS` and properties `since` and `isFriend`. +If a relationship with that relationship type is created without both the `since` and `isFriend` properties, or if the combination of the two is not unique, the write operation will fail. +The write operation will also fail if the `since` and/or `isFriend` properties on an existing relationship with the relationship type `KNOWS` is modified to violate these constraints. +-- +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/create.adoc b/modules/cheat-sheet/pages/create.adoc new file mode 100644 index 000000000..c898ec9ae --- /dev/null +++ b/modules/cheat-sheet/pages/create.adoc @@ -0,0 +1,54 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/create/[CREATE^] + + + +==== +[source, cypher, role=noheader] +---- +CREATE (n:Label {name: $value}) +---- + +[.description] +Create a node with the given label and properties. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE (n:Label $map) +---- + +[.description] +Create a node with the given label and properties. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE (n:Label)-[r:TYPE]->(m:Label) +---- + +[.description] +Create a relationship with the given relationship type and direction; bind a variable `r` to it. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE (n:Label)-[:TYPE {name: $value}]->(m:Label) +---- + +[.description] +Create a relationship with the given type, direction, and properties. +==== + +==== +include::ROOT:clauses/create.adoc[tag=clauses_create_dynamic_create] + +[.description] +Node labels and relationship types can be referenced dynamically in expressions, parameters, and variables when merging nodes and relationships. +The expression must evaluate to a `STRING NOT NULL | LIST NOT NULL` value. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/cypher-query-versioning.adoc b/modules/cheat-sheet/pages/cypher-query-versioning.adoc new file mode 100644 index 000000000..0671b2653 --- /dev/null +++ b/modules/cheat-sheet/pages/cypher-query-versioning.adoc @@ -0,0 +1,17 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/queries/select-version/[Select Cypher version for queries^] + +==== +include::ROOT:queries/select-version.adoc[tag=queries_select_version_cypher_25] + +[.description] +Prepending a query with `CYPHER 25` ensures that the query will be executed using Cypher 25 as it exists in the version of Neo4j that the database is currently running, provided it is on Neo4j 2025.06 or later. +==== + +==== +include::ROOT:queries/select-version.adoc[tag=queries_select_version_cypher_5] + +[.description] +Selecting `CYPHER 5` ensures that the query will be executed using the Cypher 5 as it existed at the time of the Neo4j 2025.06 release. +Any changes introduced after the 2025.06 release will not affect the query. +==== + diff --git a/modules/cheat-sheet/pages/database-functions.adoc b/modules/cheat-sheet/pages/database-functions.adoc new file mode 100644 index 000000000..14ad7bb5f --- /dev/null +++ b/modules/cheat-sheet/pages/database-functions.adoc @@ -0,0 +1,9 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/database/[Database functions^] + +==== +include::ROOT:functions/database.adoc[tag=functions_database_name_from_element_id] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/database/#functions-database-nameFromElementId[`db.nameFromElementId()`^] function returns the name of a database to which the element id belongs. +The name of the database can only be returned if the provided element id belongs to a standard database in the DBMS. +==== diff --git a/modules/cheat-sheet/pages/database-management.adoc b/modules/cheat-sheet/pages/database-management.adoc new file mode 100644 index 000000000..ba4467506 --- /dev/null +++ b/modules/cheat-sheet/pages/database-management.adoc @@ -0,0 +1,290 @@ += link:{neo4j-docs-base-uri}/operations-manual/current/database-administration/standard-databases/manage-databases/[DATABASE Management^] + + +==== +[source, cypher, role=noheader] +---- +dba +`db1` +`database-name` +`database-name-123` +`database.name` +`database.name.123` +---- + +[.description] +-- +The naming rules for a database: + +* The character length of a database name must be at least `3` characters; and not more than `63` characters. +* The first character of a database name must be an ASCII alphabetic character. +* Subsequent characters must be ASCII alphabetic or numeric characters, dots or dashes; `[a..z][0..9].-`. +* Database names are case-insensitive and normalized to lowercase. +* Database names that begin with an underscore (`_`) or with the prefix `system` are reserved for internal use. + +Database names may include dots (`.`) without being quoted with backticks, although this behavior is deprecated as it may introduce ambiguity when addressing composite databases. +Naming a database `foo.bar.baz` is valid, but deprecated. `++`foo.bar.baz`++` is valid. +-- +==== + + + +==== +[source, cypher, role=noheader] +---- +SHOW DATABASES +---- + +[.description] +List all databases in Neo4j DBMS and information about them, returns only the default outputs (`name`, `type`, `aliases`, `access`, `address`, `role`, `writer`, `requestedStatus`, `currentStatus`, `statusMessage`, `default`, `home`, and `constituents`). +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW DATABASES YIELD * +---- + +[.description] +List all databases in Neo4j DBMS and information about them. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW DATABASES +YIELD name, currentStatus +WHERE name CONTAINS 'my' + AND currentStatus = 'online' +---- + +[.description] +List information about databases, filtered by `name` and `currentStatus` and further refined by conditions on these. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW DATABASE `database-name` YIELD * +---- + +[.description] +List information about the database `database-name`. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW DATABASES YIELD name, defaultLanguage +---- + +[.description] +List the default Cypher version of databases. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW DEFAULT DATABASE +---- + +[.description] +List information about the default database, for the Neo4j DBMS. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW HOME DATABASE +---- + +[.description] +List information about the current users home database. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +DROP DATABASE `database-name` IF EXISTS +---- + +[.description] +Delete the database `database-name`, if it exists. This command can delete both standard and composite databases. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +DROP COMPOSITE DATABASE `composite-database-name` +---- + +[.description] +Delete the database named `composite-database-name`. In case the given database name does not exist or is not composite, and error will be thrown. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +DROP DATABASE `database-name` CASCADE ALIASES +---- + +[.description] +Drop the database `database-name` and any database aliases referencing the database. +This command can drop both standard and composite databases. +For standard databases, the database aliases that will be dropped are any local database aliases targeting the database. +For composite databases, the database aliases that will be dropped are any constituent database aliases belonging to the composite database. + +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +CREATE DATABASE `database-name` IF NOT EXISTS +---- + +[.description] +Create a standard database named `database-name` if it does not already exist. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +CREATE OR REPLACE DATABASE `database-name` +---- + +[.description] +Create a standard database named `database-name`. If a database with that name exists, then the existing database is deleted and a new one created. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +CREATE DATABASE `topology-example` IF NOT EXISTS +TOPOLOGY 1 PRIMARY 0 SECONDARIES +---- + +[.description] +Create a standard database named `topology-example` in a cluster environment, to use 1 primary server and 0 secondary servers. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +CREATE COMPOSITE DATABASE `composite-database-name` +---- + +[.description] +Create a composite database named `composite-database-name`. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +CREATE [COMPOSITE] DATABASE actors DEFAULT LANGUAGE CYPHER 25 +---- + +[.description] +-- +Set the default Cypher version for a standard or composite database when creating it. +The available versions are `CYPHER 25` and `CYPHER 5`. +If not specified, the default language for the database is set to the default language of the DBMS. +-- +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +STOP DATABASE `database-name` +---- + +[.description] +Stop a database named `database-name`. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +START DATABASE `database-name` +---- + +[.description] +Start a database named `database-name`. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +ALTER DATABASE `database-name` IF EXISTS +SET ACCESS READ ONLY +---- + +[.description] +Modify a standard database named `database-name` to accept only read queries. +==== + +[role=label--enterprise-edition label--aura-db-free label--aura-db-professional label--aura-db-enterprise label--aura-db-business-critical label--aura-ds-professional label--aura-ds-enterprise] +==== +[source, cypher, role=noheader] +---- +ALTER DATABASE movies SET DEFAULT LANGUAGE CYPHER 25 +---- + +[.description] +Alter the default Cypher version of an existing standard or composite database. +The available versions are `CYPHER 25` and `CYPHER 5`. +==== + + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +ALTER DATABASE `database-name` IF EXISTS +SET ACCESS READ WRITE +---- + +[.description] +Modify a standard database named `database-name` to accept write and read queries. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +ALTER DATABASE `topology-example` +SET TOPOLOGY 1 PRIMARY 0 SECONDARIES +---- + +[.description] +Modify a standard database named `topology-example` in a cluster environment to use 1 primary server and 0 secondary servers. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +ALTER DATABASE `topology-example` +SET TOPOLOGY 1 PRIMARY +SET ACCESS READ ONLY +---- + +[.description] +Modify a standard database named `topology-example` in a cluster environment to use 1 primary servers and 0 secondary servers, and to only accept read queries. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/delete.adoc b/modules/cheat-sheet/pages/delete.adoc new file mode 100644 index 000000000..475eb5939 --- /dev/null +++ b/modules/cheat-sheet/pages/delete.adoc @@ -0,0 +1,92 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/delete/[DELETE^] + + + +==== +[source, cypher, role=noheader] +---- +MATCH (n:Label)-[r]->(m:Label) +WHERE r.id = 123 +DELETE r +---- + +[.description] +Delete a relationship. +==== + + +==== +[source, cypher, role=noheader] +---- +MATCH ()-[r]->() +DELETE r +---- + +[.description] +Delete all relationships. +==== + + +==== +[source, cypher, role=noheader] +---- +MATCH (n:Label) +WHERE n.id = 123 +DETACH DELETE n +---- + +[.description] +Delete a node and all relationships connected to it. +==== + + +==== +[source, cypher, role=noheader] +---- +MATCH (n:Label)-[r]-() +WHERE r.id = 123 AND n.id = 'abc' +DELETE n, r +---- + +[.description] +Delete a node and a relationship. An error will be thrown if the given node is attached to more than one relationship. +==== + + +==== +[source, cypher, role=noheader] +---- +MATCH (n1:Label)-[r {id: 123}]->(n2:Label) +CALL (n1) { + MATCH (n1)-[r1]-() + RETURN count(r1) AS rels1 +} +CALL (n2) { + MATCH (n2)-[r2]-() + RETURN count(r2) AS rels2 +} +DELETE r +RETURN + n1.name AS node1, rels1 - 1 AS relationships1, + n2.name AS node2, rels2 - 1 AS relationships2 +---- + +[.description] +-- +Delete a relationship and return the number of relationships for each node after the deletion. +This example uses a link:https://neo4j.com/docs/cypher-manual/current/subqueries/call-subquery/#variable-scope-clause[variable scope clause] (introduced in Neo4j 5.23) to import variables into the `CALL` subquery. +If you are using an older version of Neo4j, use an link:https://neo4j.com/docs/cypher-manual/current/subqueries/call-subquery/#importing-with[importing `WITH` clause] instead. +-- +==== + + +==== +[source, cypher, role=noheader] +---- +MATCH (n) +DETACH DELETE n +---- + +[.description] +Delete all nodes and relationships from the database. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/duration-functions.adoc b/modules/cheat-sheet/pages/duration-functions.adoc new file mode 100644 index 000000000..7c66c1a5b --- /dev/null +++ b/modules/cheat-sheet/pages/duration-functions.adoc @@ -0,0 +1,49 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/duration/[Duration functions^] + + + +==== +include::ROOT:functions/temporal/duration.adoc[tag=functions_duration] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/duration/#functions-duration[`duration()`^] function can construct a `DURATION` from a `MAP` of its components. +==== + +==== +include::ROOT:functions/temporal/duration.adoc[tag=functions_duration_from_string] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/duration/#functions-duration-create-string[`duration()` from a string^] function returns the `DURATION` value obtained by parsing a `STRING` representation of a temporal amount. +==== + + +==== +include::ROOT:functions/temporal/duration.adoc[tag=functions_duration_between] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/duration/#functions-duration-between[`duration.between()`^] function returns the `DURATION` value equal to the difference between the two given instants. +==== + + +==== +include::ROOT:functions/temporal/duration.adoc[tag=functions_duration_in_days] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/duration/#functions-duration-indays[`duration.inDays()`^] function returns the `DURATION` value equal to the difference in whole days or weeks between the two given instants. +==== + + +==== +include::ROOT:functions/temporal/duration.adoc[tag=functions_duration_in_months] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/duration/#functions-duration-inmonths[`duration.inMonths()`^] function returns the `DURATION` value equal to the difference in whole months between the two given instants. +==== + + +==== +include::ROOT:functions/temporal/duration.adoc[tag=functions_duration_in_seconds] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/duration/#functions-duration-inseconds[`duration.inSeconds()`^] function returns the `DURATION` value equal to the difference in seconds and nanoseconds between the two given instants. +==== diff --git a/modules/cheat-sheet/pages/finish.adoc b/modules/cheat-sheet/pages/finish.adoc new file mode 100644 index 000000000..039121af7 --- /dev/null +++ b/modules/cheat-sheet/pages/finish.adoc @@ -0,0 +1,11 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/finish/[FINISH^] + + + +==== +include::ROOT:clauses/finish.adoc[tag=clauses_finish_match] + +[.description] +A query ending in `FINISH` -- instead of `RETURN` -- has no result but executes all its side effects. +==== + diff --git a/modules/cheat-sheet/pages/fixed-length-paths.adoc b/modules/cheat-sheet/pages/fixed-length-paths.adoc new file mode 100644 index 000000000..767df3be9 --- /dev/null +++ b/modules/cheat-sheet/pages/fixed-length-paths.adoc @@ -0,0 +1,17 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/patterns/fixed-length-paths/[Fixed-length paths^] + + +==== +include::ROOT:patterns/fixed-length-paths.adoc[tag=patterns_fixed_length_paths_node_pattern] + +[.description] +Match a node pattern including a `WHERE` clause predicate. +==== + + +==== +include::ROOT:patterns/fixed-length-paths.adoc[tag=patterns_fixed_length_paths_path_pattern] + +[.description] +Match a fixed-length path pattern to paths in a graph. +==== diff --git a/modules/cheat-sheet/pages/foreach.adoc b/modules/cheat-sheet/pages/foreach.adoc new file mode 100644 index 000000000..a377125f6 --- /dev/null +++ b/modules/cheat-sheet/pages/foreach.adoc @@ -0,0 +1,25 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/foreach/[FOREACH^] + + + +==== +include::ROOT:clauses/foreach.adoc[tag=clauses_foreach_node] + +[.description] +`FOREACH` can be used to update data, such as executing update commands on elements in a path, or on a list created by aggregation. +This example sets the property `marked` to `true` on all nodes along a path. +==== + +==== +include::ROOT:clauses/foreach.adoc[tag=clauses_foreach_relationship] + +[.description] +This example sets the property `marked` to `true` on all relationships along a path. +==== + +==== +include::ROOT:clauses/foreach.adoc[tag=clauses_foreach_create] + +[.description] +This example creates a new node for each label in a list. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/full-text-index.adoc b/modules/cheat-sheet/pages/full-text-index.adoc new file mode 100644 index 000000000..37dbb76ba --- /dev/null +++ b/modules/cheat-sheet/pages/full-text-index.adoc @@ -0,0 +1,79 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/indexes/semantic-indexes/full-text-indexes/[Full-text indexes] + +==== +[source, cypher, role=noheader] +---- +CREATE FULLTEXT INDEX node_fulltext_index +FOR (n:Friend) ON EACH [n.name] +OPTIONS { + indexConfig: { + `fulltext.analyzer`: 'swedish' + } +} +---- + +[.description] +Create a fulltext index on nodes with the name `index_name` and analyzer `swedish`. +The other index settings will have their default values. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE FULLTEXT INDEX relationship_fulltext_index +FOR ()-[r:KNOWS]-() ON EACH [r.info, r.note] +OPTIONS { + indexConfig: { + `fulltext.analyzer`: 'english' + } +} +---- + +[.description] +Create a fulltext index on relationships with the name `index_name` and analyzer `english`. +The other index settings will have their default values. +==== + + +==== +[source, cypher, role=noheader] +---- +CALL db.index.fulltext.queryNodes("node_fulltext_index", "Alice") YIELD node, score +---- + +[.description] +Query a full-text index on nodes. +==== + + +==== +[source, cypher, role=noheader] +---- +CALL db.index.fulltext.queryRelationships("relationship_fulltext_index", "Alice") YIELD relationship, score +---- + +[.description] +Query a full-text index on relationships. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW FULLTEXT INDEXES +---- + +[.description] +List all full-text indexes. +==== + +==== +[source, cypher, role=noheader] +---- +DROP INDEX node_fulltext_index +---- + +[.description] +Drop a full-text index. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/graph-functions.adoc b/modules/cheat-sheet/pages/graph-functions.adoc new file mode 100644 index 000000000..6e029c7d8 --- /dev/null +++ b/modules/cheat-sheet/pages/graph-functions.adoc @@ -0,0 +1,36 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/graph/[Graph functions^] + + +==== +include::ROOT:functions/graph.adoc[tag=functions_graph_names] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/graph/#functions-graph-names[`graph.names()`^] function returns a list containing the names of all graphs on the current composite database. +It is only supported on link:{neo4j-docs-base-uri}/operations-manual/current/database-administration/composite-databases/concepts/[composite databases]. +==== + + +==== +include::ROOT:functions/graph.adoc[tag=functions_graph_properties_by_name] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/graph/#functions-graph-propertiesbyname[`graph.propertiesByName()`^] function returns a map containing the properties associated with the given graph. The properties are set on the link:{neo4j-docs-base-uri}/operations-manual/current/database-administration/aliases/manage-aliases-standard-databases/[alias] that adds the graph as a constituent of a composite database. +It is only supported on link:{neo4j-docs-base-uri}/operations-manual/current/database-administration/composite-databases/concepts/[composite databases]. +==== + +==== +include::ROOT:functions/graph.adoc[tag=functions_graph_by_name] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/graph/#functions-graph-byname[`graph.byName()`^] function resolves a constituent graph by name. +It is only supported in the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/use/[`USE`] clause on link:{neo4j-docs-base-uri}/operations-manual/current/database-administration/composite-databases/concepts/[composite databases]. +==== + + +==== +include::ROOT:functions/graph.adoc[tag=functions_graph_by_element_id] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/graph/#functions-graph-by-elementid[`graph.byElementId()`^] function is used in the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/use/[`USE`] clause to resolve a constituent graph to which a given element id belongs. +If the constituent database is not a standard database in the DBMS, an error will be thrown. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/immutable-privileges.adoc b/modules/cheat-sheet/pages/immutable-privileges.adoc new file mode 100644 index 000000000..feb0fb961 --- /dev/null +++ b/modules/cheat-sheet/pages/immutable-privileges.adoc @@ -0,0 +1,37 @@ +[role=label--enterprise-edition] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/privileges-immutable/[IMMUTABLE Privileges^] + +==== +[source, cypher, role=noheader] +---- +GRANT IMMUTABLE TRAVERSE +ON GRAPH * TO role_name +---- + +[.description] +Grant immutable `TRAVERSE` privilege on all graphs to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +DENY IMMUTABLE START +ON DATABASE * TO role_name +---- + +[.description] +Deny immutable `START` privilege to start all databases to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +REVOKE IMMUTABLE CREATE ROLE +ON DBMS FROM role_name +---- + +[.description] +Revoke immutable `CREATE ROLE` privilege from the specified role. When immutable is specified in conjunction with a `REVOKE` command, it will act as a filter and only remove the matching immutable privileges. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/index.adoc b/modules/cheat-sheet/pages/index.adoc new file mode 100644 index 000000000..f4c3d7e5b --- /dev/null +++ b/modules/cheat-sheet/pages/index.adoc @@ -0,0 +1,233 @@ += Cypher Cheat Sheet +:page-theme: cheat-sheet +:page-layout: cheat-sheet +:neo4j-docs-base-uri: https://neo4j.com/docs +:github-raw-page-uri: https://raw.githubusercontent.com/neo4j + + +== Read Query + +include::read-query-structure.adoc[leveloffset=2] + +include::match.adoc[leveloffset=2] + +include::optional-match.adoc[leveloffset=2] + +include::where.adoc[leveloffset=2] + +include::return.adoc[leveloffset=2] + +include::with.adoc[leveloffset=2] + +include::union.adoc[leveloffset=2] + + +== Write query + +include::write-only-query-structure.adoc[leveloffset=2] + +include::read-write-query-structure.adoc[leveloffset=2] + +include::create.adoc[leveloffset=2] + +include::set.adoc[leveloffset=2] + +include::merge.adoc[leveloffset=2] + +include::delete.adoc[leveloffset=2] + +include::remove.adoc[leveloffset=2] + +== Cypher query versioning + +include::cypher-query-versioning.adoc[leveloffset=2] + +== Patterns + +include::fixed-length-paths.adoc[leveloffset=2] + +include::variable-length-paths.adoc[leveloffset=2] + +include::non-linear-paths.adoc[leveloffset=2] + +include::shortest-paths.adoc[leveloffset=2] + +== Clauses + +include::call-procedure.adoc[leveloffset=2] + +include::finish.adoc[leveloffset=2] + +include::foreach.adoc[leveloffset=2] + +include::limit.adoc[leveloffset=2] + +include::load-csv.adoc[leveloffset=2] + +include::order-by.adoc[leveloffset=2] + +include::show-functions.adoc[leveloffset=2] + +include::show-procedures.adoc[leveloffset=2] + +include::show-settings.adoc[leveloffset=2] + +include::show-transactions.adoc[leveloffset=2] + +include::skip.adoc[leveloffset=2] + +include::terminate-transactions.adoc[leveloffset=2] + +include::unwind.adoc[leveloffset=2] + +include::use.adoc[leveloffset=2] + +== Subqueries + +include::subqueries-call.adoc[leveloffset=2] + +include::subqueries-call-in-transactions.adoc[leveloffset=2] + +include::subqueries-collect-count-exists.adoc[leveloffset=2] + +== Predicates + +include::boolean-operators.adoc[leveloffset=2] + +include::comparison-operators.adoc[leveloffset=2] + +include::label-expression-predicates.adoc[leveloffset=2] + +include::list-operators.adoc[leveloffset=2] + +include::path-pattern-expressions.adoc[leveloffset=2] + +include::string-operators.adoc[leveloffset=2] + +include::type-predicate-expressions.adoc[leveloffset=2] + + +== Expressions + +include::conditional-expressions.adoc[leveloffset=2] + +include::label-expressions.adoc[leveloffset=2] + +include::list-expressions.adoc[leveloffset=2] + +include::node-relationship-operators.adoc[leveloffset=2] + +include::mathematical-operators.adoc[leveloffset=2] + +include::map-expressions.adoc[leveloffset=2] + +include::string-concatenation-operators.adoc[leveloffset=2] + +include::temporal-operators.adoc[leveloffset=2] + + +== Functions + +include::aggregating-functions.adoc[leveloffset=2] + +include::database-functions.adoc[leveloffset=2] + +include::duration-functions.adoc[leveloffset=2] + +include::graph-functions.adoc[leveloffset=2] + +include::list-functions.adoc[leveloffset=2] + +include::mathematical-functions-numeric.adoc[leveloffset=2] + +include::mathematical-functions-logarithmic.adoc[leveloffset=2] + +include::mathematical-functions-trigonometric.adoc[leveloffset=2] + +include::predicate-functions.adoc[leveloffset=2] + +include::scalar-functions.adoc[leveloffset=2] + +include::string-functions.adoc[leveloffset=2] + +include::spatial-functions.adoc[leveloffset=2] + +include::temporal-functions.adoc[leveloffset=2] + +include::vector-functions.adoc[leveloffset=2] + +== Schema + +include::search-performance-index.adoc[leveloffset=2] + +include::full-text-index.adoc[leveloffset=2] + +include::vector-index.adoc[leveloffset=2] + +include::constraint.adoc[leveloffset=2] + + +== Performance + +include::performance.adoc[leveloffset=2] + + +== Database Management + +include::database-management.adoc[leveloffset=2] + +include::alias-management.adoc[leveloffset=2] + +include::server-management.adoc[leveloffset=2] + + +== Access Control + +include::user-management.adoc[leveloffset=2] + +include::role-management.adoc[leveloffset=2] + +include::show-privileges.adoc[leveloffset=2] + +include::show-supported-privileges.adoc[leveloffset=2] + +include::immutable-privileges.adoc[leveloffset=2] + +include::load-privileges.adoc[leveloffset=2] + + +== ON GRAPH + +include::on-graph-read-privileges.adoc[leveloffset=2] + +include::on-graph-write-privileges.adoc[leveloffset=2] + + +== ON DATABASE + +include::on-database-privileges.adoc[leveloffset=2] + +include::on-database-index-management-privileges.adoc[leveloffset=2] + +include::on-database-constraint-management-privileges.adoc[leveloffset=2] + +include::on-database-name-management-privileges.adoc[leveloffset=2] + +include::on-database-transaction-management-privileges.adoc[leveloffset=2] + + +== ON DBMS + +include::on-dbms-privileges.adoc[leveloffset=2] + +include::on-dbms-role-management-privileges.adoc[leveloffset=2] + +include::on-dbms-user-management-privileges.adoc[leveloffset=2] + +include::on-dbms-database-management-privileges.adoc[leveloffset=2] + +include::on-dbms-alias-management-privileges.adoc[leveloffset=2] + +include::on-dbms-role-management-privileges.adoc[leveloffset=2] + +include::on-dbms-privilege-management-privileges.adoc[leveloffset=2] diff --git a/modules/cheat-sheet/pages/label-expression-predicates.adoc b/modules/cheat-sheet/pages/label-expression-predicates.adoc new file mode 100644 index 000000000..078dbbc8b --- /dev/null +++ b/modules/cheat-sheet/pages/label-expression-predicates.adoc @@ -0,0 +1,15 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/expressions/predicates/#label-expression-predicates[Label expression predicates^] + +==== +include::ROOT:expressions/predicates/label-expression-predicates.adoc[tag=predicates_label_expression_predicates_test_node_label] + +[.description] +Use a colon (`:`) to verify that the labels of a node match a given label expression. +==== + +==== +include::ROOT:expressions/predicates/label-expression-predicates.adoc[tag=predicates_label_expression_predicates_test_relation_type] + +[.description] +Label expression predicate to test that the type of a relationship match a given label expression. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/label-expressions.adoc b/modules/cheat-sheet/pages/label-expressions.adoc new file mode 100644 index 000000000..c70d45834 --- /dev/null +++ b/modules/cheat-sheet/pages/label-expressions.adoc @@ -0,0 +1,25 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/patterns/reference/#label-expressions[Label expressions^] + +==== +include::ROOT:clauses/match.adoc[tag=clauses_match_label_expression_or] + +[.description] +Node pattern using the `OR` (`|`) label expression. +==== + +==== +include::ROOT:clauses/match.adoc[tag=clauses_match_label_expression_negation] + +[.description] +Node pattern using the negation (`!`) label expression. +==== + +==== +include::ROOT:clauses/match.adoc[tag=clauses_match_type_expression_or] + +[.description] +Relationship pattern using the `OR` (`|`) label expression. +As relationships can only have exactly one type each, `()-[:A&B]->()` will never match a relationship. +==== + + diff --git a/modules/cheat-sheet/pages/limit.adoc b/modules/cheat-sheet/pages/limit.adoc new file mode 100644 index 000000000..48c7b8d04 --- /dev/null +++ b/modules/cheat-sheet/pages/limit.adoc @@ -0,0 +1,17 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/limit/[LIMIT^] + +==== +include::ROOT:clauses/limit.adoc[tag=clauses_limit] + +[.description] +`LIMIT` constrains the number of returned rows. +It can be used in conjunction with link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/order-by/[`ORDER BY`] and link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/skip/[`SKIP`]. +==== + +==== +include::ROOT:clauses/limit.adoc[tag=clauses_limit_standalone] + +[.description] +`LIMIT` can be used as a standalone clause. +==== + diff --git a/modules/cheat-sheet/pages/list-expressions.adoc b/modules/cheat-sheet/pages/list-expressions.adoc new file mode 100644 index 000000000..be6323aff --- /dev/null +++ b/modules/cheat-sheet/pages/list-expressions.adoc @@ -0,0 +1,128 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/expressions/list-expressions[List expressions^] + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_element_access] + +[.description] +The subscript operator, `[]`, can be used to access specific elements in a `LIST`. +`[0]` refers to the first element in a `LIST`, `[1]` to the second, and so on. +`[-1]` refers to the last element in a `LIST`, `[-2]` to the penultimate element, and so on. +==== + + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_nested_list_access] + +[.description] +Access a `LIST` within a nested `LIST`. +==== + + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_nested_list_specific_element_access] + +[.description] +Access specific elements in a nested `LIST`. +==== + + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_slicing] + +[.description] +`LIST` values can be sliced if a range is provided within the subscript operator `[]`. +The bounds of the range are separated using two dots (`..`). +This allows for extracting a subset of a `LIST` rather than a single element. +List slicing is inclusive at the start of the range, but exclusive at the end (e.g. `list[start..end]` includes `start`, but excludes `end`). +==== + + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_negative_slicing] + +[.description] +Negative indexing in list slicing references elements from the end of the `LIST`; `..-1` excludes the last element, `..-2` excludes the last two elements, and so on. +==== + + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_slice_inner_list] + +[.description] +Slicing inner `LIST` values require two `[]` operators; the first `[]` accesses elements from the outer `LIST`, while the second slices or accesses elements from the inner `LIST`. +==== + + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_concatenation] + +[.description] +Cypher contains two list concatenation operators: `||` and `\+`. +They are functionally equivalent but `||` is GQL conformant and `+` is not. +==== + + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_add_elements] + +[.description] +The `+` operator can add elements to the beginning or end of a `LIST` value. +This is not possible using the `||` operator. +==== + + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_comprehension] + +[.description] +List comprehension is used to create new `LIST` values by iterating over existing `LIST` values and transforming the elements based on certain conditions or operations. +This process effectively maps each element in the original `LIST` to a new value. +The result is a new `LIST` that consists of the transformed elements. +==== + + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_comprehension_properties] + +[.description] +List comprehension using node properties. +==== + + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_comprehension_where] + +[.description] +List comprehension with a `WHERE` predicate. +==== + + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_comprehension_concatenation_remove_null] + +[.description] +List comprehension can be used to remove any unknown `NULL` values when concatenating `LIST` values. +==== + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_pattern_comprehension] + +[.description] +Pattern comprehension is used to create new `LIST` values by matching graph patterns and applying conditions to the matched elements, returning custom projections. +==== + + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_pattern_comprehension_where] + +[.description] +Pattern comprehension with a `WHERE` predicate. +==== + + +==== +include::ROOT:expressions/list-expressions.adoc[tag=expressions_list_pattern_comprehension_var_length] + +[.description] +Variable-length pattern comprehension. +==== diff --git a/modules/cheat-sheet/pages/list-functions.adoc b/modules/cheat-sheet/pages/list-functions.adoc new file mode 100644 index 000000000..a9cfd8d84 --- /dev/null +++ b/modules/cheat-sheet/pages/list-functions.adoc @@ -0,0 +1,97 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/list/[List functions^] + +==== +include::ROOT:functions/list.adoc[tag=functions_list_keys] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/list/#functions-keys[`keys()`^] function returns a `LIST` containing the `STRING` representations for all the property names of a `NODE`, `RELATIONSHIP`, or `MAP`. +==== + + +==== +include::ROOT:functions/list.adoc[tag=functions_list_labels] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/list/#functions-labels[`labels()`^] function returns a `LIST` containing the `STRING` representations for all the labels of a `NODE`. +==== + + +==== +include::ROOT:functions/list.adoc[tag=functions_list_nodes] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/list/#functions-nodes[`nodes()`^] function returns a `LIST` containing all the `NODE` values in a `PATH`. +==== + + +==== +include::ROOT:functions/list.adoc[tag=functions_list_range] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/list/#functions-range[`range()`^] function returns a `LIST` comprising all `INTEGER` values within a range bounded by a start value and an end value, where the difference step between any two consecutive values is constant; i.e. an arithmetic progression. +==== + + +==== +include::ROOT:functions/list.adoc[tag=functions_list_reduce] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/list/#functions-reduce[`reduce()`^] function returns the value resulting from the application of an expression on each successive element in a list in conjunction with the result of the computation thus far. +==== + +==== +include::ROOT:functions/list.adoc[tag=functions_list_relationships] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/list/#functions-relationships[`relationships()`^] function returns a `LIST` containing all the `RELATIONSHIP` values in a `PATH`. +==== + +==== +include::ROOT:functions/list.adoc[tag=functions_list_reverse] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/list/#functions-reverse-list[`reverse()`^] function returns a `LIST` in which the order of all elements in the given `LIST` have been reversed. +==== + +==== +include::ROOT:functions/list.adoc[tag=functions_list_tail] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/list/#functions-tail[`tail()`^] function returns a `LIST` containing all the elements, excluding the first one, from a given `LIST`. +==== + + +==== +include::ROOT:functions/list.adoc[tag=functions_list_to_boolean_list] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/list/#functions-tobooleanlist[`toBooleanList()`^] converts a `LIST` and returns a `LIST`. +If any values are not convertible to `BOOLEAN` they will be `null` in the `LIST` returned. +==== + + +==== +include::ROOT:functions/list.adoc[tag=functions_list_to_float_list] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/list/#functions-tofloatlist[`toFloatList()`^] converts a `LIST` of values and returns a `LIST`. +If any values are not convertible to `FLOAT` they will be `null` in the `LIST` returned. +==== + + +==== +include::ROOT:functions/list.adoc[tag=functions_list_to_integer_list] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/list/#functions-tointegerlist[`toIntegerList()`^] converts a `LIST` of values and returns a `LIST`. +If any values are not convertible to `INTEGER` they will be `null` in the `LIST` returned. +==== + + +==== +include::ROOT:functions/list.adoc[tag=functions_list_to_string_list] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/list/#functions-tostringlist[`toStringList()`^] converts a `LIST` of values and returns a `LIST`. +If any values are not convertible to `STRING` they will be `null` in the `LIST` returned. +==== diff --git a/modules/cheat-sheet/pages/list-operators.adoc b/modules/cheat-sheet/pages/list-operators.adoc new file mode 100644 index 000000000..a385c7e28 --- /dev/null +++ b/modules/cheat-sheet/pages/list-operators.adoc @@ -0,0 +1,31 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/expressions/predicates/#list-operators[List operators^] + +==== +include::ROOT:expressions/predicates/list-operators.adoc[tag=expressions_predicates_list_operators_in] + +[.description] +The `IN` operator checks if a value is present in a `LIST`. +==== + +==== +include::ROOT:expressions/predicates/list-operators.adoc[tag=expressions_predicates_list_operators_check_null] + +[.description] +To check if `NULL` is a member of a `LIST`, use the +link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/predicate/#functions-any[`any()`] function. +==== + +==== +include::ROOT:expressions/predicates/list-operators.adoc[tag=expressions_predicates_list_operators_nested_list] + +[.description] +When used with nested `LIST` values, the `IN` operator evaluates whether a `LIST` is an exact match to any of the nested `LIST` values that are part of an outer `LIST`. +Partial matches of individual elements within a nested `LIST` will return `false`. +==== + +==== +include::ROOT:expressions/predicates/list-operators.adoc[tag=expressions_predicates_list_operators_list_subset] + +[.description] +A subset check using the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/predicate/#functions-all[`all()`] function verifies if all elements of one `LIST` exist in another. +==== diff --git a/modules/cheat-sheet/pages/load-csv.adoc b/modules/cheat-sheet/pages/load-csv.adoc new file mode 100644 index 000000000..409fcabb2 --- /dev/null +++ b/modules/cheat-sheet/pages/load-csv.adoc @@ -0,0 +1,61 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/load-csv/[LOAD CSV^] + + +==== +include::ROOT:clauses/load-csv.adoc[tag=clauses_load_csv_local_files] + +[.description] +`LOAD CSV` is used to import data from CSV files into a Neo4j database. +This example imports the name and year information of artists from a local file. +==== + +==== +include::ROOT:clauses/load-csv.adoc[tag=clauses_load_csv_remote_locations] + +[.description] +Import artists name and year information from a remote file URL. +==== + +==== +include::ROOT:clauses/load-csv.adoc[tag=clauses_load_csv_dynamic_columns] + +[.description] +CSV columns can be referenced dynamically to map labels to nodes in the graph. +This enables flexible data handling, allowing labels to be be populated from CSV column values without manually specifying each entry. +==== + +==== +include::ROOT:clauses/load-csv.adoc[tag=clauses_load_csv_transactions] + +[.description] +Load a CSV file in several link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/subqueries/subqueries-in-transactions/[transactions]. +This example uses a link:https://neo4j.com/docs/cypher-manual/current/subqueries/call-subquery/#variable-scope-clause[variable scope clause] (introduced in Neo4j 5.23) to import variables into the `CALL` subquery. +==== + +==== +include::ROOT:clauses/load-csv.adoc[tag=clauses_load_csv_linenumber] + +[.description] +Access line numbers in a CSV with the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/load-csv/#functions-linenumber[`linenumber()`] function. +==== + +==== +include::ROOT:clauses/load-csv.adoc[tag=clauses_load_csv_file] + +[.description] +Access the CSV file path with the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/load-csv/#functions-file[`file()`] function. +==== + +==== +include::ROOT:clauses/load-csv.adoc[tag=clauses_load_csv_headers] + +[.description] +Load CSV data with headers. +==== + +==== +include::ROOT:clauses/load-csv.adoc[tag=clauses_load_csv_field_terminator] + +[.description] +Import a CSV using `;` as field delimiter. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/load-privileges.adoc b/modules/cheat-sheet/pages/load-privileges.adoc new file mode 100644 index 000000000..3a67c93a1 --- /dev/null +++ b/modules/cheat-sheet/pages/load-privileges.adoc @@ -0,0 +1,31 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/load-privileges/[Load Privileges^] + + +==== +[source, cypher, role=noheader] +---- +GRANT LOAD +ON ALL DATA +TO role_name +---- + +[.description] +-- +Grant `LOAD` privilege on `ALL DATA` to allow loading all data to the specified role. +-- +==== + +==== +[source, cypher, role=noheader] +---- +DENY LOAD +ON CIDR "127.0.0.1/32" +TO role_name +---- + +[.description] +-- +Deny `LOAD` privilege on CIDR range `127.0.0.1/32` to disallow loading data from sources in that range to the specified role. +-- +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/map-expressions.adoc b/modules/cheat-sheet/pages/map-expressions.adoc new file mode 100644 index 000000000..3a7203e07 --- /dev/null +++ b/modules/cheat-sheet/pages/map-expressions.adoc @@ -0,0 +1,67 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/expressions/map-expressions[Map expressions^] + + +==== +include::ROOT:expressions/map-expressions.adoc[tag=expressions_map_static_access] + +[.description] +`MAP` values can be accessed statically by specifying a key after the `.` operator. +==== + + +==== +include::ROOT:expressions/map-expressions.adoc[tag=expressions_map_static_access_nested_map] + +[.description] +To statically access a value in a nested `MAP`, use chained `.` operators. +Each `.` operator traverses one level deeper into the nested structure. +==== + + +==== +include::ROOT:expressions/map-expressions.adoc[tag=expressions_map_dynamic_access] + +[.description] +To dynamically access a `MAP` value, use the subscript operator, `[]`. +The key can be provided by a variable or a parameter. +==== + + +==== +include::ROOT:expressions/map-expressions.adoc[tag=expressions_map_dynamic_access_nested_map] + +[.description] +Dynamically access a nested `MAP` value. +==== + + +==== +include::ROOT:expressions/map-expressions.adoc[tag=expressions_map_projection_key_selector] + +[.description] +Map projection with a key selector to extract specific key-value pairs from a `MAP`. +==== + + +==== +include::ROOT:expressions/map-expressions.adoc[tag=expressions_map_projection_literal_entry] + +[.description] +Map projection with a literal entry to add custom values to a projected `MAP` value without modifying the original data structure. +==== + + +==== +include::ROOT:expressions/map-expressions.adoc[tag=expressions_map_projection_variable_selector] + +[.description] +Map projection with a variable selector to project values based on a variable name. +==== + + +==== +include::ROOT:expressions/map-expressions.adoc[tag=expressions_map_projection_all_map_projection] + +[.description] +Map projection with an all-map projection to project all key-value pairs from a `MAP` without explicitly listing them. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/match.adoc b/modules/cheat-sheet/pages/match.adoc new file mode 100644 index 000000000..05d21e609 --- /dev/null +++ b/modules/cheat-sheet/pages/match.adoc @@ -0,0 +1,54 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/match/[MATCH^] + +==== +include::ROOT:clauses/match.adoc[tag=clauses_match_all_nodes] + +[.description] +Match all nodes and return all nodes. +==== + +==== +include::ROOT:clauses/match.adoc[tag=clauses_match_label] + +[.description] +Find all nodes with the `Movie` label. +==== + +==== +include::ROOT:clauses/match.adoc[tag=clauses_match_relationship_types] + +[.description] +Find the types of an aliased relationship. +==== + +==== +include::ROOT:clauses/match.adoc[tag=clauses_match_relationship] + +[.description] +Relationship pattern filtering on the `ACTED_IN` relationship type. +==== + +==== +include::ROOT:clauses/match.adoc[tag=clauses_match_path] + +[.description] +Bind a path pattern to a path variable, and return the path pattern. +==== + +==== +include::ROOT:clauses/match.adoc[tag=clauses_match_dynamic_match_parameter] + +[.description] +-- +Node labels and relationship types can be referenced dynamically in expressions, parameters, and variables. +The expression must evaluate to a `STRING NOT NULL | LIST NOT NULL` value. +-- +==== + + +==== +include::ROOT:clauses/match.adoc[tag=clauses_match_dynamic_match_variable] + +[.description] +Match nodes dynamically using a variable. +==== diff --git a/modules/cheat-sheet/pages/mathematical-functions-logarithmic.adoc b/modules/cheat-sheet/pages/mathematical-functions-logarithmic.adoc new file mode 100644 index 000000000..143b0f509 --- /dev/null +++ b/modules/cheat-sheet/pages/mathematical-functions-logarithmic.adoc @@ -0,0 +1,40 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-logarithmic[Mathematical functions - logarithmic^] + + + +==== +include::ROOT:functions/mathematical-logarithmic.adoc[tag=functions_mathematical_logarithmic_e] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-logarithmic/#functions-e[`e()`^] function returns the base of the natural logarithm, _e_. +==== + +==== +include::ROOT:functions/mathematical-logarithmic.adoc[tag=functions_mathematical_logarithmic_exp] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-logarithmic/#functions-exp[`exp()`^] function returns `e^n^`, where `e` is the base of the natural logarithm, and `n` is the value of the argument expression. +==== + +==== +include::ROOT:functions/mathematical-logarithmic.adoc[tag=functions_mathematical_logarithmic_log] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-logarithmic/#functions-log[`log()`^] function returns the natural logarithm of a number. +==== + + +==== +include::ROOT:functions/mathematical-logarithmic.adoc[tag=functions_mathematical_logarithmic_log10] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-logarithmic/#functions-log10[`log10()`^] function returns the common logarithm (base 10) of a number. +==== + + +==== +include::ROOT:functions/mathematical-logarithmic.adoc[tag=functions_mathematical_logarithmic_sqrt] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-logarithmic/#functions-sqrt[`sqrt()`^] function returns the square root of a number. +==== diff --git a/modules/cheat-sheet/pages/mathematical-functions-numeric.adoc b/modules/cheat-sheet/pages/mathematical-functions-numeric.adoc new file mode 100644 index 000000000..5b62dd05a --- /dev/null +++ b/modules/cheat-sheet/pages/mathematical-functions-numeric.adoc @@ -0,0 +1,73 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-numeric[Mathematical functions - numerical^] + + + +==== +include::ROOT:functions/mathematical-numeric.adoc[tag=functions_mathematical_numeric_abs] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-numeric/#functions-abs[`abs()`^] function returns the absolute value of the given number. +==== + +==== +include::ROOT:functions/mathematical-numeric.adoc[tag=functions_mathematical_numeric_ceil] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-numeric/#functions-ceil[`ceil()`^] function returns the smallest `FLOAT` that is greater than or equal to the given number and equal to an `INTEGER`. +==== + + + +==== +include::ROOT:functions/mathematical-numeric.adoc[tag=functions_mathematical_numeric_floor] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-numeric/#functions-floor[`floor()`^] function returns the largest `FLOAT` that is less than or equal to the given number and equal to an `INTEGER`. +==== + +==== +include::ROOT:functions/mathematical-numeric.adoc[tag=functions_mathematical_numeric_is_nan] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-numeric/#functions-isnan[`isNan()`^] function returns `true` if the given numeric value is `NaN` (Not a Number). +==== + + +==== +include::ROOT:functions/mathematical-numeric.adoc[tag=functions_mathematical_numeric_rand] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-numeric/#functions-rand[`rand()`^] function returns a random `FLOAT` in the range from 0 (inclusive) to 1 (exclusive). +The numbers returned follow an approximate uniform distribution. +==== + + +==== +include::ROOT:functions/mathematical-numeric.adoc[tag=functions_mathematical_numeric_round] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-numeric/#functions-round[`round()`^] function returns the value of the given number rounded to the nearest `INTEGER`, with ties always rounded towards positive infinity. +==== + + +==== +include::ROOT:functions/mathematical-numeric.adoc[tag=functions_mathematical_numeric_round_with_precision] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-numeric/#functions-round2[`round()` with precision^] function returns the value of the given number rounded to the closest value of given precision, with ties always being rounded away from zero (using rounding mode `HALF_UP`). +The exception is for precision 0, where ties are rounded towards positive infinity to align with `round()` without precision. +==== + +==== +include::ROOT:functions/mathematical-numeric.adoc[tag=functions_mathematical_numeric_round_with_precision_and_rounding_mode] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-numeric/#functions-round3[`round()` with precision and rounding mode^] function returns the value of the given number rounded with the specified precision and the specified rounding mode. +==== + +==== +include::ROOT:functions/mathematical-numeric.adoc[tag=functions_mathematical_numeric_sign] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-numeric/#functions-sign[`sign()`^] function returns the signum of the given number: `0` if the number is 0, `-1` for any negative number, and `1` for any positive number. +==== diff --git a/modules/cheat-sheet/pages/mathematical-functions-trigonometric.adoc b/modules/cheat-sheet/pages/mathematical-functions-trigonometric.adoc new file mode 100644 index 000000000..e07cbcde4 --- /dev/null +++ b/modules/cheat-sheet/pages/mathematical-functions-trigonometric.adoc @@ -0,0 +1,97 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-trigonometric[Mathematical Functions - trigonometric^] + + + +==== +include::ROOT:functions/mathematical-trigonometric.adoc[tag=functions_mathematical_trigonometric_acos] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-trigonometric/#functions-acos[`acos()`^] function returns the arccosine of a `FLOAT` in radians. +==== + + +==== +include::ROOT:functions/mathematical-trigonometric.adoc[tag=functions_mathematical_trigonometric_asin] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-trigonometric/#functions-asin[`asin()`^] function returns the arcsine of a `FLOAT` in radians. +==== + +==== +include::ROOT:functions/mathematical-trigonometric.adoc[tag=functions_mathematical_trigonometric_atan] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-trigonometric/#functions-atan[`atan()`^] function returns the arctangent of a `FLOAT` in radians. +==== + + +==== +include::ROOT:functions/mathematical-trigonometric.adoc[tag=functions_mathematical_trigonometric_atan2] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-trigonometric/#functions-atan2[`atan2()`^] function returns the arctangent2 of a set of coordinates in radians. +==== + + +==== +include::ROOT:functions/mathematical-trigonometric.adoc[tag=functions_mathematical_trigonometric_cos] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-trigonometric/#functions-cos[`cos()`^] function returns the cosine of a `FLOAT`. +==== + + +==== +include::ROOT:functions/mathematical-trigonometric.adoc[tag=functions_mathematical_trigonometric_cot] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-trigonometric/#functions-cot[`cot()`^] function returns the cotangent of a `FLOAT`. +==== + + +==== +include::ROOT:functions/mathematical-trigonometric.adoc[tag=functions_mathematical_trigonometric_degrees] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-trigonometric/#functions-degrees[`degrees()`^] function converts radians to degrees. +==== + + +==== +include::ROOT:functions/mathematical-trigonometric.adoc[tag=functions_mathematical_trigonometric_haversin] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-trigonometric/#functions-haversin[`haversin()`^] function converts half the versine of a number. +==== + + +==== +include::ROOT:functions/mathematical-trigonometric.adoc[tag=functions_mathematical_trigonometric_pi] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-trigonometric/#functions-pi[`pi()`^] function returns the mathematical constant _pi_. +==== + + +==== +include::ROOT:functions/mathematical-trigonometric.adoc[tag=functions_mathematical_trigonometric_radians] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-trigonometric/#functions-radians[`radians()`^] function converts degrees to radians. +==== + + +==== +include::ROOT:functions/mathematical-trigonometric.adoc[tag=functions_mathematical_trigonometric_sin] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-trigonometric/#functions-sin[`sin()`^] function returns the sine of a number. +==== + + +==== +include::ROOT:functions/mathematical-trigonometric.adoc[tag=functions_mathematical_trigonometric_tan] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/mathematical-trigonometric/#functions-tan[`tan()`^] function returns the tangent of a number. +==== diff --git a/modules/cheat-sheet/pages/mathematical-operators.adoc b/modules/cheat-sheet/pages/mathematical-operators.adoc new file mode 100644 index 000000000..b708c4a8f --- /dev/null +++ b/modules/cheat-sheet/pages/mathematical-operators.adoc @@ -0,0 +1,45 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/expressions/mathematical-operators/[Mathematical operators^] + +==== +include::ROOT:expressions/mathematical-operators.adoc[tag=expressions_mathematical_operators_addition] + +[.description] +The addition operator `+` is used to add numeric values. +==== + +==== +include::ROOT:expressions/mathematical-operators.adoc[tag=expressions_mathematical_operators_subtraction] + +[.description] +The subtraction operator `-` is used to subtract numeric values. +==== + +==== +include::ROOT:expressions/mathematical-operators.adoc[tag=expressions_mathematical_operators_multiplication] + +[.description] +The multiplication operator `*` is used to multiply numeric values. +==== + +==== +include::ROOT:expressions/mathematical-operators.adoc[tag=expressions_mathematical_operators_division] + +[.description] +The division operator `/` is used to divide numeric values. +==== + + +==== +include::ROOT:expressions/mathematical-operators.adoc[tag=expressions_mathematical_operators_modulo_division] + +[.description] +The modulo division operation `%` returns the remainder when one number is divided by another. +==== + + +==== +include::ROOT:expressions/mathematical-operators.adoc[tag=expressions_mathematical_operators_exponentiation] + +[.description] +The exponentiation operator `^` raises a number to the power of another. +==== diff --git a/modules/cheat-sheet/pages/merge.adoc b/modules/cheat-sheet/pages/merge.adoc new file mode 100644 index 000000000..94297ed6a --- /dev/null +++ b/modules/cheat-sheet/pages/merge.adoc @@ -0,0 +1,50 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/merge/[MERGE^] + + + +==== +[source, cypher, role=noheader] +---- +MERGE (n:Label {name: $value}) +ON CREATE SET n.created = timestamp() +ON MATCH SET + n.counter = coalesce(n.counter, 0) + 1, + n.accessTime = timestamp() +---- + +[.description] +Match a pattern or create it if it does not exist. Use `ON CREATE` and `ON MATCH` for conditional updates. +==== + + +==== +[source, cypher, role=noheader] +---- +MATCH + (a:Person {name: $value1}), + (b:Person {name: $value2}) +MERGE (a)-[r:LOVES]->(b) +---- + +[.description] +`MERGE` finds or creates a relationship between the nodes. +==== + + +==== +[source, cypher, role=noheader] +---- +MATCH (a:Person {name: $value1}) +---- + +[.description] +`MERGE` finds or creates paths attached to the node. +==== + +==== +include::ROOT:clauses/merge.adoc[tag=clauses_merge_dynamic_merge] + +[.description] +Node labels and relationship types can be referenced dynamically in expressions, parameters, and variables when merging nodes and relationships. +The expression must evaluate to a `STRING NOT NULL | LIST NOT NULL` value. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/node-relationship-operators.adoc b/modules/cheat-sheet/pages/node-relationship-operators.adoc new file mode 100644 index 000000000..c3386ad5e --- /dev/null +++ b/modules/cheat-sheet/pages/node-relationship-operators.adoc @@ -0,0 +1,24 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/expressions/node-relationship-operators/[Node and relationship operators^] + +==== +include::ROOT:expressions/node-relationship-operators.adoc[tag=expressions_node_relationship_operators_static_property_access] + +[.description] +Property values of nodes and relationships can be accessed statically by specifying a property name after the `.` operator. +==== + +==== +include::ROOT:expressions/node-relationship-operators.adoc[tag=expressions_node_relationship_operators_dynamic_property_access] + +[.description] +Property values can be accessed dynamically by using the subscript operator `[]`. +==== + + +==== +include::ROOT:expressions/node-relationship-operators.adoc[tag=expressions_node_relationship_operators_null] + +[.description] +If a property (or property value) is missing in an expression that tries to access a property statically or dynamically, the whole expression will evaluate to `NULL`. +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-coalesce[`coalesce()`] function can be used to skip the first `NULL` value in an expression. +==== diff --git a/modules/cheat-sheet/pages/non-linear-paths.adoc b/modules/cheat-sheet/pages/non-linear-paths.adoc new file mode 100644 index 000000000..5caf981cf --- /dev/null +++ b/modules/cheat-sheet/pages/non-linear-paths.adoc @@ -0,0 +1,20 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/patterns/fixed-length-paths/[Non-linear paths^] + + +==== +include::ROOT:patterns/non-linear-paths.adoc[tag=patterns_non_linear_paths_equijoin] + +[.description] +An equijoin is an operation on paths that requires more than one of the nodes or relationships of the paths to be the same. +The equality between the nodes or relationships is specified by declaring a node variable or relationship variable more than once. +An equijoin on nodes allows cycles to be specified in a path pattern. +Due to link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/patterns/reference/#graph-patterns-rules-relationship-uniqueness[relationship uniqueness^], an equijoin on relationships yields no solutions. +==== + +==== +include::ROOT:patterns/non-linear-paths.adoc[tag=patterns_non_linear_paths_graph_pattern] + +[.description] +Multiple path patterns can be combined in a comma-separated list to form a graph pattern. +In a graph pattern, each path pattern is matched separately, and where node variables are repeated in the separate path patterns, the solutions are reduced via equijoins. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/on-database-constraint-management-privileges.adoc b/modules/cheat-sheet/pages/on-database-constraint-management-privileges.adoc new file mode 100644 index 000000000..1fb3bf397 --- /dev/null +++ b/modules/cheat-sheet/pages/on-database-constraint-management-privileges.adoc @@ -0,0 +1,56 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/database-administration/#access-control-database-administration-constraints[ON DATABASE - CONSTRAINT MANAGEMENT Privileges^] + + +==== +[source, cypher, role=noheader] +---- +GRANT CONSTRAINT MANAGEMENT +ON DATABASE * TO role_name +---- + +[.description] +-- +Grant `CONSTRAINT MANAGEMENT` privilege to create, drop, and list constraints for all database to the specified role. + +* Allow creating a constraint - (`GRANT CREATE CONSTRAINT`). +* Allow removing a constraint - (`GRANT DROP CONSTRAINT`). +* Allow listing a constraint - (`GRANT SHOW CONSTRAINT`). +-- +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT CREATE CONSTRAINT +ON DATABASE * TO role_name +---- + +[.description] +Grant `CREATE CONSTRAINT` privilege to create constraints on all databases to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT DROP CONSTRAINT +ON DATABASE * TO role_name +---- + +[.description] +Grant `DROP CONSTRAINT` privilege to create constraints on all databases to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT SHOW CONSTRAINT +ON DATABASE `database-name` TO role_name +---- + +[.description] +Grant `SHOW CONSTRAINT` privilege to list constraints on a specified database to the specified role. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/on-database-index-management-privileges.adoc b/modules/cheat-sheet/pages/on-database-index-management-privileges.adoc new file mode 100644 index 000000000..8e70c8078 --- /dev/null +++ b/modules/cheat-sheet/pages/on-database-index-management-privileges.adoc @@ -0,0 +1,56 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/database-administration/#access-control-database-administration-index[ON DATABASE - INDEX MANAGEMENT Privileges^] + + +==== +[source, cypher, role=noheader] +---- +GRANT INDEX MANAGEMENT +ON DATABASE * TO role_name +---- + +[.description] +-- +Grant `INDEX MANAGEMENT` privilege to create, drop, and list indexes for all database to the specified role. + +* Allow creating an index - (`GRANT CREATE INDEX`). +* Allow removing an index - (`GRANT DROP INDEX`). +* Allow listing an index - (`GRANT SHOW INDEX`). +-- +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT CREATE INDEX +ON DATABASE `database-name` TO role_name +---- + +[.description] +Grant `CREATE INDEX` privilege to create indexes on a specified database to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT DROP INDEX +ON DATABASE `database-name` TO role_name +---- + +[.description] +Grant `DROP INDEX` privilege to drop indexes on a specified database to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT SHOW INDEX +ON DATABASE * TO role_name +---- + +[.description] +Grant `SHOW INDEX` privilege to list indexes on all databases to the specified role. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/on-database-name-management-privileges.adoc b/modules/cheat-sheet/pages/on-database-name-management-privileges.adoc new file mode 100644 index 000000000..25a6dfd7f --- /dev/null +++ b/modules/cheat-sheet/pages/on-database-name-management-privileges.adoc @@ -0,0 +1,56 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/database-administration/#access-control-database-administration-tokens[ON DATABASE - NAME MANAGEMENT Privileges^] + + +==== +[source, cypher, role=noheader] +---- +GRANT NAME MANAGEMENT +ON DATABASE * TO role_name +---- + +[.description] +-- +Grant `NAME MANAGEMENT` privilege to create new labels, new relationship types, and new property names for all databases to the specified role. + +* Allow creating a new label - (`GRANT CREATE NEW LABEL`). +* Allow creating a new relationship type - (`GRANT CREATE NEW TYPE`). +* Allow creating a new property name - (`GRANT CREATE NEW NAME`). +-- +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT CREATE NEW LABEL +ON DATABASE * TO role_name +---- + +[.description] +Grant `CREATE NEW LABEL` privilege to create new labels on all databases to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +DENY CREATE NEW TYPE +ON DATABASE * TO role_name +---- + +[.description] +Deny `CREATE NEW TYPE` privilege to create new relationship types on all databases to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT CREATE NEW NAME +ON DATABASE * TO role_name +---- + +[.description] +Grant `CREATE NEW NAME` privilege to create new property names on all databases to the specified role. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/on-database-privileges.adoc b/modules/cheat-sheet/pages/on-database-privileges.adoc new file mode 100644 index 000000000..f635b63e0 --- /dev/null +++ b/modules/cheat-sheet/pages/on-database-privileges.adoc @@ -0,0 +1,77 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/database-administration/[ON DATABASE Privileges^] + + +==== +[source, cypher, role=noheader] +---- +GRANT ALL DATABASE PRIVILEGES +ON DATABASE * TO role_name +---- + +[.description] +-- +Grant `ALL DATABASE PRIVILEGES` privilege for all databases to the specified role. + +* Allows access (`GRANT ACCESS`). +* Index management (`GRANT INDEX MANAGEMENT`). +* Constraint management (`GRANT CONSTRAINT MANAGEMENT`). +* Name management (`GRANT NAME MANAGEMENT`). + +Note that the privileges for starting and stopping all databases, and transaction management, are not included. +-- +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT ALL ON DATABASE * TO role_name +---- + +[.description] +-- +Short form for grant `ALL DATABASE PRIVILEGES` privilege. + +* `GRANT` – gives privileges to roles. +* `DENY` – denies privileges to roles. + +To remove a granted or denied privilege, prepend the privilege query with `REVOKE` and replace the `TO` with `FROM`; (`REVOKE GRANT ALL ON DATABASE * FROM role_name`). +-- +==== + + +==== +[source, cypher, role=noheader] +---- +REVOKE ACCESS +ON HOME DATABASE FROM role_name +---- + +[.description] +Revoke `ACCESS` privilege to access and run queries against the home database from the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT START +ON DATABASE * TO role_name +---- + +[.description] +Grant `START` privilege to start all databases to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +DENY STOP +ON HOME DATABASE TO role_name +---- + +[.description] +Deny `STOP` privilege to stop the home database to the specified role. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/on-database-transaction-management-privileges.adoc b/modules/cheat-sheet/pages/on-database-transaction-management-privileges.adoc new file mode 100644 index 000000000..c5fdd30af --- /dev/null +++ b/modules/cheat-sheet/pages/on-database-transaction-management-privileges.adoc @@ -0,0 +1,55 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/database-administration/#access-control-database-administration-transaction[ON DATABASE - TRANSACTION MANAGEMENT Privileges^] + + +==== +[source, cypher, role=noheader] +---- +GRANT TRANSACTION MANAGEMENT (*) +ON DATABASE * TO role_name +---- + +[.description] +-- +Grant `TRANSACTION MANAGEMENT` privilege to show and terminate transactions on all users, for all databases, to the specified role. + +* Allow listing transactions - (`GRANT SHOW TRANSACTION`). +* Allow terminate transactions - (`GRANT TERMINATE TRANSACTION`). +-- +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT SHOW TRANSACTION (*) +ON DATABASE * TO role_name +---- + +[.description] +Grant `SHOW TRANSACTION` privilege to list transactions on all users on all databases to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT SHOW TRANSACTION (user_name1, user_name2) +ON HOME DATABASE TO role_name1, role_name2 +---- + +[.description] +Grant `SHOW TRANSACTION` privilege to list transactions by the specified users on home database to the specified roles. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT TERMINATE TRANSACTION (*) +ON DATABASE * TO role_name +---- + +[.description] +Grant `TERMINATE TRANSACTION` privilege to terminate transactions on all users on all databases to the specified role. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/on-dbms-alias-management-privileges.adoc b/modules/cheat-sheet/pages/on-dbms-alias-management-privileges.adoc new file mode 100644 index 000000000..768a5a0db --- /dev/null +++ b/modules/cheat-sheet/pages/on-dbms-alias-management-privileges.adoc @@ -0,0 +1,69 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-alias-management[ON DBMS - ALIAS MANAGEMENT Privileges^] + + +==== +[source, cypher, role=noheader] +---- +GRANT ALIAS MANAGEMENT +ON DBMS TO role_name +---- + +[.description] +-- +Grant `ALIAS MANAGEMENT` privilege to manage aliases to the specified role. + +* Allow creating aliases - (`GRANT CREATE ALIAS`). +* Allow deleting aliases - (`GRANT DROP ALIAS`). +* Allow modifying aliases - (`GRANT ALTER ALIAS`). +* Allow listing aliases - (`GRANT SHOW ALIAS`). +-- +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT CREATE ALIAS +ON DBMS TO role_name +---- + +[.description] +Grant `CREATE ALIAS` privilege to create aliases to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT DROP ALIAS +ON DBMS TO role_name +---- + +[.description] +Grant `DROP ALIAS` privilege to delete aliases to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT ALTER ALIAS +ON DBMS TO role_name +---- + +[.description] +Grant `ALTER ALIAS` privilege to alter aliases to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT SHOW ALIAS +ON DBMS TO role_name +---- + +[.description] +Grant `SHOW ALIAS` privilege to list aliases to the specified role. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/on-dbms-database-management-privileges.adoc b/modules/cheat-sheet/pages/on-dbms-database-management-privileges.adoc new file mode 100644 index 000000000..4a68ef1bf --- /dev/null +++ b/modules/cheat-sheet/pages/on-dbms-database-management-privileges.adoc @@ -0,0 +1,139 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-database-management[ON DBMS - DATABASE MANAGEMENT Privileges^] + + +==== +[source, cypher, role=noheader] +---- +GRANT DATABASE MANAGEMENT +ON DBMS TO role_name +---- + +[.description] +-- +Grant `DATABASE MANAGEMENT` privilege to manage databases to the specified role. + +* Allow creating standard databases - (`GRANT CREATE DATABASE`). +* Allow deleting standard databases - (`GRANT DROP DATABASE`). +* Allow modifying standard databases - (`GRANT ALTER DATABASE`). +* Allow managing composite databases - (`GRANT COMPOSITE DATABASE MANAGEMENT`). +-- +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT CREATE DATABASE +ON DBMS TO role_name +---- + +[.description] +Grant `CREATE DATABASE` privilege to create standard databases to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT DROP DATABASE +ON DBMS TO role_name +---- + +[.description] +Grant `DROP DATABASE` privilege to delete standard databases to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT ALTER DATABASE +ON DBMS TO role_name +---- + +[.description] +-- +Grant `ALTER DATABASE` privilege to alter standard databases the specified role. + +* Allow modifying access mode for standard databases - (`GRANT SET DATABASE ACCESS`). +* Allow modifying topology settings for standard databases. +-- +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT SET DATABASE ACCESS +ON DBMS TO role_name +---- + +[.description] +Grant `SET DATABASE ACCESS` privilege to set database access mode for standard databases to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT COMPOSITE DATABASE MANAGEMENT +ON DBMS TO role_name +---- + +[.description] +-- +Grant all privileges to manage composite databases to the specified role. + +* Allow creating composite databases - (`CREATE COMPOSITE DATABASE`). +* Allow deleting composite databases - (`DROP COMPOSITE DATABASE`). +-- +==== + + +==== +[source, cypher, role=noheader] +---- +DENY CREATE COMPOSITE DATABASE +ON DBMS TO role_name +---- + +[.description] +Denies the specified role the privilege to create composite databases. +==== + + +==== +[source, cypher, role=noheader] +---- +REVOKE DROP COMPOSITE DATABASE +ON DBMS FROM role_name +---- + +[.description] +Revokes the granted and denied privileges to delete composite databases from the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT SERVER MANAGEMENT +ON DBMS TO role_name +---- + +[.description] +Enables the specified role to show, enable, rename, alter, reallocate, deallocate, and drop servers. +==== + + +==== +[source, cypher, role=noheader] +---- +DENY SHOW SERVERS +ON DBMS TO role_name +---- + +[.description] +Denies the specified role the privilege to show information about the serves. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/on-dbms-privilege-management-privileges.adoc b/modules/cheat-sheet/pages/on-dbms-privilege-management-privileges.adoc new file mode 100644 index 000000000..7506403d0 --- /dev/null +++ b/modules/cheat-sheet/pages/on-dbms-privilege-management-privileges.adoc @@ -0,0 +1,56 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-privilege-management[ON DBMS - PRIVILEGE MANAGEMENT Privileges^] + + +==== +[source, cypher, role=noheader] +---- +GRANT PRIVILEGE MANAGEMENT +ON DBMS TO role_name +---- + +[.description] +-- +Grant `PRIVILEGE MANAGEMENT` privilege to manage privileges for the Neo4j DBMS to the specified role. + +* Allow assigning (`GRANT|DENY`) privileges for a role - (`GRANT ASSIGN PRIVILEGE`). +* Allow removing (`REVOKE`) privileges for a role - (`GRANT REMOVE PRIVILEGE`). +* Allow listing privileges - (`GRANT SHOW PRIVILEGE`). +-- +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT ASSIGN PRIVILEGE +ON DBMS TO role_name +---- + +[.description] +Grant `ASSIGN PRIVILEGE` privilege, allows the specified role to assign privileges for roles. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT REMOVE PRIVILEGE +ON DBMS TO role_name +---- + +[.description] +Grant `REMOVE PRIVILEGE` privilege, allows the specified role to remove privileges for roles. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT SHOW PRIVILEGE +ON DBMS TO role_name +---- + +[.description] +Grant `SHOW PRIVILEGE` privilege to list privileges to the specified role. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/on-dbms-privileges.adoc b/modules/cheat-sheet/pages/on-dbms-privileges.adoc new file mode 100644 index 000000000..3dfa4803b --- /dev/null +++ b/modules/cheat-sheet/pages/on-dbms-privileges.adoc @@ -0,0 +1,141 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/[ON DBMS Privileges^] + + +==== +[source, cypher, role=noheader] +---- +GRANT ALL DBMS PRIVILEGES +ON DBMS TO role_name +---- + +[.description] +-- +Grant `ALL DBMS PRIVILEGES` privilege to perform management for roles, users, databases, aliases, and privileges to the specified role. Also privileges to execute procedures and user defined functions are granted. + +* Allow controlling roles - (`GRANT ROLE MANAGEMENT`). +* Allow controlling users - (`GRANT USER MANAGEMENT`). +* Allow controlling databases - (`GRANT DATABASE MANAGEMENT`). +* Allow controlling aliases - (`GRANT ALIAS MANAGEMENT`). +* Allow controlling privileges - (`GRANT PRIVILEGE MANAGEMENT`). +* Allow user impersonation - (`GRANT IMPERSONATE (*)`). +* Allow to execute all procedures with elevated privileges. +* Allow to execute all user defined functions with elevated privileges. +-- +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT ALL +ON DBMS TO role_name +---- + +[.description] +-- +Short form for grant `ALL DBMS PRIVILEGES` privilege. + +* `GRANT` – gives privileges to roles. +* `DENY` – denies privileges to roles. + +To remove a granted or denied privilege, prepend the privilege query with `REVOKE` and replace the `TO` with `FROM`; (`REVOKE GRANT ALL ON DBMS FROM role_name`). +-- +==== + + +==== +[source, cypher, role=noheader] +---- +DENY IMPERSONATE (user_name1, user_name2) +ON DBMS TO role_name +---- + +[.description] +Deny `IMPERSONATE` privilege to impersonate the specified users (`user_name1` and `user_name2`) to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +REVOKE IMPERSONATE (*) +ON DBMS TO role_name +---- + +[.description] +Revoke `IMPERSONATE` privilege to impersonate all users from the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT EXECUTE PROCEDURE * +ON DBMS TO role_name +---- + +[.description] +Enables the specified role to execute all procedures. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT EXECUTE BOOSTED PROCEDURE * +ON DBMS TO role_name +---- + +[.description] +Enables the specified role to use elevated privileges when executing all procedures. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT EXECUTE ADMIN PROCEDURES +ON DBMS TO role_name +---- + +[.description] +Enables the specified role to execute procedures annotated with `@Admin`. The procedures are executed with elevated privileges. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT EXECUTE FUNCTIONS * +ON DBMS TO role_name +---- + +[.description] +Enables the specified role to execute all user defined functions. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT EXECUTE BOOSTED FUNCTIONS * +ON DBMS TO role_name +---- + +[.description] +Enables the specified role to use elevated privileges when executing all user defined functions. +==== + + +[neo4j.ee] +==== +[source, cypher, role=noheader] +---- +GRANT SHOW SETTINGS * +ON DBMS TO role_name +---- + +[.description] +Enables the specified role to view all configuration settings. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/on-dbms-role-management-privileges.adoc b/modules/cheat-sheet/pages/on-dbms-role-management-privileges.adoc new file mode 100644 index 000000000..64c7f7567 --- /dev/null +++ b/modules/cheat-sheet/pages/on-dbms-role-management-privileges.adoc @@ -0,0 +1,95 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-role-management[ON DBMS - ROLE MANAGEMENT Privileges^] + + +==== +[source, cypher, role=noheader] +---- +GRANT ROLE MANAGEMENT +ON DBMS TO role_name +---- + +[.description] +-- +Grant `ROLE MANAGEMENT` privilege to manage roles to the specified role. + +* Allow creating roles - (`GRANT CREATE ROLE`). +* Allow renaming roles - (`GRANT RENAME ROLE`). +* Allow deleting roles - (`GRANT DROP ROLE`). +* Allow assigning (`GRANT`) roles to a user - (`GRANT ASSIGN ROLE`). +* Allow removing (`REVOKE`) roles from a user - (`GRANT REMOVE ROLE`). +* Allow listing roles - (`GRANT SHOW ROLE`). +-- +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT CREATE ROLE +ON DBMS TO role_name +---- + +[.description] +Grant `CREATE ROLE` privilege to create roles to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT RENAME ROLE +ON DBMS TO role_name +---- + +[.description] +Grant `RENAME ROLE` privilege to rename roles to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +DENY DROP ROLE +ON DBMS TO role_name +---- + +[.description] +Deny `DROP ROLE` privilege to delete roles to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT ASSIGN ROLE +ON DBMS TO role_name +---- + +[.description] +Grant `ASSIGN ROLE` privilege to assign roles to users to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +DENY REMOVE ROLE +ON DBMS TO role_name +---- + +[.description] +Deny `REMOVE ROLE` privilege to remove roles from users to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT SHOW ROLE +ON DBMS TO role_name +---- + +[.description] +Grant `SHOW ROLE` privilege to list roles to the specified role. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/on-dbms-user-management-privileges.adoc b/modules/cheat-sheet/pages/on-dbms-user-management-privileges.adoc new file mode 100644 index 000000000..88b24886b --- /dev/null +++ b/modules/cheat-sheet/pages/on-dbms-user-management-privileges.adoc @@ -0,0 +1,135 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-user-management[ON DBMS - USER MANAGEMENT Privileges^] + + +==== +[source, cypher, role=noheader] +---- +GRANT USER MANAGEMENT +ON DBMS TO role_name +---- + +[.description] +-- +Grant `USER MANAGEMENT` privilege to manage users to the specified role. + +* Allow creating users - (`GRANT CREATE USER`). +* Allow renaming users - (`GRANT RENAME USER`). +* Allow modifying a user - (`GRANT ALTER USER`). +* Allow deleting users - (`GRANT DROP USER`). +* Allow listing users - (`GRANT SHOW USER`). +-- +==== + + +==== +[source, cypher, role=noheader] +---- +DENY CREATE USER +ON DBMS TO role_name +---- + +[.description] +Deny `CREATE USER` privilege to create users to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT RENAME USER +ON DBMS TO role_name +---- + +[.description] +Grant `RENAME USER` privilege to rename users to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT ALTER USER +ON DBMS TO my_role +---- + +[.description] +-- +Grant `ALTER USER` privilege to alter users to the specified role. + +* Allow changing a user's password - (`GRANT SET PASSWORD`). +* Allow adding or removing a user's auth providers - (`GRANT SET AUTH`). +* Allow changing a user's home database - (`GRANT SET USER HOME DATABASE`). +* Allow changing a user's status - (`GRANT USER STATUS`). +-- +==== + + +==== +[source, cypher, role=noheader] +---- +DENY SET PASSWORD +ON DBMS TO role_name +---- + +[.description] +Deny `SET PASSWORD` privilege to alter a user password to the specified role. +==== + +==== +[source, cypher, role=noheader] +---- +GRANT SET AUTH +ON DBMS TO role_name +---- + +[.description] +Grant `SET AUTH` privilege to add/remove auth providers to the specified role. +==== + +==== +[source, cypher, role=noheader] +---- +GRANT SET USER HOME DATABASE +ON DBMS TO role_name +---- + +[.description] +Grant `SET USER HOME DATABASE` privilege to alter the home database of users to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT SET USER STATUS +ON DBMS TO role_name +---- + +[.description] +Grant `SET USER STATUS` privilege to alter user account status to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT DROP USER +ON DBMS TO role_name +---- + +[.description] +Grant `DROP USER` privilege to delete users to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +DENY SHOW USER +ON DBMS TO role_name +---- + +[.description] +Deny `SHOW USER` privilege to list users to the specified role. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/on-graph-read-privileges.adoc b/modules/cheat-sheet/pages/on-graph-read-privileges.adoc new file mode 100644 index 000000000..6db045a26 --- /dev/null +++ b/modules/cheat-sheet/pages/on-graph-read-privileges.adoc @@ -0,0 +1,121 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/privileges-reads/[ON GRAPH Read Privileges^] + + +==== +[source, cypher, role=noheader] +---- +GRANT TRAVERSE +ON GRAPH * NODE * TO role_name +---- + +[.description] +-- +Grant `TRAVERSE` privilege on all graphs and all nodes to the specified role. + +* `GRANT` – gives privileges to roles. +* `DENY` – denies privileges to roles. +-- +==== + + +==== +[source, cypher, role=noheader] +---- +REVOKE GRANT TRAVERSE +ON GRAPH * NODE * FROM role_name +---- + +[.description] +To remove a granted or denied privilege, prepend the privilege query with `REVOKE` and replace the `TO` with `FROM`. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT TRAVERSE +ON GRAPH * RELATIONSHIP * TO role_name +---- + +[.description] +Grant `TRAVERSE` privilege on all graphs and all relationships to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +DENY READ {prop} +ON GRAPH `database-name` RELATIONSHIP rel_type TO role_name +---- + +[.description] +Deny `READ` privilege on a specified property, on all relationships with a specified type in a specified graph, to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +REVOKE READ {prop} +ON GRAPH `database-name` FROM role_name +---- + +[.description] +Revoke `READ` privilege on a specified property in a specified graph from the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT MATCH {*} +ON HOME GRAPH ELEMENTS label_or_type TO role_name +---- + +[.description] +Grant `MATCH` privilege on all nodes and relationships with the specified label/type, on the home graph, to the specified role. This is semantically the same as having both `TRAVERSE` privilege and `READ {*}` privilege. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT READ {*} +ON GRAPH * +FOR (n) WHERE n.secret = false +TO role_name +---- + +[.description] +Grant `READ` privilege on all graphs and all nodes with a `secret` property set to `false` to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +DENY TRAVERSE +ON GRAPH * +FOR (n:label) WHERE n.secret <> false +TO role_name +---- + +[.description] +Deny `TRAVERSE` privilege on all graphs and all nodes with the specified label and with a `secret` property not set to `false` to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +REVOKE MATCH {*} +ON GRAPH * +FOR (n:foo_label|bar_label) WHERE n.secret IS NULL +FROM role_name +---- + +[.description] +Revoke `MATCH` privilege on all graphs and all nodes with either `foo_label` or `bar_label` and with a `secret` property that is `null` from the specified role. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/on-graph-write-privileges.adoc b/modules/cheat-sheet/pages/on-graph-write-privileges.adoc new file mode 100644 index 000000000..2ba22c8b3 --- /dev/null +++ b/modules/cheat-sheet/pages/on-graph-write-privileges.adoc @@ -0,0 +1,116 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/privileges-writes/[ON GRAPH Write Privileges^] + + +==== +[source, cypher, role=noheader] +---- +GRANT ALL GRAPH PRIVILEGES +ON GRAPH `database-name` TO role_name +---- + +[.description] +Grant `ALL GRAPH PRIVILEGES` privilege on a specified graph to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT ALL ON GRAPH `database-name` TO role_name +---- + +[.description] +-- +Short form for grant `ALL GRAPH PRIVILEGES` privilege. + +* `GRANT` – gives privileges to roles. +* `DENY` – denies privileges to roles. + +To remove a granted or denied privilege, prepend the privilege query with `REVOKE` and replace the `TO` with `FROM`; (`REVOKE GRANT ALL ON GRAPH `database-name` FROM role_name`). +-- +==== + + +==== +[source, cypher, role=noheader] +---- +DENY CREATE +ON GRAPH * NODES node_label TO role_name +---- + +[.description] +Deny `CREATE` privilege on all nodes with a specified label in all graphs to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +REVOKE DELETE +ON GRAPH `database-name` TO role_name +---- + +[.description] +Revoke `DELETE` privilege on all nodes and relationships in a specified graph from the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT SET LABEL node_label +ON GRAPH * TO role_name +---- + +[.description] +Grant `SET LABEL` privilege for the specified label on all graphs to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +DENY REMOVE LABEL * +ON GRAPH `database-name` TO role_name +---- + +[.description] +Deny `REMOVE LABEL` privilege for all labels on a specified graph to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT SET PROPERTY {prop_name} +ON GRAPH `database-name` RELATIONSHIPS rel_type TO role_name +---- + +[.description] +Grant `SET PROPERTY` privilege on a specified property, on all relationships with a specified type in a specified graph, to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT MERGE {*} +ON GRAPH * NODES node_label TO role_name +---- + +[.description] +Grant `MERGE` privilege on all properties, on all nodes with a specified label in all graphs, to the specified role. +==== + + +==== +[source, cypher, role=noheader] +---- +REVOKE WRITE +ON GRAPH * FROM role_name +---- + +[.description] +Revoke `WRITE` privilege on all graphs from the specified role. +==== diff --git a/modules/cheat-sheet/pages/optional-match.adoc b/modules/cheat-sheet/pages/optional-match.adoc new file mode 100644 index 000000000..b86af0ecc --- /dev/null +++ b/modules/cheat-sheet/pages/optional-match.adoc @@ -0,0 +1,10 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/optional-match/[OPTIONAL MATCH^] + +==== +include::ROOT:clauses/optional-match.adoc[tag=clauses_optional_match] + +[.description] +Use `MATCH` to find entities that must be present in the pattern. +Use `OPTIONAL MATCH` to find entities that may not be present in the pattern. +`OPTIONAL MATCH` returns `null` for empty rows. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/order-by.adoc b/modules/cheat-sheet/pages/order-by.adoc new file mode 100644 index 000000000..8bd8712f9 --- /dev/null +++ b/modules/cheat-sheet/pages/order-by.adoc @@ -0,0 +1,37 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/order-by/[ORDER BY^] + +==== +include::ROOT:clauses/order-by.adoc[tag=clauses_order_by] + +[.description] +-- +`ORDER BY` specifies how the output of a clause should be sorted. +It can be used as a sub-clause following link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/return/[`RETURN`] or link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/with/[`WITH`]. +-- +==== + +==== +include::ROOT:clauses/order-by.adoc[tag=clauses_order_by_multiple] + +[.description] +You can order by multiple properties by stating each variable in the `ORDER BY` clause. +==== + +==== +include::ROOT:clauses/order-by.adoc[tag=clauses_order_by_descending] + +[.description] +-- +By adding `DESC[ENDING]` after the variable to sort on, the sort will be done in reverse order. + +`ORDER BY` can be used in conjunction with `SKIP` and `LIMIT`. +-- +==== + + +==== +include::ROOT:clauses/order-by.adoc[tag=clauses_order_by_standalone] + +[.description] +`ORDER BY` can be used as a standalone clause. +==== diff --git a/modules/cheat-sheet/pages/path-pattern-expressions.adoc b/modules/cheat-sheet/pages/path-pattern-expressions.adoc new file mode 100644 index 000000000..c0c3bf577 --- /dev/null +++ b/modules/cheat-sheet/pages/path-pattern-expressions.adoc @@ -0,0 +1,16 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/expressions/predicates/#path-pattern-expressions[Path pattern expressions^] + +==== +include::ROOT:expressions/predicates/path-pattern-expressions.adoc[tag=expressions_predicates_path_pattern_expression] + +[.description] +Similar to link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/subqueries/existential/[`EXISTS` subqueries], path pattern expressions can be used to assert whether a specified path exists at least once in a graph. +==== + + +==== +include::ROOT:expressions/predicates/path-pattern-expressions.adoc[tag=expressions_predicates_path_pattern_expression_boolean] + +[.description] +Path pattern expression with boolean operators. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/performance.adoc b/modules/cheat-sheet/pages/performance.adoc new file mode 100644 index 000000000..610594d3d --- /dev/null +++ b/modules/cheat-sheet/pages/performance.adoc @@ -0,0 +1,12 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/planning-and-tuning/query-tuning/[Performance^] + +[.description] +-- +Use parameters instead of literals when possible. This allows Neo4j DBMS to cache your queries instead of having to parse and build new execution plans. + +Always set an upper limit for your variable length patterns. It is possible to have a query go wild and touch all nodes in a graph by mistake. + +Return only the data you need. Avoid returning whole nodes and relationships; instead, pick the data you need and return only that. + +Use `PROFILE` / `EXPLAIN` to analyze the performance of your queries. See link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/planning-and-tuning/query-tuning/[Query Tuning^] for more information on these and other topics, such as planner hints. +-- diff --git a/modules/cheat-sheet/pages/predicate-functions.adoc b/modules/cheat-sheet/pages/predicate-functions.adoc new file mode 100644 index 000000000..33628d547 --- /dev/null +++ b/modules/cheat-sheet/pages/predicate-functions.adoc @@ -0,0 +1,49 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/predicate/[Predicate functions^] + + +==== +include::ROOT:functions/predicate.adoc[tag=functions_predicate_all] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/predicate/#functions-all[`all()`^] function returns `true` if the predicate holds for all elements in the given `LIST`. +==== + + +==== +include::ROOT:functions/predicate.adoc[tag=functions_predicate_any] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/predicate/#functions-any[`any()`^] function returns `true` if the predicate holds for at least one element in the given `LIST`. +==== + + +==== +include::ROOT:functions/predicate.adoc[tag=functions_predicate_exists] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/predicate/#functions-exists[`exists()`^] function returns `true` if a match for the given pattern exists in the graph. +==== + + +==== +include::ROOT:functions/predicate.adoc[tag=functions_predicate_is_empty] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/predicate/#functions-isempty[`isEmpty()`^] function returns `true` if the given `LIST` or `MAP` contains no elements, or if the given `STRING` contains no characters. +==== + + +==== +include::ROOT:functions/predicate.adoc[tag=functions_predicate_none] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/predicate/#functions-none[`none()`^] function returns `true` if the predicate does not hold for any element in the given `LIST`. +==== + + +==== +include::ROOT:functions/predicate.adoc[tag=functions_predicate_single] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/predicate/#functions-single[`single()`^] function returns `true` if the predicate holds for exactly _one_ of the elements in the given `LIST`. +==== diff --git a/modules/cheat-sheet/pages/read-query-structure.adoc b/modules/cheat-sheet/pages/read-query-structure.adoc new file mode 100644 index 000000000..4330eb81d --- /dev/null +++ b/modules/cheat-sheet/pages/read-query-structure.adoc @@ -0,0 +1,26 @@ += Read Query Structure + + +==== +[source, cypher, role=noheader] +---- +[USE] +[MATCH [WHERE]] +[OPTIONAL MATCH [WHERE]] +[WITH [ORDER BY] [SKIP] [LIMIT] [WHERE]] +RETURN [ORDER BY] [SKIP] [LIMIT] +---- + +[.description] +-- +Baseline for pattern search operations. + +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/use/[`USE`^] clause. +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/match/[`MATCH`^] clause. +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/optional-match/[`OPTIONAL MATCH`^] clause. +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/with/[`WITH`^] clause. +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/return/[`RETURN`^] clause. +* Cypher keywords are not case-sensitive. +* Cypher is case-sensitive for variables. +-- +==== diff --git a/modules/cheat-sheet/pages/read-write-query-structure.adoc b/modules/cheat-sheet/pages/read-write-query-structure.adoc new file mode 100644 index 000000000..930288fd1 --- /dev/null +++ b/modules/cheat-sheet/pages/read-write-query-structure.adoc @@ -0,0 +1,46 @@ += Read-Write Query Structure + + +==== +[source, cypher, role=noheader] +---- +[USE] +[MATCH [WHERE]] +[OPTIONAL MATCH [WHERE]] +[WITH [ORDER BY] [SKIP] [LIMIT] [WHERE]] +[CREATE] +[MERGE [ON CREATE ...] [ON MATCH ...]] +[WITH [ORDER BY] [SKIP] [LIMIT] [WHERE]] +[SET] +[DELETE] +[REMOVE] +[RETURN [ORDER BY] [SKIP] [LIMIT]] +---- + +[.description] +-- +Baseline for pattern search and write operations. + + + +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/use/[`USE`^] clause. + +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/match/[`MATCH`^] clause + +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/optional-match/[`OPTIONAL MATCH`^] clause. + +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/create/[`CREATE`^] clause + +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/merge/[`MERGE`^] clause. + +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/with/[`WITH`^] clause. + +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/set/[`SET`^] clause. + +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/delete/[`DELETE`^] clause. + +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/remove/[`REMOVE`^] clause. + +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/return/[`RETURN`^] clause. +-- +==== diff --git a/modules/cheat-sheet/pages/remove.adoc b/modules/cheat-sheet/pages/remove.adoc new file mode 100644 index 000000000..202100e00 --- /dev/null +++ b/modules/cheat-sheet/pages/remove.adoc @@ -0,0 +1,62 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/remove/[REMOVE^] + + +==== +[source, cypher, role=noheader] +---- +MATCH (n:Label) +WHERE n.id = 123 +REMOVE n:Label +---- + +[.description] +Remove a label from a node. +==== + +==== +[source, cypher, role=noheader] +---- +MATCH (n {name: 'Peter'}) +REMOVE n:$($label) +RETURN n.name +---- + +[.description] +Dynamically remove node labels. +==== + +==== +[source, cypher, role=noheader] +---- +MATCH (n:Label) +WHERE n.id = 123 +REMOVE n.alias +---- + +[.description] +Remove a property from a node. +==== + +==== +[source, cypher, role=noheader] +---- +MATCH (n) +REMOVE n[$key] +---- + +[.description] +Dynamically remove properties from nodes. +==== + + +==== +[source, cypher, role=noheader] +---- +MATCH (n:Label) +WHERE n.id = 123 +SET n = {} # REMOVE ALL properties +---- + +[.description] +`REMOVE` cannot be used to remove all existing properties from a node or relationship. All existing properties can be removed from a node or relationship by using the `SET` clause with the property replacement operator (`=`) and an empty map (`{}`) as the right operand. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/return.adoc b/modules/cheat-sheet/pages/return.adoc new file mode 100644 index 000000000..7abf8e948 --- /dev/null +++ b/modules/cheat-sheet/pages/return.adoc @@ -0,0 +1,55 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/return/[RETURN^] + +==== +include::ROOT:clauses/return.adoc[tag=clauses_return_node] + +[.description] +Return a node. +==== + +==== +include::ROOT:clauses/return.adoc[tag=clauses_return_relationship_type] + +[.description] +Return relationship types. +==== + +==== +include::ROOT:clauses/return.adoc[tag=clauses_return_property] + +[.description] +Return a specific property. +==== + +==== +include::ROOT:clauses/return.adoc[tag=clauses_return_all_elements] + +[.description] +To return all nodes, relationships and paths found in a query, use the `*` symbol. +==== + +==== +include::ROOT:clauses/return.adoc[tag=clauses_return_with_column_alias] + +[.description] +Names of returned columns can be aliased using the `AS` operator. +==== + +==== +include::ROOT:clauses/return.adoc[tag=clauses_return_distinct] + +[.description] +`DISTINCT` retrieves unique rows for the returned columns. +==== + +==== +[.description] +-- +The `RETURN` clause can use: + +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/order-by[`ORDER BY`] +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/skip[`SKIP`] +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/limit[`LIMIT`] +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/where[`WHERE`] +-- +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/role-management.adoc b/modules/cheat-sheet/pages/role-management.adoc new file mode 100644 index 000000000..e9be53a4f --- /dev/null +++ b/modules/cheat-sheet/pages/role-management.adoc @@ -0,0 +1,128 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/manage-roles/[ROLE Management^] + + +==== +[source, cypher, role=noheader] +---- +SHOW ROLES +---- + +[.description] +List all roles in the system, returns the output `role`. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW ROLES +WHERE role CONTAINS $subString +---- + +[.description] +List roles that contains a given string. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW POPULATED ROLES +---- + +[.description] +List all roles that are assigned to at least one user in the system. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW POPULATED ROLES WITH USERS +---- + +[.description] +List all roles that are assigned to at least one user in the system, and the users assigned to those roles. The returned outputs are `role` and `member`. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW POPULATED ROLES WITH USERS +YIELD member, role +WHERE member = $user +RETURN role +---- + +[.description] +List all roles that are assigned to a `$user`. +// The explicit `YIELD member, role` must be present to be able to do a `RETURN role +==== + + +==== +[source, cypher, role=noheader] +---- +DROP ROLE role_name +---- + +[.description] +Delete a role. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE ROLE role_name IF NOT EXISTS +---- + +[.description] +Create a role, unless it already exists. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE ROLE role_name AS COPY OF other_role_name +---- + +[.description] +Create a role, as a copy of the existing `other_role_name`. +==== + + +==== +[source, cypher, role=noheader] +---- +RENAME ROLE role_name TO other_role_name +---- + +[.description] +Rename a role. +==== + + +==== +[source, cypher, role=noheader] +---- +GRANT ROLE role_name1, role_name2 TO user_name +---- + +[.description] +Assign roles to a user. +==== + + +==== +[source, cypher, role=noheader] +---- +REVOKE ROLE role_name FROM user_name +---- + +[.description] +Remove the specified role from a user. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/scalar-functions.adoc b/modules/cheat-sheet/pages/scalar-functions.adoc new file mode 100644 index 000000000..b7ec04295 --- /dev/null +++ b/modules/cheat-sheet/pages/scalar-functions.adoc @@ -0,0 +1,184 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/[Scalar functions^] + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_char_length] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-char_length[`char_length()`^] function returns the number of Unicode characters in a `STRING`. +This function is an alias of the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-size[`size()`^] function. +==== + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_character_length] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-character_length[`character_length()`^] function returns the number of Unicode characters in a `STRING`. +This function is an alias of the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-size[`size()`^] function. +==== + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_coalesce] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-coalesce[`coalesce()`^] function returns the first given non-null argument. +==== + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_element_id] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-elementid[`elementId()`^] function returns a `STRING` representation of a node or relationship identifier, unique within a specific transaction and DBMS. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_end_node] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-endnode[`endNode()`^] function returns the the end `NODE` of a `RELATIONSHIP`. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_head] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-head[`head()`^] function returns the first element of the list. Returns `null` for an empty list. Equivalent to the list indexing `$list[0]`. +==== + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_id] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-id[`id()`^] function returns an `INTEGER` (the internal ID of a node or relationship). Do not rely on the internal ID for your business domain; the internal ID can change between transactions. It is recommended to use `elementId` instead. +==== + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_last] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-last[`last()`^] function returns the last element of the list. Returns `null` for an empty list. Equivalent to the list indexing `$list[-1]`. +==== + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_length] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-length[`length()`^] function returns the length of a `PATH`. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_null_if] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-nullIf[`nullIf()`^] function returns `null` if the two given parameters are equivalent, otherwise it returns the value of the first parameter. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_properties] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-properties[`properties()`^] function returns a `MAP` containing all the properties of a node or relationship. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_random_uuid] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-randomuuid[`randomUUID()`^] function returns a `STRING`; a randomly-generated universally unique identifier (UUID). +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_size] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-size[`size()`^] function returns the number of elements in the list. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_start_node] + +[.description] +The function link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-startnode[`startNode()`^] function returns the start `NODE` of a `RELATIONSHIP`. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_timestamp] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-timestamp[`timestamp()`^] function returns the time in milliseconds since `midnight, January 1, 1970 UTC.` and the current time. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_to_boolean] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-toboolean[`toBoolean()`^] function converts a `STRING`, `INTEGER` or `BOOLEAN` value to a `BOOLEAN` value. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_to_boolean_or_null] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-tobooleanornull[`toBooleanOrNull()`^] function converts a `STRING`, `INTEGER` or `BOOLEAN` value to a `BOOLEAN` value. +For any other input value, `null` will be returned. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_to_float] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-tofloat[`toFloat()`^] function converts an `INTEGER`, `FLOAT` or a `STRING` value to a `FLOAT`. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_to_float_or_null] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-tofloatornull[`toFloatOrNull()`^] function converts an `INTEGER`, `FLOAT` or a `STRING` value to a `FLOAT`. +For any other input value, `null` will be returned. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_to_integer] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-tointeger[`toInteger()`^] function converts a `BOOLEAN`, `INTEGER`, `FLOAT` or a `STRING` value to an `INTEGER` value. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_to_integer_or_null] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-tointegerornull[`toIntegerOrNull()`^] function converts a `BOOLEAN`, `INTEGER`, `FLOAT` or a `STRING` value to an `INTEGER` value. +For any other input value, `null` will be returned. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_type] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-type[`type()`^] function returns the `STRING` representation of the `RELATIONSHIP` type. +==== + + +==== +include::ROOT:functions/scalar.adoc[tag=functions_scalar_value_type] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-valueType[`valueType()`^] function returns a `STRING` representation of the most precise value type that the given expression evaluates to. +==== diff --git a/modules/cheat-sheet/pages/search-performance-index.adoc b/modules/cheat-sheet/pages/search-performance-index.adoc new file mode 100644 index 000000000..77ff222b8 --- /dev/null +++ b/modules/cheat-sheet/pages/search-performance-index.adoc @@ -0,0 +1,240 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/indexes/search-performance-indexes/managing-indexes/[Search-performance indexes] + +Cypher includes four search-performance indexes: range (default), text, point, and token lookup. + +==== +[source, cypher, role=noheader] +---- +CREATE INDEX index_name +FOR (p:Person) ON (p.name) +---- + +[.description] +-- +Create a range index with the name `index_name` on nodes with label `Person` and property `name`. + +It is possible to omit the `index_name`, if not specified the index name will be decided by the DBMS. Best practice is to always specify a sensible name when creating an index. + +The create syntax is `CREATE [RANGE|TEXT|POINT|LOOKUP|FULLTEXT|VECTOR] INDEX ...`. Defaults to range if not explicitly stated. +-- +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE RANGE INDEX index_name +FOR ()-[k:KNOWS]-() ON (k.since) +---- + +[.description] +Create a range index on relationships with type `KNOWS` and property `since` with the name `index_name`. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE INDEX $nameParam +FOR (p:Person) ON (p.name, p.age) +---- + +[.description] +Create a composite range index with the name given by the parameter `nameParam` on nodes with label `Person` and the properties `name` and `age`, throws an error if the index already exist. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE INDEX index_name IF NOT EXISTS +FOR (p:Person) ON (p.name, p.age) +---- + +[.description] +Create a composite range index with the name `index_name` on nodes with label `Person` and the properties `name` and `age` if it does not already exist, does nothing if it did exist. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE TEXT INDEX index_name +FOR (p:Person) ON (p.name) +---- + +[.description] +-- +Create a text index on nodes with label `Person` and property `name`. +Text indexes only solve predicates involving `STRING` property values. +-- +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE TEXT INDEX index_name +FOR ()-[r:KNOWS]-() ON (r.city) +---- + +[.description] +Create a text index on relationships with type `KNOWS` and property `city`. +Text indexes only solve predicates involving `STRING` property values. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE POINT INDEX index_name +FOR (p:Person) ON (p.location) +OPTIONS { + indexConfig: { + `spatial.cartesian.min`: [-100.0, -100.0], + `spatial.cartesian.max`: [100.0, 100.0] + } +} +---- + +[.description] +Create a point index on nodes with label `Person` and property `location` with the name `index_name` and the given `spatial.cartesian` settings. The other index settings will have their default values. +Point indexes only solve predicates involving `POINT` property values. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE POINT INDEX $nameParam +FOR ()-[h:STREET]-() ON (h.intersection) +---- + +[.description] +Create a point index with the name given by the parameter `nameParam` on relationships with the type `STREET` and property `intersection`. +Point indexes only solve predicates involving `POINT` property values. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE LOOKUP INDEX index_name +FOR (n) ON EACH labels(n) +---- + +[.description] +Create a token lookup index on nodes with any label. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE LOOKUP INDEX index_name +FOR ()-[r]-() ON EACH type(r) +---- + +[.description] +Create a token lookup index on relationships with any relationship type. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW INDEXES +---- + +[.description] +List all indexes, returns only the default outputs (`id`, `name`, `state`, `populationPercent`, `type`, `entityType`, `labelsOrTypes`, `properties`, `indexProvider`, `owningConstraint`, `lastRead`, and `readCount`). +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW INDEXES YIELD * +---- + +[.description] +List all indexes and return all columns. +==== + +==== +[source, cypher, role=noheader] +---- +SHOW INDEX YIELD name, type, entityType, labelsOrTypes, properties +---- + +[.description] +List all indexes and return only specific columns. +==== + +==== +[source, cypher, role=noheader] +---- +SHOW INDEXES +YIELD name, type, options, createStatement +RETURN name, type, options.indexConfig AS config, createStatement +---- + +[.description] +List all indexes and return only specific columns using the `RETURN` clause. +Note that `YIELD` is mandatory if `RETURN` is used. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW RANGE INDEXES +---- + +[.description] +List range indexes, can also be filtered on `ALL`, `FULLTEXT`, `LOOKUP`, `POINT`, `TEXT`, and `VECTOR`. +==== + + +==== +[source, cypher, role=noheader] +---- +DROP INDEX index_name +---- + +[.description] +Drop the index named `index_name`, throws an error if the index does not exist. +==== + + +==== +[source, cypher, role=noheader] +---- +DROP INDEX index_name IF EXISTS +---- + +[.description] +Drop the index named `index_name` if it exists, does nothing if it does not exist. +==== + +==== +[source, cypher, role=noheader] +---- +DROP INDEX $nameParam +---- + +[.description] +Drop an index using a parameter. +==== + +==== +[source, cypher, role=noheader] +---- +MATCH (n:Person) +USING INDEX n:Person(name) +WHERE n.name = $value +---- + +[.description] +Index usage can be enforced when Cypher uses a suboptimal index, or when more than one index should be used. +==== diff --git a/modules/cheat-sheet/pages/server-management.adoc b/modules/cheat-sheet/pages/server-management.adoc new file mode 100644 index 000000000..d8d878a2e --- /dev/null +++ b/modules/cheat-sheet/pages/server-management.adoc @@ -0,0 +1,79 @@ += link:{neo4j-docs-base-uri}/operations-manual/current/clustering/servers/[SERVER Management^] + + +[neo4j-ee.aura-dbe.aura-dbc] +==== +[source, cypher, role=noheader] +---- +SHOW SERVERS +---- + +[.description] +Display all servers running in the cluster, including servers that have yet to be enabled as well as dropped servers. Default outputs are: `name`, `address`, `state`, `health`, and `hosting`. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +ENABLE SERVER 'serverId' +---- + +[.description] +Make the server with the ID `serverId` an active member of the cluster. +==== + +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] +==== +[source, cypher, role=noheader] +---- +RENAME SERVER 'oldName' TO 'newName' +---- + +[.description] +Change the name of a server. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +ALTER SERVER 'name' SET OPTIONS {modeConstraint: 'PRIMARY'} +---- + +[.description] +Only allow the specified server to host databases in primary mode. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +REALLOCATE DATABASES +---- + +[.description] +Re-balance databases among the servers in the cluster. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +DEALLOCATE DATABASES FROM SERVER 'name' +---- + +[.description] +Remove all databases from the specified server, adding them to other servers as needed. The specified server is not allowed to host any new databases. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +DROP SERVER 'name' +---- + +[.description] +Remove the specified server from the cluster. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/set.adoc b/modules/cheat-sheet/pages/set.adoc new file mode 100644 index 000000000..5f7eb5c3a --- /dev/null +++ b/modules/cheat-sheet/pages/set.adoc @@ -0,0 +1,94 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/set/[SET^] + + + +==== +[source, cypher, role=noheader] +---- +SET e.property1 = $value1 +---- + +[.description] +Update or create a property. +==== + + +==== +[source, cypher, role=noheader] +---- +SET + e.property1 = $value1, + e.property2 = $value2 +---- + +[.description] +Update or create several properties. +==== + +==== +[source, cypher, role=noheader] +---- +MATCH (n) +SET n[$key] = value +---- + +[.description] +Dynamically set or update node properties. +==== + +==== +[source, cypher, role=noheader] +---- +MATCH (n) +SET n:$($label) +---- + +[.description] +Dynamically set node labels. +==== + + +==== +[source, cypher, role=noheader] +---- +SET e = $map +---- + +[.description] +Set all properties. This will remove any existing properties. +==== + + +==== +[source, cypher, role=noheader] +---- +SET e = {} +---- + +[.description] +Using the empty map (`{}`), removes any existing properties. +==== + + +==== +[source, cypher, role=noheader] +---- +SET e += $map +---- + +[.description] +Add and update properties, while keeping existing ones. +==== + + +==== +[source, cypher, role=noheader] +---- +MATCH (n:Label) +WHERE n.id = 123 +SET n:Person +---- + +[.description] +Add a label to a node. This example adds the label `Person` to a node. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/shortest-paths.adoc b/modules/cheat-sheet/pages/shortest-paths.adoc new file mode 100644 index 000000000..52773bfac --- /dev/null +++ b/modules/cheat-sheet/pages/shortest-paths.adoc @@ -0,0 +1,31 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/patterns/#shortest-paths[Shortest paths^] + +==== +include::ROOT:patterns/shortest-paths.adoc[tag=patterns_shortest_paths_shortest_k] + + +[.description] +`SHORTEST k` finds the shortest path(s) (by number of hops) between nodes, where `k` is the number of paths to match. +==== + +==== +include::ROOT:patterns/shortest-paths.adoc[tag=patterns_shortest_paths_all_shortest] + +[.description] +Find all shortest paths between two nodes. +==== + +==== +include::ROOT:patterns/shortest-paths.adoc[tag=patterns_shortest_paths_shortest_k_groups] + +[.description] +`SHORTEST k GROUPS` returns all paths that are tied for first, second, and so on, up to the kth shortest length. +This example finds all paths with the first and second shortest lengths between two nodes. +==== + +==== +include::ROOT:patterns/shortest-paths.adoc[tag=patterns_shortest_paths_any] + +[.description] +The `ANY` keyword can be used to test the reachability of nodes from a given node(s). It returns the same as `SHORTEST 1`, but by using the `ANY` keyword the intent of the query is clearer. +==== diff --git a/modules/cheat-sheet/pages/show-functions.adoc b/modules/cheat-sheet/pages/show-functions.adoc new file mode 100644 index 000000000..7557f3ac8 --- /dev/null +++ b/modules/cheat-sheet/pages/show-functions.adoc @@ -0,0 +1,46 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/listing-functions/[SHOW FUNCTIONS^] + + + +==== +[source, cypher, role=noheader] +---- +SHOW FUNCTIONS +---- + +[.description] +List all available functions, returns only the default outputs (`name`, `category`, and `description`). +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW BUILT IN FUNCTIONS YIELD * +---- + +[.description] +List built-in functions, can also be filtered on `ALL` or `USER-DEFINED` . +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW FUNCTIONS EXECUTABLE BY CURRENT USER YIELD * +---- + +[.description] +Filter the available functions for the current user. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW FUNCTIONS EXECUTABLE BY user_name +---- + +[.description] +Filter the available functions for the specified user. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/show-privileges.adoc b/modules/cheat-sheet/pages/show-privileges.adoc new file mode 100644 index 000000000..312c865b5 --- /dev/null +++ b/modules/cheat-sheet/pages/show-privileges.adoc @@ -0,0 +1,90 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/manage-privileges/#access-control-list-privileges[SHOW Privileges^] + + +==== +[source, cypher, role=noheader] +---- +SHOW PRIVILEGES +---- + +[.description] +List all privileges in the system, and the roles that they are assigned to. Outputs returned are: `access`, `action`, `resource`, `graph`, `segment`, `role`, and `immutable`. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW PRIVILEGES AS COMMANDS +---- + +[.description] +List all privileges in the system as Cypher commands, for example `GRANT ACCESS ON DATABASE * TO `admin``. Returns only the default output (`command`). +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW USER PRIVILEGES +---- + +[.description] +List all privileges of the currently logged-in user, and the roles that they are assigned to. Outputs returned are: `access`, `action`, `resource`, `graph`, `segment`, `role`, `immutable`, and `user`. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW USER PRIVILEGES AS COMMANDS +---- + +[.description] +List all privileges of the currently logged-in user, and the roles that they are assigned to as Cypher commands, for example `GRANT ACCESS ON DATABASE * TO $role`. Returns only the default output (`command`). +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW USER user_name PRIVILEGES +---- + +[.description] +List all privileges assigned to each of the specified users (multiple users can be specified separated by commas `n1, n2, n3`), and the roles that they are assigned to. Outputs returned are: `access`, `action`, `resource`, `graph`, `segment`, `role`, `immutable`, and `user`. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW USER user_name PRIVILEGES AS COMMANDS YIELD * +---- + +[.description] +List all privileges assigned to each of the specified users (multiple users can be specified separated by commas `n1, n2, n3`), as generic Cypher commands, for example `GRANT ACCESS ON DATABASE * TO $role`. Outputs returned are: `command` and `immutable`. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW ROLE role_name PRIVILEGES +---- + +[.description] +List all privileges assigned to each of the specified roles (multiple roles can be specified separated by commas `r1, r2, r3`). Outputs returned are: `access`, `action`, `resource`, `graph`, `segment`, `role`, and `immutable`. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW ROLE role_name PRIVILEGES AS COMMANDS +---- + +[.description] +List all privileges assigned to each of the specified roles (multiple roles can be specified separated by commas `r1, r2, r3`) as Cypher commands, for example `GRANT ACCESS ON DATABASE * TO `admin``. Returns only the default output (`command`). +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/show-procedures.adoc b/modules/cheat-sheet/pages/show-procedures.adoc new file mode 100644 index 000000000..fc8a2c37a --- /dev/null +++ b/modules/cheat-sheet/pages/show-procedures.adoc @@ -0,0 +1,35 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/listing-procedures/[SHOW PROCEDURES^] + + + +==== +[source, cypher, role=noheader] +---- +SHOW PROCEDURES +---- + +[.description] +List all available procedures, returns only the default outputs (`name`, `description`, `mode`, and `worksOnSystem`). +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW PROCEDURES YIELD * +---- + +[.description] +List all available procedures. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW PROCEDURES EXECUTABLE YIELD name +---- + +[.description] +List all procedures that can be executed by the current user and return only the name of the procedures. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/show-settings.adoc b/modules/cheat-sheet/pages/show-settings.adoc new file mode 100644 index 000000000..d1e0cce3f --- /dev/null +++ b/modules/cheat-sheet/pages/show-settings.adoc @@ -0,0 +1,39 @@ +[role=label--community-edition label--enterprise-edition] += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/listing-settings/[SHOW SETTINGS^] + + +[role=label--community-edition label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +SHOW SETTINGS +---- + +[.description] +List configuration settings (within the instance), returns only the default outputs (`name`, `value`, `isDynamic`, `defaultValue`, and `description`). +==== + + +[role=label--community-edition label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +SHOW SETTINGS YIELD * +---- + +[.description] +List configuration settings (within the instance). +==== + + +[role=label--community-edition label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +SHOW SETTINGS 'server.bolt.advertised_address', 'server.bolt.listen_address' YIELD * +---- + +[.description] +List the configuration settings (within the instance) named `server.bolt.advertised_address` and `server.bolt.listen_address`. +As long as the setting names evaluate to a string or a list of strings at runtime, they can be any expression. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/show-supported-privileges.adoc b/modules/cheat-sheet/pages/show-supported-privileges.adoc new file mode 100644 index 000000000..a6b2a9452 --- /dev/null +++ b/modules/cheat-sheet/pages/show-supported-privileges.adoc @@ -0,0 +1,14 @@ +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/manage-privileges/#access-control-list-supported-privileges[SHOW SUPPORTED Privileges^] + + +==== +[source, cypher, role=noheader] +---- +SHOW SUPPORTED PRIVILEGES +---- + +[.description] +List all privileges that are possible to grant or deny on a server. +Outputs returned are: `action`, `qualifier`, `target`, `scope`, and `description`. +==== diff --git a/modules/cheat-sheet/pages/show-transactions.adoc b/modules/cheat-sheet/pages/show-transactions.adoc new file mode 100644 index 000000000..f7fb8a79a --- /dev/null +++ b/modules/cheat-sheet/pages/show-transactions.adoc @@ -0,0 +1,36 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/transaction-clauses/#query-listing-transactions[SHOW TRANSACTIONS^] + + + +==== +[source, cypher, role=noheader] +---- +SHOW TRANSACTIONS +---- + +[.description] +List running transactions (within the instance), returns only the default outputs (`database`, `transactionId`, `currentQueryId`, `connectionId`, `clientAddress`, `username`, `currentQuery`, `startTime`, `status`, and `elapsedTime`). +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW TRANSACTIONS YIELD * +---- + +[.description] +List running transactions (within the instance). +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW TRANSACTIONS 'transaction_id' YIELD * +---- + +[.description] +List the running transaction (within the instance), with a specific `transaction_id`. +As long as the transaction IDs evaluate to a string or a list of strings at runtime, they can be any expression. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/skip.adoc b/modules/cheat-sheet/pages/skip.adoc new file mode 100644 index 000000000..ef12799a2 --- /dev/null +++ b/modules/cheat-sheet/pages/skip.adoc @@ -0,0 +1,23 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/skip/[SKIP^] + +==== +include::ROOT:clauses/skip.adoc[tag=clauses_skip] + +[.description] +`SKIP` defines from which row to start including the rows in the output. +It can be used in conjunction with link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/limit/[`LIMIT`] and link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/order-by/[`ORDER BY`]. +==== + +==== +include::ROOT:clauses/skip.adoc[tag=clauses_skip_standalone] + +[.description] +`SKIP` can be used as a standalone clause. +==== + +==== +include::ROOT:clauses/skip.adoc[tag=clauses_skip_offset] + +[.description] +`OFFSET` can be used as a synonym to `SKIP`. +==== diff --git a/modules/cheat-sheet/pages/spatial-functions.adoc b/modules/cheat-sheet/pages/spatial-functions.adoc new file mode 100644 index 000000000..7ab758320 --- /dev/null +++ b/modules/cheat-sheet/pages/spatial-functions.adoc @@ -0,0 +1,50 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/spatial/[Spatial functions^] + + +==== +include::ROOT:functions/spatial.adoc[tag=functions_spatial_point_cartesian_2d] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/spatial/#functions-point-cartesian-2d[`point()` Cartesian 2D^] function returns a 2D `POINT` in the _Cartesian_ CRS corresponding to the given coordinate values. +==== + + +==== +include::ROOT:functions/spatial.adoc[tag=functions_spatial_point_cartesian_3d] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/spatial/#functions-point-cartesian-3d[`point()` Cartesian 3D^] function returns a 3D `POINT` in the _Cartesian_ CRS corresponding to the given coordinate values. +==== + + +==== +include::ROOT:functions/spatial.adoc[tag=functions_spatial_point_wgs_84_2d] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/spatial/#functions-point-wgs84-2d[`point()` WGS 84 2D^] function returns a 2D `POINT` in the _WGS 84 CRS_ corresponding to the given coordinate values. +==== + + +==== +include::ROOT:functions/spatial.adoc[tag=functions_spatial_point_wgs_84_3d] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/spatial/#functions-point-wgs84-3d[`point()` WGS 84 3D^] function returns a 3D `POINT` in the _WGS 84 CRS_ corresponding to the given coordinate values. +==== + + +==== +include::ROOT:functions/spatial.adoc[tag=functions_spatial_point_distance] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/spatial/#functions-distance[`point.distance()`^] function returns returns a `FLOAT` representing the geodesic distance between two points in the same Coordinate Reference System (CRS). +==== + + +==== +include::ROOT:functions/spatial.adoc[tag=functions_spatial_point_within_bbox] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/spatial/#functions-withinBBox[`point.withinBBox()`^] function takes the following arguments: the `POINT` to check, the lower-left (south-west) `POINT` of a bounding box, and the upper-right (or north-east) `POINT` of a bounding box. +The return value will be true if the provided point is contained in the bounding box (boundary included), otherwise the return value will be false. +==== diff --git a/modules/cheat-sheet/pages/string-concatenation-operators.adoc b/modules/cheat-sheet/pages/string-concatenation-operators.adoc new file mode 100644 index 000000000..db9c8e81b --- /dev/null +++ b/modules/cheat-sheet/pages/string-concatenation-operators.adoc @@ -0,0 +1,58 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/expressions/string-operators/[String concatenation operators^] + +==== +include::ROOT:expressions/string-operators.adoc[tag=expressions_string_concatenation_basic] + +[.description] +Cypher contains two operators for the concatenation of `STRING` values: `||` and `\+` +The two operators are functionally equivalent. +However, `||` is GQL conformant, while `+` is not. +==== + +==== +include::ROOT:expressions/string-operators.adoc[tag=expressions_string_concatenation_whitespace] + +[.description] +Cypher does not insert spaces when concatenating `STRING` values. +==== + + +==== +include::ROOT:expressions/string-operators.adoc[tag=expressions_string_concatenation_properties] + +[.description] +String concatenation on two `STRING` properties. +==== + + +==== +include::ROOT:expressions/string-operators.adoc[tag=expressions_string_concatenation_prefix_suffix_separator] + +[.description] +String concatenation adding a prefix, suffix, and separator. +==== + + +==== +include::ROOT:expressions/string-operators.adoc[tag=expressions_string_concatenation_concatenate_strings_in_list] + +[.description] +`STRING` values in a `LIST` can be concatenated using the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/list/#functions-reduce[`reduce()`] function. +==== + + +==== +include::ROOT:expressions/string-operators.adoc[tag=expressions_string_concatenation_concatenate_skip_null] + +[.description] +Concatenating a `STRING` value with `NULL` returns `NULL`. +To skip the first `NULL` value in a list of expressions, use the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/scalar/#functions-coalesce[`coalesce()`] function. +==== + + +==== +include::ROOT:expressions/string-operators.adoc[tag=expressions_string_concatenation_concatenate_list_comprehension] + +[.description] +List comprehension allows concatenating a `STRING` value to each item in a `LIST` to generate a new `LIST` of modified `STRING` values. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/string-functions.adoc b/modules/cheat-sheet/pages/string-functions.adoc new file mode 100644 index 000000000..28d6ab937 --- /dev/null +++ b/modules/cheat-sheet/pages/string-functions.adoc @@ -0,0 +1,137 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/[String functions^] + +==== +include::ROOT:functions/string.adoc[tag=functions_string_btrim] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-btrim[`btrim()`^] function returns the original `STRING` with leading and trailing `trimCharacterString` characters removed. +If `trimCharacterString` is not specified then all leading and trailing whitespace will be removed. +==== + +==== +include::ROOT:functions/string.adoc[tag=functions_string_left] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-left[`left()`^] function returns a `STRING` containing the specified number of leftmost characters of the given `STRING`. +==== + +==== +include::ROOT:functions/string.adoc[tag=functions_string_lower] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-lower[`lower()`^] function returns the given `STRING` in lowercase. +This function is an alias of the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-tolower[`toLower`^] function. +==== + + +==== +include::ROOT:functions/string.adoc[tag=functions_string_ltrim] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-ltrim[`ltrim()`^] function returns the original `STRING` with leading `trimCharacterString` characters removed. +If `trimCharacterString` is not specified then all leading whitespace will be removed. +==== + +==== +include::ROOT:functions/string.adoc[tag=functions_string_normalize] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-normalize[`normalize()`^] function returns a given `STRING` normalized using the `NFC` Unicode normalization form. +==== + +==== +include::ROOT:functions/string.adoc[tag=functions_string_replace] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-replace[`replace()`^] function returns a `STRING` in which all occurrences of a specified `STRING` in the given `STRING` have been replaced by another (specified) replacement `STRING`. +==== + + +==== +include::ROOT:functions/string.adoc[tag=functions_string_reverse] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-reverse[`reverse()`^] function returns a `STRING` in which the order of all characters in the given `STRING` have been reversed. +==== + + +==== +include::ROOT:functions/string.adoc[tag=functions_string_right] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-right[`right()`^] function returns a `STRING` containing the specified number of rightmost characters in the given `STRING`. +==== + + +==== +include::ROOT:functions/string.adoc[tag=functions_string_rtrim] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-rtrim[`rtrim()`^] function returns the given `STRING` with trailing `trimCharacterString` characters removed. +If `trimCharacterString` is not specified then all trailing whitespace will be removed. +==== + + +==== +include::ROOT:functions/string.adoc[tag=functions_string_split] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-split[`split()`^] function returns a `LIST` resulting from the splitting of the given `STRING` around matches of the given delimiter. +==== + + +==== +include::ROOT:functions/string.adoc[tag=functions_string_substring] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-substring[`substring()`^] function returns a substring of the given `STRING`, beginning with a zero-based index start and length. +==== + + +==== +include::ROOT:functions/string.adoc[tag=functions_string_to_lower] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-tolower[`toLower()`^] function returns the given `STRING` in lowercase. +==== + + +==== +include::ROOT:functions/string.adoc[tag=functions_string_to_string] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-tostring[`toString()`^] function converts an `INTEGER`, `FLOAT`, `BOOLEAN`, `STRING`, `POINT`, `DURATION`, `DATE`, `ZONED TIME`, `LOCAL TIME`, `LOCAL DATETIME` or `ZONED DATETIME` value to a `STRING`. +==== + + +==== +include::ROOT:functions/string.adoc[tag=functions_string_to_string_or_null] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-tostringornull[`toStringOrNull()`^] function converts an `INTEGER`, `FLOAT`, `BOOLEAN`, `STRING`, `POINT`, `DURATION`, `DATE`, `ZONED TIME`, `LOCAL TIME`, `LOCAL DATETIME` or `ZONED DATETIME` value to a `STRING`. +For any other input value, `null` will be returned. +==== + + +==== +include::ROOT:functions/string.adoc[tag=functions_string_to_upper] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-toupper[`toUpper()`^] function returns the given `STRING` in uppercase. +==== + + +==== +include::ROOT:functions/string.adoc[tag=functions_string_trim] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-trim[`trim()`^] function returns the given `STRING` with leading and trailing whitespace removed. +==== + +==== +include::ROOT:functions/string.adoc[tag=functions_string_upper] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-upper[`upper()`^] function returns the given `STRING` in uppercase. +This function is an alias of the link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/string/#functions-toupper[`toUpper()`^] function. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/string-operators.adoc b/modules/cheat-sheet/pages/string-operators.adoc new file mode 100644 index 000000000..babc876c4 --- /dev/null +++ b/modules/cheat-sheet/pages/string-operators.adoc @@ -0,0 +1,63 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/expressions/predicates/#string-operators[String operators^] + +==== +include::ROOT:expressions/predicates/string-operators.adoc[tag=expressions_predicates_string_operators_prefix] + +[.description] +The `STARTS WITH` operator checks if a `STRING` value begins with a specified prefix. +==== + +==== +include::ROOT:expressions/predicates/string-operators.adoc[tag=expressions_predicates_string_operators_suffix] + +[.description] +The `ENDS WITH` operator checks if a `STRING` value ends with a specified suffix +==== + + +==== +include::ROOT:expressions/predicates/string-operators.adoc[tag=expressions_predicates_string_operators_substring] + +[.description] +The `CONTAINS` operator checks if a `STRING` value contains a specified substring. +==== + + +==== +include::ROOT:expressions/predicates/string-operators.adoc[tag=expressions_predicates_string_operators_regex] + +[.description] +The regular expression operator `=~` checks if a `STRING`value matches a regular expression. +==== + + +==== +include::ROOT:expressions/predicates/string-operators.adoc[tag=expressions_predicates_string_operators_regex_flag] + +[.description] +The `=~` operator can be used with regular expression flags, such as `(?i)` for case-insensitive matching, to modify how the regex is applied. +==== + +==== +include::ROOT:expressions/predicates/string-operators.adoc[tag=expressions_predicates_string_operators_is_normalized] + +[.description] +The `IS NORMALIZED` operator is used to check whether the given `STRING` value is in the `NFC` Unicode normalization form. +==== + + +==== +include::ROOT:expressions/predicates/string-operators.adoc[tag=expressions_predicates_string_operators_is_not_normalized] + +[.description] +The `IS NOT NORMALIZED` operator is used to check whether the given `STRING` value is not in the `NFC` Unicode normalization form. +==== + + +==== +include::ROOT:expressions/predicates/string-operators.adoc[tag=expressions_predicates_string_operators_is_normalized_normalization_type] + +[.description] +It is possible to define which Unicode normalization type is used. +The available normalization types are: `NFC` (default), `NFD`, `NFKC`, and `NFKD`. +==== diff --git a/modules/cheat-sheet/pages/subqueries-call-in-transactions.adoc b/modules/cheat-sheet/pages/subqueries-call-in-transactions.adoc new file mode 100644 index 000000000..ba7c48226 --- /dev/null +++ b/modules/cheat-sheet/pages/subqueries-call-in-transactions.adoc @@ -0,0 +1,45 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/subqueries/subqueries-in-transactions/[CALL subqueries in transactions^] + +==== +include::ROOT:subqueries/subqueries-in-transactions.adoc[tag=subqueries_in_transactions_basic_example] + +[.description] +`CALL` subqueries can execute in separate, inner transactions, producing intermediate commits. +==== + +==== +include::ROOT:subqueries/subqueries-in-transactions.adoc[tag=subqueries_in_transactions_batching] + +[.description] +Specify the number of rows processed in each transaction. +==== + +==== +include::ROOT:subqueries/subqueries-in-transactions.adoc[tag=subqueries_in_transactions_error_behavior] + +[.description] +-- +There are four different option flags to control the behavior in case of an error occurring in any of the inner transactions: + +* `ON ERROR CONTINUE` - ignores a recoverable error and continues the execution of subsequent inner transactions. The outer transaction succeeds. +* `ON ERROR BREAK` - ignores a recoverable error and stops the execution of subsequent inner transactions. The outer transaction succeeds. +* `ON ERROR FAIL` - acknowledges a recoverable error and stops the execution of subsequent inner transactions. The outer transaction fails. +* `ON ERROR RETRY` - uses an exponential delay between retry attempts for transaction batches that fail due to transient errors (i.e. errors where retrying a transaction can be expected to give a different result), with an optional maximum retry duration. +If the transaction still fails after the maximum duration, the failure is handled according to an optionally specified fallback error handling mode (`THEN CONTINUE`, `THEN BREAK`, `THEN FAIL` (default)). +-- + +==== + +==== +include::ROOT:subqueries/subqueries-in-transactions.adoc[tag=subqueries_in_transactions_concurrent_transactions] + +[.description] +`CALL` subqueries can execute batches in parallel by appending `IN [n] CONCURRENT TRANSACTIONS`, where `n` is an optional concurrency value used to set the maximum number of transactions that can be executed in parallel. +==== + +==== +include::ROOT:subqueries/subqueries-in-transactions.adoc[tag=subqueries_in_transactions_deadlock_example] + +[.description] +`ON ERROR RETRY ... THEN CONTINUE` can be used to retry the execution of a transaction for a specified maximum duration before continuing the execution of subsequent inner transactions by ignoring any recoverable errors. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/subqueries-call.adoc b/modules/cheat-sheet/pages/subqueries-call.adoc new file mode 100644 index 000000000..bc76bdb1b --- /dev/null +++ b/modules/cheat-sheet/pages/subqueries-call.adoc @@ -0,0 +1,34 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/subqueries/call-subquery/[CALL^] + +==== +include::ROOT:subqueries/call-subquery.adoc[tag=subqueries_call_subquery_basic_example] + +[.description] +A `CALL` subquery is executed once for each row. +In this example, the `CALL` subquery executes three times. +==== + +==== +include::ROOT:subqueries/call-subquery.adoc[tag=subqueries_call_subquery_variable_scope] + +[.description] +Variables are imported into a `CALL` subquery using a link:https://neo4j.com/docs/cypher-manual/current/subqueries/call-subquery/#variable-scope-clause[variable scope clause], `CALL ()`, or an link:https://neo4j.com/docs/cypher-manual/current/subqueries/call-subquery/#importing-with[importing `WITH` clause] (deprecated). +In this example, the subquery will process each `Team` at a time and `collect` a list of all `Player` nodes. +==== + +==== +include::ROOT:subqueries/call-subquery.adoc[tag=subqueries_call_subquery_optional_call] + +[.description] +Optionally `CALL` a subquery. +Similar to OPTIONAL MATCH, any empty rows produced by the `OPTIONAL CALL` will return `null` and not affect the remainder of the subquery evaluation. +==== + + +==== +include::ROOT:subqueries/call-subquery.adoc[tag=subqueries_call_subquery_union] + +[.description] +`CALL` subqueries can be used to further process the results of a `UNION` query. +This example finds the youngest and the oldest `Player` in the graph. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/subqueries-collect-count-exists.adoc b/modules/cheat-sheet/pages/subqueries-collect-count-exists.adoc new file mode 100644 index 000000000..562fc1929 --- /dev/null +++ b/modules/cheat-sheet/pages/subqueries-collect-count-exists.adoc @@ -0,0 +1,56 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/subqueries[COUNT, COLLECT, and EXISTS^] +//// +[source, cypher, role=test-setup] +---- +CREATE +(andy:Swedish:Person {name: 'Andy', age: 36}), +(timothy:Person {name: 'Timothy', nickname: 'Tim', age: 25}), +(peter:Person {name: 'Peter', nickname: 'Pete', age: 35}), +(andy)-[:HAS_DOG {since: 2016}]->(:Dog {name:'Andy'}), +(timothy)-[:HAS_CAT {since: 2019}]->(:Cat {name:'Mittens'}), +(fido:Dog {name:'Fido'})<-[:HAS_DOG {since: 2010}]-(peter)-[:HAS_DOG {since: 2018}]->(:Dog {name:'Ozzy'}), +(fido)-[:HAS_TOY]->(:Toy{name:'Banana'}) +---- +//// + +==== +[source, cypher, role=noheader] +---- +MATCH (person:Person) +WHERE COUNT { (person)-[:HAS_DOG]->(:Dog) } > 1 +RETURN person.name AS name +---- + +[.description] +A `COUNT` subquery counts the number of rows returned by the subquery. +Unlike `CALL` subqueries, variables introduced by the outer scope can be used in `EXISTS`, `COLLECT`, and `COUNT` subqueries. +==== + +==== +[source, cypher, role=noheader] +---- +MATCH (person:Person) +WHERE EXISTS { + MATCH (person)-[:HAS_DOG]->(dog:Dog) + WHERE person.name = dog.name +} +RETURN person.name AS name +---- + +[.description] +An `EXISTS` subquery determines if a specified pattern exists at least once in the graph. +A `WHERE` clause can be used inside `COLLECT`, `COUNT`, and `EXISTS` patterns. +==== + +==== +[source, cypher, role=noheader] +---- +MATCH (person:Person) WHERE person.name = "Peter" +SET person.dogNames = COLLECT { MATCH (person)-[:HAS_DOG]->(d:Dog) RETURN d.name } +RETURN person.dogNames as dogNames +---- + +[.description] +A `COLLECT` subquery creates a list with the rows returned by the subquery. +`COLLECT`, `COUNT`, and `EXISTS` subqueries can be used inside other clauses. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/temporal-functions.adoc b/modules/cheat-sheet/pages/temporal-functions.adoc new file mode 100644 index 000000000..091f158bd --- /dev/null +++ b/modules/cheat-sheet/pages/temporal-functions.adoc @@ -0,0 +1,214 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/[Temporal functions^] + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_date] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-date[`date`^] function returns the current `DATE` value. +If no time zone parameter is specified, the local time zone will be used. +==== + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_date_realtime] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-date-realtime[`date.realtime()`] function returns the current `DATE` instant using the realtime clock. +==== + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_date_statement] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-date-statement[`date.statement()`] function returns the current `DATE` instant using the statement clock. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_date_transaction] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-date-transaction[`date.transaction()`] function returns the current `DATE` instant using the transaction clock. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_date_truncate] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-date-truncate[`date.truncate()`] function truncates the given temporal value to a `DATE` instant using the specified unit. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_datetime] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-datetime[`datetime()`] function creates a `ZONED DATETIME` instant. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_datetime_fromepoch] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-datetime-fromepoch[`datetime.fromEpoch()`] function creates a `ZONED DATETIME` given the seconds and nanoseconds since the start of the epoch. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_datetime_fromepochmillis] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-datetime-fromepochmillis[`datetime.fromEpochMillis()`] function creates a `ZONED DATETIME` given the milliseconds since the start of the epoch. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_datetime_realtime] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-datetime-realtime[`datetime.realtime()`] function returns the current `ZONED DATETIME` instant using the realtime clock. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_datetime_statement] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-datetime-statement[`datetime.statement()`] function returns the current `ZONED DATETIME` instant using the statement clock. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_datetime_transaction] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-datetime-transaction[`datetime.transaction()`] function returns the current `ZONED DATETIME` instant using the transaction clock. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_datetime_truncate] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-datetime-truncate[`datetime.truncate()`] function truncates the given temporal value to a `ZONED DATETIME` instant using the specified unit. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_localdatetime] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-localdatetime[`localdatetime()`] function creates a `LOCAL DATETIME` instant. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_localdatetime_realtime] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-localdatetime-realtime[`localdatetime.realtime()`] function returns the current `LOCAL DATETIME` instant using the realtime clock. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_localdatetime_statement] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-localdatetime-statement[`localdatetime.statement()`] function returns the current `LOCAL DATETIME` instant using the statement clock. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_localdatetime_transaction] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-localdatetime-transaction[`localdatetime.transaction()`] function returns the current `LOCAL DATETIME` instant using the transaction clock. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_localdatetime_truncate] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-localdatetime-truncate[`localdatetime.truncate()`] function truncates the given temporal value to a `LOCAL DATETIME` instant using the specified unit. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_localtime] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-localtime[`localtime()`] function creates a `LOCAL TIME` instant. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_localtime_realtime] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-localtime-realtime[`localtime.realtime()`] function creates a `LOCAL TIME` instant. function returns the current `LOCAL TIME` instant using the realtime clock. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_localtime_statement] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-localtime-statement[`localtime.statement()`] function creates a `LOCAL TIME` instant. function returns the current `LOCAL TIME` instant using the statement clock. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_localtime_transaction] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-localtime-transaction[`localtime.transaction()`] function returns the current `LOCAL TIME` instant using the transaction clock. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_localtime_truncate] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-localtime-truncate[`localtime.truncate()`] function truncates the given temporal value to a `LOCAL TIME` instant using the specified unit. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_time] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-time[`time()`] function creates a `ZONED TIME` instant. +==== + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_time_realtime] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-time-realtime[`time.realtime()`] function returns the current `ZONED TIME` instant using the realtime clock. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_time_statement] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-time-statement[`time.statement()`] function returns the current `ZONED TIME` instant using the statement clock. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_time_transaction] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-time-transaction[`time.transaction()`] function returns the current `ZONED TIME` instant using the transaction clock. +==== + + +==== +include::ROOT:functions/temporal/index.adoc[tag=functions_temporal_time_truncate] + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/temporal/#functions-time-truncate[`time.truncate()`] function truncates the given temporal value to a `ZONED TIME` instant using the specified unit. +==== diff --git a/modules/cheat-sheet/pages/temporal-operators.adoc b/modules/cheat-sheet/pages/temporal-operators.adoc new file mode 100644 index 000000000..a7a2539b8 --- /dev/null +++ b/modules/cheat-sheet/pages/temporal-operators.adoc @@ -0,0 +1,17 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/expressions/temporal-operators[Temporal operators^] + +==== +include::ROOT:expressions/temporal-operators.adoc[tag=expressions_temporal_operators_add_duration_to_instant] + +[.description] +`DURATION` values can be added and subtracted from temporal instant values, such as `LOCAL DATETIME`. +==== + +==== +include::ROOT:expressions/temporal-operators.adoc[tag=expressions_temporal_operators_multiply_divide_duration] + +[.description] +When multiplying or dividing a `DURATION`, each component is handled separately. +In multiplication, the value of each component is multiplied by the given factor, while in division, each component is divided by the given number. +If the result of the division does not fit into the original components, it overflows into smaller components (e.g. converting days into hours). +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/terminate-transactions.adoc b/modules/cheat-sheet/pages/terminate-transactions.adoc new file mode 100644 index 000000000..24e05ed3e --- /dev/null +++ b/modules/cheat-sheet/pages/terminate-transactions.adoc @@ -0,0 +1,43 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/transaction-clauses/#query-terminate-transactions[TERMINATE TRANSACTIONS^] + + + +==== +[source, cypher, role=noheader] +---- +TERMINATE TRANSACTIONS 'transaction_id' +---- + +[.description] +Terminate a specific transaction, returns the outputs: `transactionId`, `username`, `message`. +==== + + +==== +[source, cypher, role=noheader] +---- +TERMINATE TRANSACTIONS $value + YIELD transactionId, message + RETURN transactionId, message +---- + +[.description] +Terminal transactions allow for `YIELD` clauses. As long as the transaction IDs evaluate to a string or a list of strings at runtime, they can be any expression. +==== + + +==== +[source, cypher, role=noheader] +---- + SHOW TRANSACTIONS + YIELD transactionId AS txId, username + WHERE username = 'user_name' +TERMINATE TRANSACTIONS txId + YIELD message + WHERE NOT message = 'Transaction terminated.' + RETURN txId +---- + +[.description] +List all transactions by the specified user and terminate them. Return the transaction IDs of the transactions that failed to terminate successfully. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/type-predicate-expressions.adoc b/modules/cheat-sheet/pages/type-predicate-expressions.adoc new file mode 100644 index 000000000..f699b06ac --- /dev/null +++ b/modules/cheat-sheet/pages/type-predicate-expressions.adoc @@ -0,0 +1,42 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/expressions/predicates/type-predicate-expressions/[Type predicate expressions^] + + +==== +include::ROOT:expressions/predicates/type-predicate-expressions.adoc[tag=expressions_predicates_type_predicate] + +[.description] +A type predicate expression can be used to verify the type of a variable, literal, property or other Cypher expression. +==== + +==== +include::ROOT:expressions/predicates/type-predicate-expressions.adoc[tag=expressions_predicates_type_predicate_not] + +[.description] +It is possible to verify that a Cypher expression is not of a certain type, using the negated type predicate expression `IS NOT ::`. +==== + + +==== +include::ROOT:expressions/predicates/type-predicate-expressions.adoc[tag=expressions_predicates_type_predicate_null] + +[.description] +All Cypher types includes the `NULL` value. +Type predicate expressions can be appended with `NOT NULL`. +This means that `IS ::` returns `TRUE` for all expressions evaluating to `NULL`, unless `NOT NULL` is appended. +==== + + +==== +include::ROOT:expressions/predicates/type-predicate-expressions.adoc[tag=expressions_predicates_type_predicate_properties] + +[.description] +Type predicate expressions can also be used to filter out nodes or relationships with properties of a certain type. +==== + + +==== +include::ROOT:expressions/predicates/type-predicate-expressions.adoc[tag=expressions_predicates_type_predicate_closed_dynamic_union] + +[.description] +Closed dynamic union types allow for the testing of multiple types in the same predicate. +==== diff --git a/modules/cheat-sheet/pages/union.adoc b/modules/cheat-sheet/pages/union.adoc new file mode 100644 index 000000000..19bc11d1a --- /dev/null +++ b/modules/cheat-sheet/pages/union.adoc @@ -0,0 +1,23 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/queries/combined-queries/[UNION^] + +==== +include::ROOT:queries/combined-queries.adoc[tag=combined_queries_union] + +[.description] +Return the distinct union of all query results. Result column types and names must match. +==== + +==== +include::ROOT:queries/combined-queries.adoc[tag=combined_queries_union_all] + +[.description] +Return the union of all query results, including duplicate rows. +==== + + +==== +include::ROOT:queries/combined-queries.adoc[tag=combined_queries_post_union_processing] + +[.description] +The `UNION` clause can be used within a `CALL` subquery to further process the combined results before a final output is returned. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/unwind.adoc b/modules/cheat-sheet/pages/unwind.adoc new file mode 100644 index 000000000..5a09b7119 --- /dev/null +++ b/modules/cheat-sheet/pages/unwind.adoc @@ -0,0 +1,34 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/unwind/[UNWIND^] + + + +==== +include::ROOT:clauses/unwind.adoc[tag=clauses_unwind_list] + +[.description] +-- +The `UNWIND` clause expands a list into a sequence of rows. + +Four rows are returned. +-- +==== + + +==== +include::ROOT:clauses/unwind.adoc[tag=clauses_unwind_create_nodes] + +[.description] +-- +Multiple `UNWIND` clauses can be chained to unwind nested list elements. + +Five rows are returned. +-- +==== + + +==== +include::ROOT:clauses/unwind.adoc[tag=clauses_unwind_list] + +[.description] +Create a number of nodes and relationships from a parameter-list without using `FOREACH`. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/use.adoc b/modules/cheat-sheet/pages/use.adoc new file mode 100644 index 000000000..925bdaf77 --- /dev/null +++ b/modules/cheat-sheet/pages/use.adoc @@ -0,0 +1,16 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/use/[USE^] + + +==== +include::ROOT:clauses/use.adoc[tag=clauses_use] + +[.description] +The `USE` clause determines which graph a query is executed against. This example assumes that the DBMS contains a database named `myDatabase`. +==== + +==== +include::ROOT:clauses/use.adoc[tag=clauses_use_composite] + +[.description] +This example assumes that the DBMS contains a composite database named `myComposite`, which includes an alias named `myConstituent`. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/user-management.adoc b/modules/cheat-sheet/pages/user-management.adoc new file mode 100644 index 000000000..2c834744b --- /dev/null +++ b/modules/cheat-sheet/pages/user-management.adoc @@ -0,0 +1,219 @@ += link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/manage-users/[USER Management^] + + + +==== +[source, cypher, role=noheader] +---- +SHOW USERS +---- + +[.description] +List all users in Neo4j DBMS, returns only the default outputs (`user`, `roles`, `passwordChangeRequired`, `suspended`, and `home`). +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW CURRENT USER +---- + +[.description] +List the currently logged-in user, returns only the default outputs (`user`, `roles`, `passwordChangeRequired`, `suspended`, and `home`). +==== + + +[role=label--enterprise-edition label--aura-db-free label--aura-db-professional label--aura-db-enterprise label--aura-db-business-critical label--aura-ds-professional label--aura-ds-enterprise] +==== +[source, cypher, role=noheader] +---- +SHOW USERS +WHERE suspended = true +---- + +[.description] +List users that are suspended. +==== + + +==== +[source, cypher, role=noheader] +---- +SHOW USERS +WHERE passwordChangeRequired +---- + +[.description] +List users that must change their password at the next login. +==== + +==== +[source, cypher, role=noheader] +---- +SHOW USERS WITH AUTH +---- + +[.description] +List users with their auth providers. Will return one row per user per auth provider. +==== + +==== +[source, cypher, role=noheader] +---- +SHOW USERS WITH AUTH WHERE provider = 'oidc1' +---- + +[.description] +List users who have the `oidc1` auth provider. +==== + + +==== +[source, cypher, role=noheader] +---- +DROP USER user_name +---- + +[.description] +Delete the specified user. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE USER user_name +SET PASSWORD $password +---- + +[.description] +Create a new user and set the password. This password must be changed on the first login. +==== + + +==== +[source, cypher, role=noheader] +---- +CREATE USER user_name +SET AUTH 'native' { + SET PASSWORD $password + SET PASSWORD CHANGE REQUIRED +} +---- +[.description] +Create a new user and set the password using the auth provider syntax. This password must be changed on the first login. +==== + + +==== +[source, cypher, role=noheader] +---- +RENAME USER user_name TO other_user_name +---- + +[.description] +Rename the specified user. +==== + + +==== +[source, cypher, role=noheader] +---- +ALTER CURRENT USER +SET PASSWORD FROM $oldPassword TO $newPassword +---- + +[.description] +Change the password of the logged-in user. The user will not be required to change this password on the next login. +==== + + +==== +[source, cypher, role=noheader] +---- +ALTER USER user_name +SET PASSWORD $password +CHANGE NOT REQUIRED +---- + +[.description] +Set a new password (a String) for a user. This user will not be required to change this password on the next login. +==== + + +==== +[source, cypher, role=noheader] +---- +ALTER USER user_name IF EXISTS +SET PASSWORD CHANGE REQUIRED +---- + +[.description] +If the specified user exists, force this user to change the password on the next login. +==== + +[role=label--enterprise-edition] +==== +[source, cypher, role=noheader] +---- +ALTER USER user_name +SET AUTH 'externalProviderName' { + SET ID 'userIdForExternalProvider' +} +---- +[.description] +Add another way for the user to authenticate and authorize using the external provider `externalProviderName`. +This provider needs to be defined in the configurations settings. +==== + +[role=label--enterprise-edition label--aura-db-free label--aura-db-professional label--aura-db-enterprise label--aura-db-business-critical label--aura-ds-professional label--aura-ds-enterprise] +==== +[source, cypher, role=noheader] +---- +ALTER USER user_name +SET STATUS SUSPENDED +---- + +[.description] +Change the status to `SUSPENDED`, for the specified user. +==== + + +[role=label--enterprise-edition label--aura-db-free label--aura-db-professional label--aura-db-enterprise label--aura-db-business-critical label--aura-ds-professional label--aura-ds-enterprise] +==== +[source, cypher, role=noheader] +---- +ALTER USER user_name +SET STATUS ACTIVE +---- + +[.description] +Change the status to `ACTIVE`, for the specified user. +==== + + +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] +==== +[source, cypher, role=noheader] +---- +ALTER USER user_name +SET HOME DATABASE `database-name` +---- + +[.description] +Set the home database for the specified user. The home database can either be a database or an alias. +==== + + +[role=label--enterprise-edition label--aura-db-enterprise label--aura-db-business-critical] +==== +[source, cypher, role=noheader] +---- +ALTER USER user_name +REMOVE HOME DATABASE +---- + +[.description] +Unset the home database for the specified user and fallback to the default database. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/variable-length-paths.adoc b/modules/cheat-sheet/pages/variable-length-paths.adoc new file mode 100644 index 000000000..144b12db9 --- /dev/null +++ b/modules/cheat-sheet/pages/variable-length-paths.adoc @@ -0,0 +1,22 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/patterns/variable-length-paths/[Variable-length paths^] + +==== +include::ROOT:patterns/variable-length-paths.adoc[tag=patterns_variable_length_paths_qpp] + +[.description] +Quantified path pattern matching a sequence of paths whose length is constrained to a specific range (1 to 3 in this case) between two nodes. +==== + +==== +include::ROOT:patterns/variable-length-paths.adoc[tag=patterns_variable_length_paths_quantified_relationships] + +[.description] +Quantified relationship matching paths where a specified relationship occurs between 1 and 10 times. +==== + +==== +include::ROOT:patterns/variable-length-paths.adoc[tag=patterns_variable_length_paths_predicates_in_qpp] + +[.description] +Quantified path pattern including a predicate. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/variable-length.adoc b/modules/cheat-sheet/pages/variable-length.adoc new file mode 100644 index 000000000..16f8ea2d8 --- /dev/null +++ b/modules/cheat-sheet/pages/variable-length.adoc @@ -0,0 +1,53 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/patterns/reference/#variable-length-relationships[Variable-length relationships^] + +==== +[source, cypher, role=noheader] +---- +(n:Label)-[*0..]->(m:Label) +---- + +[.description] +Variable-length path of between `0` or more hops between two nodes. +==== + +==== +[source, cypher, role=noheader] +---- +(n:Label)-[*3]->(m:Label) +---- + +[.description] +Variable-length path of exactly `3` hops between two nodes. +==== + + +==== +[source, cypher, role=noheader] +---- +(n:Label)-[*..3]->(m:Label) +---- + +[.description] +Variable-length path of between `1` and `3` hops between two nodes. +==== + + +==== +[source, cypher, role=noheader] +---- +(n:Label)-[*1..5]->(m:Label) +---- + +[.description] +Variable-length path of between `1` and `5` hops between two nodes. +==== + +==== +[source, cypher, role=noheader] +---- +(n:Label)-[*]->(m:Label) +---- + +[.description] +Variable-length path of one or more relationships (see the section on link:{neo4j-docs-base-uri}/cypher-cheat-sheet/{page-version}/#_performance_2[Performance] for more information). +==== diff --git a/modules/cheat-sheet/pages/vector-functions.adoc b/modules/cheat-sheet/pages/vector-functions.adoc new file mode 100644 index 000000000..851316af3 --- /dev/null +++ b/modules/cheat-sheet/pages/vector-functions.adoc @@ -0,0 +1,25 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/vector/[Vector functions^] + +==== +[source, cypher, role=noheader] +---- +MATCH (n:Label) +WITH n, vector.similarity.euclidean($query, n.vector) AS score +RETURN n, score +---- + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/vector/#functions-similarity-euclidean[`vector.similarity.euclidean()`^] function returns a `FLOAT` representing the similarity between the argument vectors based on their Euclidean distance. +==== + +==== +[source, cypher, role=noheader] +---- +MATCH (n:Label) +WITH n, vector.similarity.cosine($query, n.vector) AS score +RETURN n, score +---- + +[.description] +The link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions/vector/#functions-similarity-cosine[`vector.similarity.cosine()`^] function returns a `FLOAT` representing the similarity between the argument vectors based on their cosine. +==== diff --git a/modules/cheat-sheet/pages/vector-index.adoc b/modules/cheat-sheet/pages/vector-index.adoc new file mode 100644 index 000000000..63cc5f09e --- /dev/null +++ b/modules/cheat-sheet/pages/vector-index.adoc @@ -0,0 +1,99 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/indexes/semantic-indexes/vector-indexes/[Vector indexes] + +==== +[source, cypher, role=noheader] +---- +CREATE VECTOR INDEX `abstract-embeddings` +FOR (a:Abstract) ON (a.embedding) +OPTIONS { + indexConfig: { + `vector.dimensions`: 1536, + `vector.similarity_function`: 'cosine' + } +} +---- + +[.description] +Create a vector index on nodes with label `Abstract`, property `embedding`, and a vector dimension of `1536` using the `cosine` similarity function and the name `abstract-embeddings`. +Note that the `OPTIONS` map is mandatory since a vector index cannot be created without setting the vector dimensions and similarity function. +==== + +==== +[source, cypher, role=noheader] +---- +CREATE VECTOR INDEX `review-embeddings` +FOR ()-[r:REVIEWED]-() ON (r.embedding) +OPTIONS { + indexConfig: { + `vector.dimensions`: 256, + `vector.similarity_function`: 'cosine' + } +} +---- + +[.description] +Create a vector index on relationships with relationship type `REVIEWED`, property `embedding`, and a vector dimension of `256` using the `cosine` similarity function and the name `review-embeddings`. +Note that the `OPTIONS` map is mandatory since a vector index cannot be created without setting the vector dimensions and similarity function. +==== + +==== +[source, cypher, role=noheader] +---- +CALL db.index.vector.queryNodes('abstract-embeddings', 10, abstract.embedding) +---- + +[.description] +Query the node vector index `abstract-embeddings` for a neighborhood of `10` similar abstracts. +==== + +==== +[source, cypher, role=noheader] +---- +CALL db.index.vector.queryRelationships('review-embeddings', 10, $query) +---- + +[.description] +Query the relationship vector index `review-embeddings` for a neighborhood of `10` similar reviews to the vector given by the `query` parameter. +==== + +==== +[source, cypher, role=noheader] +---- +MATCH (n:Node {id: $id}) +CALL db.create.setNodeVectorProperty(n, 'propertyKey', $vector) +---- + +[.description] +Set the vector properties of a node using `db.create.setNodeVectorProperty`. +==== + +==== +[source, cypher, role=noheader] +---- +MATCH ()-[r:Relationship {id: $id}]->() +CALL db.create.setRelationshipVectorProperty(r, 'propertyKey', $vector) +---- + +[.description] +Set the vector properties of a relationship using `db.create.setRelationshipVectorProperty`. +==== + +==== +[source, cypher, role=noheader] +---- +SHOW VECTOR INDEXES +---- + +[.description] +List all vector indexes. +==== + +==== +[source, cypher, role=noheader] +---- +DROP INDEX `abstract-embeddings` +---- + +[.description] +Drop a vector index. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/where.adoc b/modules/cheat-sheet/pages/where.adoc new file mode 100644 index 000000000..f26d1b7b3 --- /dev/null +++ b/modules/cheat-sheet/pages/where.adoc @@ -0,0 +1,56 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/where/[WHERE^] + +==== +include::ROOT:clauses/where.adoc[tag=clauses_where_node_label] + +[.description] +`WHERE` used to filter on node labels. +==== + + +==== +include::ROOT:clauses/where.adoc[tag=clauses_where_node_property] + +[.description] +`WHERE` used to filter on node properties. +==== + + +==== +include::ROOT:clauses/where.adoc[tag=clauses_where_relationship_property] + +[.description] +`WHERE` used to filter on relationship properties. +==== + + +==== +include::ROOT:clauses/where.adoc[tag=clauses_where_dynamic] + +[.description] +To filter on a property using a dynamically computed name, use square brackets `[]`. +==== + + +==== +include::ROOT:clauses/where.adoc[tag=clauses_where_node_pattern] + +[.description] +`WHERE` used inside a fixed-length pattern. +==== + + +==== +include::ROOT:clauses/where.adoc[tag=clauses_where_pattern_comprehension] + +[.description] +`WHERE` can appear inside a pattern comprehension. +==== + + +==== +include::ROOT:clauses/where.adoc[tag=clauses_where_var_length] + +[.description] +`WHERE` can be used to filter variable-length patterns. +==== \ No newline at end of file diff --git a/modules/cheat-sheet/pages/with.adoc b/modules/cheat-sheet/pages/with.adoc new file mode 100644 index 000000000..a8b8b8c3b --- /dev/null +++ b/modules/cheat-sheet/pages/with.adoc @@ -0,0 +1,74 @@ += link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/with/[WITH^] + +==== +include::ROOT:clauses/with.adoc[tag=clauses_with_new_variable] + +[.description] +`WITH` can be used in combination with the `AS` keyword to bind new variables which can then be passed to subsequent clauses. +Any variables not explicitly referenced by `WITH` (or carried over by `WITH *`) are dropped from the scope of the query. +==== + +==== +include::ROOT:clauses/with.adoc[tag=clauses_with_all_variables] + +[.description] +Use the wildcard `*` to carry over all variables that are in scope. +==== + +==== +include::ROOT:clauses/with.adoc[tag=clauses_with_subquery] + +[.description] +`WITH` cannot de-scope variables imported to a `CALL` subquery, because variables imported to a subquery are considered global to its inner scope. +==== + +==== +include::ROOT:clauses/with.adoc[tag=clauses_with_bind_values] + +[.description] +`WITH` can be used to assign the values of expressions to variables. +==== + + +==== +include::ROOT:clauses/with.adoc[tag=clauses_with_chain_expressions] + +[.description] +`WITH` can be used to chain expressions. +==== + +==== +include::ROOT:clauses/with.adoc[tag=clauses_with_aggregations] + +[.description] +`WITH` can be used to perform aggregations and bind the results to new variables. +==== + +==== +include::ROOT:clauses/with.adoc[tag=clauses_with_remove_duplicates] + +[.description] +`WITH` can be used to remove duplicate values from the result set if appended with the modifier `DISTINCT`. +==== + + +==== +include::ROOT:clauses/with.adoc[tag=clauses_with_ordering_pagination] + +[.description] +`WITH` can order and paginate results if used together with the `ORDER BY`, `LIMIT`, and `SKIP` subclauses. +==== + +==== +include::ROOT:clauses/with.adoc[tag=clauses_with_filtering] + +[.description] +`WITH` can be followed by the `WHERE` subclause to filter results. +==== + +==== +include::ROOT:clauses/with.adoc[tag=clauses_with_combine_write_read] + +[.description] +If a write clause is followed by a read clause, `WITH` must be used as a separator between the two. +==== diff --git a/modules/cheat-sheet/pages/write-only-query-structure.adoc b/modules/cheat-sheet/pages/write-only-query-structure.adoc new file mode 100644 index 000000000..61d42b81a --- /dev/null +++ b/modules/cheat-sheet/pages/write-only-query-structure.adoc @@ -0,0 +1,29 @@ += Write-Only Query Structure + + +==== +[source, cypher, role=noheader] +---- +[USE] +[CREATE] +[MERGE [ON CREATE ...] [ON MATCH ...]] +[WITH [ORDER BY] [SKIP] [LIMIT] [WHERE]] +[SET] +[DELETE] +[REMOVE] +[RETURN [ORDER BY] [SKIP] [LIMIT]] +---- + +[.description] +-- +Baseline for write operations. + +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/create/[`CREATE`^] clause. +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/merge/[`MERGE`^] clause. +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/with/[`WITH`^] clause. +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/set/[`SET`^] clause. +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/delete/[`DELETE`^] clause. +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/remove/[`REMOVE`^] clause. +* link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/clauses/return/[`RETURN`^] clause. +-- +==== \ No newline at end of file diff --git a/preview.yml b/preview.yml index 0033ac2cb..1d557e837 100644 --- a/preview.yml +++ b/preview.yml @@ -36,7 +36,7 @@ asciidoc: - "@neo4j-antora/mark-terms" - asciidoctor-kroki attributes: - page-theme: docs + page-theme: docs@ page-type: Docs page-search-type: Docs page-search-site: Reference Docs diff --git a/publish.yml b/publish.yml index 453a6cfad..4b2a1f9cb 100644 --- a/publish.yml +++ b/publish.yml @@ -36,7 +36,7 @@ asciidoc: - "@neo4j-antora/mark-terms" - asciidoctor-kroki attributes: - page-theme: docs + page-theme: docs@ page-type: Docs page-search-type: Docs page-search-site: Reference Docs