From 511d9c7dede33b0e16ef91b31342a114bee017dd Mon Sep 17 00:00:00 2001 From: Pawel Pekrol Date: Sat, 14 Mar 2026 23:40:06 +0100 Subject: [PATCH] RavenDB-25927 Add Regex.IsMatch support examples to subscription creation docs Document the new Regex.IsMatch support in data subscription LINQ filters (RavenDB-25927). C# examples show both generic syntax with Regex.IsMatch and RQL syntax. Python and Node.js examples show the RQL regex() function. --- .../creation/content/_examples-csharp.mdx | 53 ++++++++++++++++++- .../creation/content/_examples-nodejs.mdx | 19 ++++++- .../creation/content/_examples-python.mdx | 19 +++++++ 3 files changed, 89 insertions(+), 2 deletions(-) diff --git a/docs/client-api/data-subscriptions/creation/content/_examples-csharp.mdx b/docs/client-api/data-subscriptions/creation/content/_examples-csharp.mdx index 8d8a9d2253..4c71d9684a 100644 --- a/docs/client-api/data-subscriptions/creation/content/_examples-csharp.mdx +++ b/docs/client-api/data-subscriptions/creation/content/_examples-csharp.mdx @@ -12,7 +12,8 @@ import CodeBlock from '@theme/CodeBlock'; * In this page: * [Create subscription - for all documents in a collection](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---for-all-documents-in-a-collection) - * [Create subscription - filter documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents) + * [Create subscription - filter documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents) + * [Create subscription - filter documents using regex](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents-using-regex) * [Create subscription - filter and project fields](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-and-project-fields) * [Create subscription - project data from a related document](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---project-data-from-a-related-document) * [Create subscription - include documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---include-documents) @@ -88,6 +89,56 @@ Only documents that match this condition will be sent from the server to a clien +## Create subscription - filter documents using regex + +Here we create a subscription for documents from the _Orders_ collection where the `ShipTo.City` field matches a regular expression pattern. +You can use `Regex.IsMatch` within the subscription's LINQ filter expression to perform server-side pattern matching. + + + + +{`// Filter using Regex.IsMatch in the subscription's LINQ filter +subscriptionName = store.Subscriptions.Create(x => + Regex.IsMatch(x.ShipTo.City, "^New")); +`} + + + + +{`subscriptionName = store.Subscriptions.Create(new SubscriptionCreationOptions() +{ + Query = @"From Orders + Where regex(ShipTo.City, '^New')" +}); +`} + + + + +You can pass supported `RegexOptions` as a third argument: + + +{`// Filter with case-insensitive regex matching +subscriptionName = store.Subscriptions.Create(x => + Regex.IsMatch(x.ShipTo.City, "^new", RegexOptions.IgnoreCase)); +`} + + + + +The following `RegexOptions` are supported: +* `RegexOptions.IgnoreCase` +* `RegexOptions.Multiline` +* `RegexOptions.Singleline` + +Other `RegexOptions` values (e.g. `Compiled`, `ExplicitCapture`) and the timeout overload are **not supported** and will throw a `NotSupportedException`. + +The regex pattern must be a **constant expression** — it cannot be a variable computed at runtime from document fields. + + + + + ## Create subscription - filter and project fields Here, again, we create a subscription for documents from the _Orders_ collection where the total order revenue is greater than 100. diff --git a/docs/client-api/data-subscriptions/creation/content/_examples-nodejs.mdx b/docs/client-api/data-subscriptions/creation/content/_examples-nodejs.mdx index 665881ccf8..ae8a4ac21d 100644 --- a/docs/client-api/data-subscriptions/creation/content/_examples-nodejs.mdx +++ b/docs/client-api/data-subscriptions/creation/content/_examples-nodejs.mdx @@ -12,7 +12,8 @@ import CodeBlock from '@theme/CodeBlock'; * In this page: * [Create subscription - for all documents in a collection](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---for-all-documents-in-a-collection) - * [Create subscription - filter documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents) + * [Create subscription - filter documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents) + * [Create subscription - filter documents using regex](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents-using-regex) * [Create subscription - filter and project fields](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-and-project-fields) * [Create subscription - project data from a related document](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---project-data-from-a-related-document) * [Create subscription - include documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---include-documents) @@ -92,6 +93,22 @@ const subscriptionName = await documentStore.subscriptions.create(\{ query \}); +## Create subscription - filter documents using regex + +Here we create a subscription for documents from the _Orders_ collection where the `ShipTo.City` field matches a regular expression pattern. +Use the RQL `regex` function to perform server-side pattern matching. + + + +{`const query = \`from Orders where regex(ShipTo.City, '^New')\`; + +const subscriptionName = await documentStore.subscriptions.create(\{ query \}); +`} + + + + + ## Create subscription - filter and project fields Here, again, we create a subscription for documents from the _Orders_ collection where the total order revenue is greater than 100. diff --git a/docs/client-api/data-subscriptions/creation/content/_examples-python.mdx b/docs/client-api/data-subscriptions/creation/content/_examples-python.mdx index 69f8adc10c..637bddc08d 100644 --- a/docs/client-api/data-subscriptions/creation/content/_examples-python.mdx +++ b/docs/client-api/data-subscriptions/creation/content/_examples-python.mdx @@ -13,6 +13,7 @@ import CodeBlock from '@theme/CodeBlock'; * In this page: * [Create subscription - for all documents in a collection](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---for-all-documents-in-a-collection) * [Create subscription - filter documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents) + * [Create subscription - filter documents using regex](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-documents-using-regex) * [Create subscription - filter and project fields](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---filter-and-project-fields) * [Create subscription - project data from a related document](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---project-data-from-a-related-document) * [Create subscription - include documents](../../../../client-api/data-subscriptions/creation/examples.mdx#create-subscription---include-documents) @@ -72,6 +73,24 @@ Only documents that match this condition will be sent from the server to a clien +## Create subscription - filter documents using regex + +Here we create a subscription for documents from the _Orders_ collection where the `ShipTo.City` field matches a regular expression pattern. +Use the RQL `regex` function to perform server-side pattern matching. + + + +{`name = store.subscriptions.create_for_options( + SubscriptionCreationOptions( + query="From Orders Where regex(ShipTo.City, '^New')" + ), +) +`} + + + + + ## Create subscription - filter and project fields Here, again, we create a subscription for documents from the _Orders_ collection where the total order revenue is greater than 100.