Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -659,3 +659,6 @@ Addon
addon
LoadBalancer
NodePort
orphaned
replicas
SQL's
21 changes: 16 additions & 5 deletions commands/graph.delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@ parent: "Commands"

# GRAPH.DELETE

Completely removes the graph and all of its entities.
Completely removes a graph and all of its entities (nodes and relationships).

Arguments: `Graph name`
## Syntax

Returns: `String indicating if operation succeeded or failed.`
```
GRAPH.DELETE graph_name
```

**Arguments:**
- `graph_name` - Name of the graph to delete

**Returns:** String indicating if the operation succeeded or failed.

## Examples

{% capture shell_0 %}
GRAPH.DELETE us_government
Expand All @@ -36,7 +45,9 @@ graph.delete()?;

{% include code_tabs.html id="tabs_0" shell=shell_0 python=python_0 javascript=javascript_0 java=java_0 rust=rust_0 %}

Note: To delete a node from the graph (not the entire graph), execute a `MATCH` query and pass the alias to the `DELETE` clause:
## Deleting Individual Nodes

**Note:** To delete specific nodes or relationships (not the entire graph), use the Cypher `DELETE` clause with a `MATCH` query:

{% capture shell_1 %}
GRAPH.QUERY DEMO_GRAPH "MATCH (x:Y {propname: propvalue}) DELETE x"
Expand All @@ -60,5 +71,5 @@ graph.query("MATCH (x:Y {propname: propvalue}) DELETE x")?;

{% include code_tabs.html id="tabs_1" shell=shell_1 python=python_1 javascript=javascript_1 java=java_1 rust=rust_1 %}

WARNING: When you delete a node, all of the node's incoming/outgoing relationships are also removed.
**⚠️ Warning:** When you delete a node using the Cypher `DELETE` clause, all of the node's incoming and outgoing relationships are also automatically removed.

12 changes: 11 additions & 1 deletion commands/graph.info.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ parent: "Commands"

# GRAPH.INFO

Returns information and statistics about the current executing commands.
Returns information and statistics about currently running and waiting queries.

## Syntax

```
GRAPH.INFO [RunningQueries | WaitingQueries]
```

If no argument is provided, both running and waiting queries are returned.

## Examples

