diff --git a/pages/querying/text-search.mdx b/pages/querying/text-search.mdx
index e3c3f14e1..a82e94a09 100644
--- a/pages/querying/text-search.mdx
+++ b/pages/querying/text-search.mdx
@@ -72,6 +72,13 @@ To list all text indices in Memgraph, use the `SHOW INDEX INFO`
## Query text indices
+
+
+Within a single transaction, repeated text searches may return different results if other transactions have committed their changes to the same index.
+For consistent results, avoid performing multiple identical searches within the same transaction when concurrent modifications are expected.
+
+
+
Querying text indices is done through query procedures.
@@ -109,6 +116,31 @@ YIELD node
RETURN node;
```
+{Example
}
+
+```cypher
+CREATE TEXT INDEX complianceDocuments ON :Document;
+CREATE (:Document {title: 'Rules2024', version: 1});
+CREATE (:Document {title: 'Rules2024', version: 2});
+CREATE (:Document {title: 'Other', version: 2});
+
+// Search for documents with title containing 'Rules2024'
+CALL text_search.search('complianceDocuments', 'data.title:Rules2024')
+YIELD node
+RETURN node.title AS title, node.version AS version
+ORDER BY version ASC;
+```
+
+Result:
+```
++-------------+-------------+
+| title | version |
++-------------+-------------+
+| "Rules2024" | 1 |
+| "Rules2024" | 2 |
++-------------+-------------+
+```
+
### Search over all indexed properties
The `text_search.search_all` procedure looks for text-indexed nodes where at
@@ -137,6 +169,30 @@ YIELD node
RETURN node;
```
+{Example
}
+
+```cypher
+CREATE TEXT INDEX complianceDocuments ON :Document;
+CREATE (:Document {title: 'Rules2024', fulltext: 'text words', version: 1});
+CREATE (:Document {title: 'Other', fulltext: 'Rules2024 here', version: 3});
+
+// Search for 'Rules2024' across all properties
+CALL text_search.search_all('complianceDocuments', 'Rules2024')
+YIELD node
+RETURN node
+ORDER BY node.version ASC;
+```
+
+Result:
+```
++----------------------------------------------------------------------+
+| node |
++----------------------------------------------------------------------+
+| (:Document {fulltext: "text words", title: "Rules2024", version: 1}) |
+| (:Document {fulltext: "Rules2024 here", title: "Other", version: 3}) |
++----------------------------------------------------------------------+
+```
+
### Regex search
The `text_search.regex_search` procedure looks for text-indexed nodes where at
@@ -164,6 +220,30 @@ YIELD node
RETURN node;
```
+{Example
}
+
+```cypher
+CREATE TEXT INDEX complianceDocuments ON :Document;
+CREATE (:Document {fulltext: 'words and things'});
+CREATE (:Document {fulltext: 'more words'});
+
+// Search using regex pattern 'wor.*s'
+CALL text_search.regex_search('complianceDocuments', 'wor.*s')
+YIELD node
+RETURN node
+ORDER BY node.fulltext ASC;
+```
+
+Result:
+```
++--------------------------------------------+
+| node |
++--------------------------------------------+
+| (:Document {fulltext: "more words"}) |
+| (:Document {fulltext: "words and things"}) |
++--------------------------------------------+
+```
+
### Aggregations
Aggregations allow you to perform calculations on text search results. By using
@@ -196,12 +276,38 @@ The following query counts all nodes in the `complianceDocuments` index:
CALL text_search.aggregate(
"complianceDocuments",
"data.title:Rules2024",
- '{"count": {"value_count": {"field": "metadata.gid"}}}'
+ '{"count": {"value_count": {"field": "data.version"}}}'
)
YIELD aggregation
RETURN aggregation;
```
+{Example
}
+
+```cypher
+CREATE TEXT INDEX complianceDocuments ON :Document;
+CREATE (:Document {title: 'Rules2024', version: 1});
+CREATE (:Document {title: 'Rules2024', version: 2});
+
+// Count documents matching the search query
+CALL text_search.aggregate(
+ 'complianceDocuments',
+ 'data.title:Rules2024',
+ '{"count":{"value_count":{"field":"data.version"}}}'
+)
+YIELD aggregation
+RETURN aggregation;
+```
+
+Result:
+```
++-------------------------------+
+| aggregation |
++-------------------------------+
+| "{\"count\":{\"value\":2.0}}" |
++-------------------------------+
+```
+
## Drop text indices
Text indices are dropped with the `DROP TEXT INDEX` command. You need to give
@@ -213,18 +319,15 @@ This statement drops the text index named `complianceDocuments`:
DROP TEXT INDEX complianceDocuments;
```
-If one attempts to delete an index with the same name twice, the statement will
-fail.
-
## Compatibility
Even though text search is an experimental feature, it supports most usage modalities
that are available in Memgraph from version 3.5. Refer to the table below for an overview:
-| Feature | Support |
-|-------------------------|--------------------------------------------- |
-| Multitenancy | ✅ Yes |
-| Durability | ✅ Yes |
-| Storage modes | ❌ No (doesn't work in IN_MEMORY_ANALYTICAL) |
-| Replication | ✅ Yes (from version 3.5) |
-| Concurrent transactions | ✅ Yes (from version 3.5) |
\ No newline at end of file
+| Feature | Support |
+|-------------------------|---------------------------------------------------------|
+| Multitenancy | ✅ Yes |
+| Durability | ✅ Yes |
+| Replication | ✅ Yes (from version 3.5) |
+| Concurrent transactions | ⚠️ Yes, but search results may vary within transactions |
+| Storage modes | ❌ No (doesn't work in IN_MEMORY_ANALYTICAL) |
\ No newline at end of file