You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/reference-odata-filter.md
+13-14Lines changed: 13 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,15 +12,15 @@ ms.date: 11/11/2022
12
12
13
13
Azure Web PubSub's **filter** parameter defines inclusion or exclusion criteria for sending messages to connections.
14
14
15
-
This article provides the following:
15
+
This article provides the following resources:
16
16
17
17
- A description of the OData syntax of the **filter** parameter with examples.
18
-
- A [formal grammar](#formal-grammar)that describes the complete syntax.
19
-
- A browsable [syntax diagram](https://aka.ms/awps/filter-syntax-diagram) to let you interactively explore grammar rules.
18
+
- A description of the complete [Extended Backus-Naur Form](#formal-grammar)grammar.
19
+
- A browsable [syntax diagram](https://aka.ms/awps/filter-syntax-diagram) to interactively explore the syntax grammar rules.
20
20
21
21
## Syntax
22
22
23
-
A filter in the OData language is a Boolean expression, which in turn can be one of several types of expression, as shown by the following EBNF ([Extended Backus-Naur Form](https://en.wikipedia.org/wiki/Extended_Backus–Naur_form)):
23
+
A filter in the OData language is a Boolean expression, which in turn can be one of several types of expression, as shown by the following EBNF ([Extended Backus-Naur Form](https://en.wikipedia.org/wiki/Extended_Backus–Naur_form)) description:
24
24
25
25
```
26
26
/* Identifiers */
@@ -46,27 +46,26 @@ For the complete EBNF, see [formal grammar section](#formal-grammar) .
46
46
Using the filter syntax, you can control sending messages to connections matching the identifier criteria. Azure Web PubSub supports below identifiers:
47
47
48
48
| Identifier | Description | Note | Examples
49
-
| --- | --- | -- | --
50
-
| `userId` | The userId of the connection. | Case insensitive. It can be used in [string operations](#supported-operations). | `userId eq 'user1'`
49
+
| --- | --- |--|--| `userId` | The userId of the connection. | Case insensitive. It can be used in [string operations](#supported-operations). | `userId eq 'user1'`
51
50
| `connectionId` | The connectionId of the connection. | Case insensitive. It can be used in [string operations](#supported-operations). | `connectionId ne '123'`
52
51
| `groups` | The collection of groups the connection is currently in. | Case insensitive. It can be used in [collection operations](#supported-operations). | `'group1' in groups`
53
52
54
53
Identifiers refer to the property value of a connection. Azure Web PubSub supports three identifiers matching the property name of the connection model. and supports identifiers `userId` and `connectionId` in string operations, supports identifier `groups` in [collection operations](#supported-operations). For example, to filter out connections with userId `user1`, we specify the filter as `userId eq 'user1'`. Read through the below sections for more samples using the filter.
55
54
56
55
### Boolean expressions
57
56
58
-
The expression for a filter is a boolean expression. When sending messages to connections, Azure Web PubSub sends messages to connections with filter expression evaluated to `true`.
57
+
The expression for a filter is a boolean expression. Azure Web PubSub sends messages to connections with filter expressions evaluated to `true`.
59
58
60
59
The types of Boolean expressions include:
61
60
62
61
- Logical expressions that combine other Boolean expressions using the operators `and`, `or`, and `not`.
63
62
- Comparison expressions, which compare fields or range variables to constant values using the operators `eq`, `ne`, `gt`, `lt`, `ge`, and `le`.
64
63
- The Boolean literals `true` and `false`. These constants can be useful sometimes when programmatically generating filters, but otherwise don't tend to be used in practice.
65
-
- Boolean expressions in parentheses. Using parentheses can help to explicitly determine the order of operations in a filter. For more information on the default precedence of the OData operators, see [operator precedence section](#operator-precedence).
64
+
- Boolean expressions in parentheses. Using parentheses helps to explicitly determine the order of operations in a filter. For more information on the default precedence of the OData operators, see [operator precedence section](#operator-precedence).
66
65
67
66
### Supported operations
68
67
69
-
The filter syntac supports the following operations:
68
+
The filter syntax supports the following operations:
70
69
71
70
| Operator | Description | Example
72
71
| --- | --- | ---
@@ -92,14 +91,14 @@ The filter syntac supports the following operations:
92
91
| `string substring(string p, int startIndex)`,</br>`string substring(string p, int startIndex, int length)` | Substring of the string | `substring(userId,5,2) eq 'ab'` can match connections for user `user-ab-de`
93
92
| `bool endswith(string p0, string p1)` | Check if `p0` ends with `p1` | `endswith(userId,'de')` can match connections for user `user-ab-de`
94
93
| `bool startswith(string p0, string p1)` | Check if `p0` starts with `p1` | `startswith(userId,'user')` can match connections for user `user-ab-de`
95
-
| `int indexof(string p0, string p1)` | Get the index of `p1` in `p0`. Returns `-1` if `p0`does not contain `p1`. | `indexof(userId,'-ab-') ge 0` can match connections for user `user-ab-de`
94
+
| `int indexof(string p0, string p1)` | Get the index of `p1` in `p0`. Returns `-1` if `p0`doesn't contain `p1`. | `indexof(userId,'-ab-') ge 0` can match connections for user `user-ab-de`
96
95
| `int length(string p)` | Get the length of the input string | `length(userId) gt 1` can match connections for user `user-ab-de`
97
96
| **Collection Functions**
98
-
| `int length(collection p)` | Get the length of the collection | `length(groups) gt 1` can match connections in 2 groups
97
+
| `int length(collection p)` | Get the length of the collection | `length(groups) gt 1` can match connections in two groups
99
98
100
99
### Operator precedence
101
100
102
-
If you write a filter expression with no parentheses around its sub-expressions, Azure Web PubSub service will evaluate it according to a set of operator precedence rules. These rules are based on which operators are used to combine sub-expressions. The following table lists groups of operators in order from highest to lowest precedence:
101
+
If you write a filter expression with no parentheses around its subexpressions, Azure Web PubSub service will evaluate it according to a set of operator precedence rules. These rules are based on which operators are used to combine subexpressions. The following table lists groups of operators in order from highest to lowest precedence:
103
102
104
103
| Group | Operator(s) |
105
104
| --- | --- |
@@ -115,7 +114,7 @@ length(userId) gt 0 and length(userId) lt 3 or length(userId) gt 7 and length(us
115
114
((length(userId) gt 0) and (length(userId) lt 3)) or ((length(userId) gt 7) and (length(userId) lt 10))
116
115
```
117
116
118
-
The `not` operator has the highest precedence of all -- even higher than the comparison operators. That's why if you try to write a filter like this:
117
+
The `not` operator has the highest precedence of all, even higher than the comparison operators. 's If you write a filter like this:
119
118
120
119
```odata-filter-expr
121
120
not length(userId) gt 5
@@ -163,7 +162,7 @@ There are limits to the size and complexity of filter expressions that you can s
163
162
164
163
## Formal grammar
165
164
166
-
We can describe the subset of the OData language supported by Azure Web PubSub service using an EBNF ([Extended Backus-Naur Form](https://en.wikipedia.org/wiki/Extended_Backus–Naur_form)) grammar. Rules are listed "top-down", starting with the most complex expressions, then breaking them down into more primitive expressions. At the top is the grammar rule for `$filter` that corresponds to specific parameter `filter` of the Azure Azure Web PubSub service `Send*` REST APIs:
165
+
We can describe the subset of the OData language supported by Azure Web PubSub service using an EBNF ([Extended Backus-Naur Form](https://en.wikipedia.org/wiki/Extended_Backus–Naur_form)) grammar. Rules are listed "top-down", starting with the most complex expressions, then breaking them down into more primitive expressions. The top is the grammar rule for `$filter` that corresponds to specific parameter `filter` of the Azure Web PubSub service `Send*` REST APIs:
0 commit comments