```sh
127.0.0.1:6379> GRAPH.INFO
Expand Down
24 changes: 15 additions & 9 deletions cypher/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,31 @@ parent: "Cypher Language"

# CREATE

CREATE is used to introduce new nodes and relationships.
The `CREATE` clause is used to introduce new nodes and relationships into the graph.

The simplest example of CREATE would be a single node creation:
## Creating Nodes

The simplest example creates a single node without any labels or properties:

```sh
CREATE (n)
```

It's possible to create multiple entities by separating them with a comma.
You can create multiple entities by separating them with commas:

```sh
CREATE (n),(m)
```

Create a node with a label and properties:

```sh
CREATE (:Person {name: 'Kurt', age: 27})
```

To add relations between nodes, in the following example we first find an existing source node. After it's found, we create a new relationship and destination node.
## Creating Relationships

To add relationships between nodes, you typically match existing nodes first, then create the relationship. In this example, we find an existing source node and create a new relationship with a new destination node:

```sh
GRAPH.QUERY DEMO_GRAPH
Expand All @@ -35,17 +41,17 @@ WHERE a.name = 'Kurt'
CREATE (a)-[:MEMBER]->(:Band {name:'Nirvana'})"
```

Here the source node is a bounded node, while the destination node is unbounded.
Here the source node `(a:Person)` is matched (bound), while the destination node `(:Band)` is unbound and will be created.

As a result, a new node is created representing the band Nirvana and a new relation connects Kurt to the band.
This query creates a new node representing the band Nirvana and a new `MEMBER` relationship connecting Kurt to the band.

Lastly we create a complete pattern.
## Creating Complete Patterns

All entities within the pattern which are not bounded will be created.
You can create entire graph patterns in a single statement. All entities within the pattern that are not bound (matched) will be created:

```sh
GRAPH.QUERY DEMO_GRAPH
"CREATE (jim:Person{name:'Jim', age:29})-[:FRIENDS]->(pam:Person {name:'Pam', age:27})-[:WORKS]->(:Employer {name:'Dunder Mifflin'})"
```

This query will create three nodes and two relationships.
This query creates three nodes (Jim, Pam, and an Employer) and two relationships (FRIENDS and WORKS), establishing a complete graph pattern in one operation.
32 changes: 28 additions & 4 deletions cypher/delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,44 @@ parent: "Cypher Language"

# DELETE

DELETE is used to remove both nodes and relationships.
The `DELETE` clause is used to remove nodes and relationships from the graph.

Note that deleting a node also deletes all of its incoming and outgoing relationships.
## Important Behavior

**⚠️ Note:** Deleting a node automatically deletes all of its incoming and outgoing relationships. You cannot have orphaned relationships in the graph.

## Deleting Nodes

To delete a node and all of its relationships:

```sh
GRAPH.QUERY DEMO_GRAPH "MATCH (p:Person {name:'Jim'}) DELETE p"
```

To delete relationship:
## Deleting Relationships

To delete specific relationships:

```sh
GRAPH.QUERY DEMO_GRAPH "MATCH (:Person {name:'Jim'})-[r:FRIENDS]->() DELETE r"
```

This query will delete all `friend` outgoing relationships from the node with the name 'Jim'.
This query deletes all outgoing `FRIENDS` relationships from the node with name 'Jim', while keeping the nodes intact.

## Common Patterns

### Delete all nodes and relationships in a graph

```sh
GRAPH.QUERY DEMO_GRAPH "MATCH (n) DETACH DELETE n"
```

The `DETACH DELETE` automatically removes all relationships before deleting the node.

### Conditional deletion

```sh
GRAPH.QUERY DEMO_GRAPH "MATCH (p:Person) WHERE p.age < 18 DELETE p"
```

Deletes all Person nodes where age is less than 18.
14 changes: 7 additions & 7 deletions cypher/indexing.md
Original file line number Diff line number Diff line change
Expand Up @@ -646,23 +646,23 @@ let result = graph.query("CALL db.idx.fulltext.queryRelationships('Manager', 'Ch
To delete the full-text index for a specific relation label, use:

{% capture shell_18 %}
GRAPH.QUERY DEMO_GRAPH "CALL DROP FULLTEXT INDEX FOR ()-[m:Manager]-() ON (m.name)"
GRAPH.QUERY DEMO_GRAPH "DROP FULLTEXT INDEX FOR ()-[m:Manager]-() ON (m.name)"
{% endcapture %}

{% capture python_18 %}
graph.query("CALL DROP FULLTEXT INDEX FOR ()-[m:Manager]-() ON (m.name)")
graph.query("DROP FULLTEXT INDEX FOR ()-[m:Manager]-() ON (m.name)")
{% endcapture %}

{% capture javascript_18 %}
await graph.query("CALL DROP FULLTEXT INDEX FOR ()-[m:Manager]-() ON (m.name)");
await graph.query("DROP FULLTEXT INDEX FOR ()-[m:Manager]-() ON (m.name)");
{% endcapture %}

{% capture java_18 %}
graph.query("CALL DROP FULLTEXT INDEX FOR ()-[m:Manager]-() ON (m.name)");
graph.query("DROP FULLTEXT INDEX FOR ()-[m:Manager]-() ON (m.name)");
{% endcapture %}

{% capture rust_18 %}
graph.query("CALL DROP FULLTEXT INDEX FOR ()-[m:Manager]-() ON (m.name)").execute().await?;
graph.query("DROP FULLTEXT INDEX FOR ()-[m:Manager]-() ON (m.name)").execute().await?;
{% endcapture %}

{% include code_tabs.html id="fulltext_relation_drop_tabs" shell=shell_18 python=python_18 javascript=javascript_18 java=java_18 rust=rust_18 %}
Expand All @@ -681,8 +681,8 @@ CREATE VECTOR INDEX FOR <entity_pattern> ON <entity_attribute> OPTIONS <options>
The options are:
```
{
dimension: INT, // Requiered, length of the vector to be indexed
similarityFunction: STRING, // Requiered, currently only euclidean or cosine are allowed
dimension: INT, // Required, length of the vector to be indexed
similarityFunction: STRING, // Required, currently only euclidean or cosine are allowed
M: INT, // Optional, maximum number of outgoing edges per node. default 16
efConstruction: INT, // Optional, number of candidates during construction. default 200
efRuntime: INT // Optional, number of candidates during search. default 10
Expand Down
22 changes: 12 additions & 10 deletions cypher/match.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ parent: "Cypher Language"

# MATCH

Match describes the relationship between queried entities, using ascii art to represent pattern(s) to match against.
The `MATCH` clause describes the relationship between queried entities using ASCII art to represent pattern(s) to match against.

Nodes are represented by parentheses `()`,
and Relationships are represented by brackets `[]`.
**Syntax Overview:**
- Nodes are represented by parentheses `()`
- Relationships are represented by brackets `[]`
- Each graph entity (node/relationship) can contain an alias, a label/relationship type, and filters, but all are optional

Each graph entity node/relationship can contain an alias and a label/relationship type, but both can be left empty if necessary.
**Entity Structure:** `alias:label {filters}`

Entity structure: `alias:label {filters}`.

Alias, label/relationship type, and filters are all optional.
Where:
- `alias` - Optional variable name to reference the entity
- `label` - Optional label for nodes or type for relationships
- `{filters}` - Optional property filters

Example:

Expand All @@ -35,10 +38,9 @@ Example:

`Movie` destination node is of "type" movie.

`{title:"straight outta compton"}` requires the node's title attribute to equal "straight outta compton".
`{title:"straight outta compton"}` filters for nodes where the title property equals "straight outta compton".

In this example, we're interested in actor entities which have the relation "act" with **the** entity representing the
"straight outta compton" movie.
In this example, we're querying for actor entities that have an "ACT" relationship with the movie entity "straight outta compton".

It is possible to describe broader relationships by composing a multi-hop query such as:

Expand Down
12 changes: 9 additions & 3 deletions cypher/procedures.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,25 @@ parent: "Cypher Language"

# Procedures

Procedures are invoked using the syntax:
Procedures are functions that can be called from within Cypher queries using the `CALL` syntax.

## Syntax

Basic procedure call:

```sh
GRAPH.QUERY social "CALL db.labels()"
```

Or the variant:
With explicit `YIELD` to select specific return values:

```sh
GRAPH.QUERY social "CALL db.labels() YIELD label"
```

YIELD modifiers are only required if explicitly specified; by default the value in the 'Yields' column will be emitted automatically.
**Note:** The `YIELD` clause is optional. When omitted, all values listed in the 'Yields' column are returned automatically.

## Available Procedures

| Procedure | Arguments | Yields | Description |
| ------- | :------- | :------- | :----------- |
Expand Down
56 changes: 31 additions & 25 deletions cypher/return.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,57 @@ parent: "Cypher Language"

# RETURN

In its simple form, Return defines which properties the returned result-set will contain.
The `RETURN` clause defines which properties and values the result-set will contain.

Its structure is a list of `alias.property` separated by commas.
## Basic Usage

For convenience, it's possible to specify the alias only when you're interested in every attribute an entity possesses,
and don't want to specify each attribute individually. For example:
The basic structure is a comma-separated list of `alias.property` expressions:

```sh
RETURN person.name, person.age
```

For convenience, you can specify just the alias to return all properties of an entity:

```sh
RETURN movie.title, actor
```

Use the DISTINCT keyword to remove duplications within the result-set:
## Removing Duplicates

Use the `DISTINCT` keyword to remove duplicate values from the result-set:

```sh
RETURN DISTINCT friend_of_friend.name
```

In the above example, suppose we have two friends, Joe and Miesha,
and both know Dominick.
For example, if you have two friends (Joe and Miesha) who both know Dominick, `DISTINCT` ensures that Dominick appears only once in the final result set.

DISTINCT will make sure Dominick will only appear once
in the final result set.

## Aggregations

Return can also be used to aggregate data, similar to group by in SQL.
The `RETURN` clause can also aggregate data, similar to SQL's GROUP BY functionality.

Once an aggregation function is added to the return
list, all other "none" aggregated values are considered as group keys, for example:
When an aggregation function is used in the RETURN list, all non-aggregated values become implicit grouping keys:

```sh
RETURN movie.title, MAX(actor.age), MIN(actor.age)
```

Here we group data by movie title and for each movie, and we find its youngest and oldest actor age.
This query groups data by movie title and, for each movie, returns the youngest and oldest actor ages.

## Aggregations
### Supported Aggregation Functions

| Function | Description |
|----------|-------------|
| `avg` | Calculate average of numeric values |
| `collect` | Collect values into a list |
| `count` | Count number of values |
| `max` | Find maximum value |
| `min` | Find minimum value |
| `percentileCont` | Calculate continuous percentile |
| `percentileDisc` | Calculate discrete percentile |
| `stDev` | Calculate standard deviation |
| `sum` | Calculate sum of numeric values |

Supported aggregation functions include:

* `avg`
* `collect`
* `count`
* `max`
* `min`
* `percentileCont`
* `percentileDisc`
* `stDev`
* `sum`
For detailed information on aggregation functions, see the [Functions documentation](/cypher/functions#aggregating-functions).
Loading
Loading