Skip to content

Memgraph 3.4 #1308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
105 changes: 104 additions & 1 deletion pages/advanced-algorithms/available-algorithms/text.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ If subgraph is not specified, the algorithm is computed on the entire graph by d

{<h4 className="custom-header"> Usage: </h4>}

Use the following query to insert the parameters to the placeholders in the sentence:
Use the following queries to insert the parameters to the placeholders in the sentence:

```cypher
CALL text.format("Memgraph is the number {} {} in the world.", [1, "graph database"])
Expand All @@ -137,3 +137,106 @@ Result:
| "Memgraph is the number 1 graph database in the world. "|
+---------------------------------------------------------+
```

### `replace()`

Replace each substring of the given string that matches the given regular expression with the given replacement.

{<h4 className="custom-header"> Input: </h4>}

- `subgraph: Graph` (**OPTIONAL**) ➡ A specific subgraph, which is an [object of type Graph](/advanced-algorithms/run-algorithms#run-procedures-on-subgraph) returned by the `project()` function, on which the algorithm is run.
If subgraph is not specified, the algorithm is computed on the entire graph by default.
- `text: string` ➡ Text that needs to be replaced.
- `regex: string` ➡ Regular expression by which to replace the string.
- `replacement: string` ➡ Target string to replace the matched string.

{<h4 className="custom-header"> Usage: </h4>}

Use the following queries to do text replacement:

```cypher
RETURN text.replace('Hello World!', '[^a-zA-Z]', '') AS result;
```

Result:

```plaintext
+--------------+
| result |
+--------------+
| "HelloWorld" |
+--------------+
```

```cypher
RETURN text.replace('MAGE is a Memgraph Product', 'MAGE', 'GQLAlchemy') AS result;
```

Result:

```plaintext
+------------------------------------+
| result |
+---------- -------------------------+
| "GQLAlchemy is a Memgraph Product" |
+------------------------------------+
```

### `regReplace()`

Replace each substring of the given string that matches the given regular expression with the given replacement.

{<h4 className="custom-header"> Input: </h4>}

- `subgraph: Graph` (**OPTIONAL**) ➡ A specific subgraph, which is an [object of type Graph](/advanced-algorithms/run-algorithms#run-procedures-on-subgraph) returned by the `project()` function, on which the algorithm is run.
If subgraph is not specified, the algorithm is computed on the entire graph by default.
- `text: string` ➡ Text that needs to be replaced.
- `regex: string` ➡ Regular expression by which to replace the string.
- `replacement: string` ➡ Target string to replace the matched string.

{<h4 className="custom-header"> Usage: </h4>}

Use the following query to do text replacement:

```cypher
RETURN text.regreplace("Memgraph MAGE Memgraph MAGE", "MAGE", "GQLAlchemy") AS output;
```

Result:

```plaintext
+---------------------------------------+
| result |
+---------------------------------------+
| "GQLAlchemy MAGE Memgraph GQLAlchemy" |
+---------------------------------------+
```

### `distance()`

Compare the given strings with the Levenshtein distance algorithm.

{<h4 className="custom-header"> Input: </h4>}

- `subgraph: Graph` (**OPTIONAL**) ➡ A specific subgraph, which is an [object of type Graph](/advanced-algorithms/run-algorithms#run-procedures-on-subgraph) returned by the `project()` function, on which the algorithm is run.
If subgraph is not specified, the algorithm is computed on the entire graph by default.
- `text1: string` ➡ Source string.
- `text2: string` ➡ Destination string for comparison.

{<h4 className="custom-header"> Usage: </h4>}

Use the following query to calculate distance between texts:

```cypher
RETURN text.distance("Levenshtein", "Levenstein") AS result;
```

Result:

```plaintext
+--------+
| result |
+--------+
| 1 |
+--------+
```
1 change: 1 addition & 0 deletions pages/querying/functions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ This section contains the list of supported functions.
| `outDegree` | `outDegree(node: Node) -> (integer)` | Returns the number of outgoing relationships of a node. |
| `inDegree` | `inDegree(node: Node) -> (integer)` | Returns the number of incoming relationships of a node. |
| `endNode` | `endNode(relationship: Relationship) -> (Node)` | Returns the destination node of a relationship. |
| `gethopsCounter` | `getHopsCounter() -> (integer)` | Returns the current number of hops traversed during the query execution. |
| `head` | `head(list: List[any]) -> (any)` | Returns the first element of a list. |
| `id` | `id(value: Node\|Relationship) -> (integer)` | Returns identifier for a given node or relationship. The identifier is generated during the initialization of a node or a relationship and will be persisted through the durability mechanism. |
| `last` | `last(list: List[any]) -> (any)` | Returns the last element of a list. |
Expand Down
59 changes: 40 additions & 19 deletions pages/querying/vector-search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Below is a list of all configuration options:
- `metric: string (default=l2sq)` ➡ The metric used for the vector search. The default value is `l2sq` (squared Euclidean distance).
- `resize_coefficient: int (default=2)` ➡ When the index reaches its capacity, it resizes by multiplying the current capacity by this coefficient, if sufficient memory is available.
If resizing fails due to memory limitations, an exception will be thrown. Default value is `2`.
- `scalar_kind: string (default=f32)` ➡ The scalar type used to store each vector component. Smaller types reduce memory usage but may decrease precision.

## Run vector search

Expand All @@ -81,6 +82,7 @@ Additionally, the same information can be retrieved with the `SHOW VECTOR INDEX
- `capacity: int` ➡ The capacity of the vector index.
- `metric: string` ➡ Metric used for vector search similarity.
- `size: int` ➡ The number of entries in the vector index.
- `scalar_kind: string` ➡ The scalar type used for each vector element.

{<h3 className="custom-header"> Usage: </h3>}

Expand Down Expand Up @@ -139,9 +141,28 @@ for the metric is `l2sq` (squared Euclidean distance).

### Scalar type

Properties are stored as 64-bit values in the property store and as 32-bit values in the vector index.
Scalar type define the data type of each vector element. Default type for the
metric is `f32`.
Properties are stored as 64-bit values in the property store. However, for efficiency, vector elements in the vector index are stored using 32-bit values by default.
The `scalar_kind` setting determines the data type used for each vector element in the index. By default, the scalar type is set to `f32` (32-bit floating point),
which provides a good balance between precision and memory usage. Alternative options, such as `f16` for lower memory usage or `f64` for higher precision, allow you to fine-tune this tradeoff based on your specific needs.

| Scalar | Description |
|-----------|------------------------------------------------------------|
| `b1x8` | Binary format (1 bit per element, stored in 8-bit chunks). |
| `u40` | Unsigned 40-bit integer. |
| `uuid` | Universally unique identifier (UUID). |
| `bf16` | 16-bit floating point (bfloat16). |
| `f64` | 64-bit floating point (double). |
| `f32` | 32-bit floating point (float). |
| `f16` | 16-bit floating point. |
| `f8` | 8-bit floating point. |
| `u64` | 64-bit unsigned integer. |
| `u32` | 32-bit unsigned integer. |
| `u16` | 16-bit unsigned integer. |
| `u8` | 8-bit unsigned integer. |
| `i64` | 64-bit signed integer. |
| `i32` | 32-bit signed integer. |
| `i16` | 16-bit signed integer. |
| `i8` | 8-bit signed integer. |

## Drop vector index

Expand Down Expand Up @@ -179,7 +200,7 @@ After Memgraph MAGE and Lab have been started, head over to the Query execution
tab in Memgraph Lab and run the following query to create vector index:

```cypher
CREATE VECTOR INDEX index_name ON :Node(vector) WITH CONFIG {"dimension": 2, "capacity": 1000, "metric": "cos","resize_coefficient": 2};
CREATE VECTOR INDEX index_name ON :Node(vector) WITH CONFIG {"dimension": 2, "capacity": 1000, "metric": "cos", "resize_coefficient": 2, "scalar_kind": "f16"};
```

Then, run the following query to inspect vector index:
Expand All @@ -196,11 +217,11 @@ SHOW VECTOR INDEX INFO;
The above query will result with:

```
+--------------+--------------+--------------+--------------+--------------+--------------+
| capacity | dimension | index_name | label | property | size |
+--------------+--------------+--------------+--------------+--------------+--------------+
| 2048 | 2 | "index_name" | "Node" | "vector" | 0 |
+--------------+--------------+--------------+--------------+--------------+--------------+
+--------------+--------------+--------------+--------------+--------------+--------+--------------+
| capacity | dimension | index_name | label | property | size | scalar_kind |
+--------------+--------------+--------------+--------------+--------------+--------+--------------+
| 2048 | 2 | "index_name" | "Node" | "vector" | 0 | "f16" |
+--------------+--------------+--------------+--------------+--------------+--------+--------------+
```

{<h3 className="custom-header"> Create a node </h3>}
Expand All @@ -221,11 +242,11 @@ CALL vector_search.show_index_info() YIELD * RETURN *;
The above query results in:

```
+--------------+--------------+--------------+--------------+--------------+--------------+
| capacity | dimension | index_name | label | property | size |
+--------------+--------------+--------------+--------------+--------------+--------------+
| 2048 | 2 | "index_name" | "Node" | "vector" | 1 |
+--------------+--------------+--------------+--------------+--------------+--------------+
+--------------+--------------+--------------+--------------+--------------+--------+--------------+
| capacity | dimension | index_name | label | property | size | scalar_kind |
+--------------+--------------+--------------+--------------+--------------+--------+--------------+
| 2048 | 2 | "index_name" | "Node" | "vector" | 1 | "f16" |
+--------------+--------------+--------------+--------------+--------------+--------+--------------+
```

We can see the size of the index changed, due to one new node.
Expand Down Expand Up @@ -269,11 +290,11 @@ CALL vector_search.show_index_info() YIELD * RETURN *;

The size is now 5, due to 4 additional nodes:
```
+--------------+--------------+--------------+--------------+--------------+--------------+
| capacity | dimension | index_name | label | property | size |
+--------------+--------------+--------------+--------------+--------------+--------------+
| 2048 | 2 | "index_name" | "Node" | "vector" | 5 |
+--------------+--------------+--------------+--------------+--------------+--------------+
+--------------+--------------+--------------+--------------+--------------+--------+--------------+
| capacity | dimension | index_name | label | property | size | scalar_kind |
+--------------+--------------+--------------+--------------+--------------+--------+--------------+
| 2048 | 2 | "index_name" | "Node" | "vector" | 5 | "f16" |
+--------------+--------------+--------------+--------------+--------------+--------+--------------+
```

Let's again search for the top five similar nodes to the vector [2.0, 2.0] (to compare it to all nodes we have):
Expand Down
10 changes: 8 additions & 2 deletions pages/release-notes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ updated.

## 🚀 Latest release

### Memgraph v3.4.0 - July 16th, 2025

### MAGE v3.4.0 - July 16th, 2025

### Lab v3.4.0 - July 16th, 2025

## Previous releases

### Memgraph v3.3.0 - June 4th, 2025

{<h4 className="custom-header">✨ New features</h4>}
Expand Down Expand Up @@ -163,8 +171,6 @@ updated.

<LabReleasesClient version="3.3.0" />

## Previous releases

### Memgraph v3.2.1 - May 9th, 2025

{<h4 className="custom-header">🛠️ Improvements</h4>}
Expand Down