Skip to content

Commit fc17f21

Browse files
committed
fix: add object notification filtering
1 parent 486fe90 commit fc17f21

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

docs/buckets/object-notifications.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,24 @@ An example notification payload is:
104104
}
105105
```
106106

107+
## Filtering
108+
109+
Object notifications support adding a SQL-like filter to only receive
110+
notifications that match the filter. The filter is configured in the Tigris
111+
Dashboard. The filtering can be used to send specific events or object keys that
112+
match a given prefix. The filtering uses the SQL-like syntax defined in given
113+
prefix. The filtering uses the SQL-like syntax defined in
114+
[Metadata Querying](/docs/objects/query-metadata.md).
115+
116+
An example to only receive notifications for a key with a prefix of `images/`:
117+
118+
For example, if you only want to receive notifications for objects in the
119+
"images" folder, you would use this filter:
120+
121+
```sql
122+
WHERE key REGEXP "^images"
123+
```
124+
107125
## Pricing
108126

109127
See [Pricing](/docs/pricing/index.md) for how object notifications are charged.

docs/objects/query-metadata.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The `X-Tigris-Query` field query can be thought of as the `WHERE` clause in a
1010
SQL query. For instance, to find all objects with a `Content-Type` of
1111
`text/javascript`, set the header as follows:
1212

13-
- `X-Tigris-Query`: `` `Content-Type` = "text/javascript" ``
13+
- `X-Tigris-Query`: `` WHERE `Content-Type` = "text/javascript" ``
1414

1515
## Queryable Fields
1616

@@ -20,6 +20,9 @@ Tigris supports querying against the following fields:
2020
2. `` `Content-Length` ``: The size of the object.
2121
3. `` `Last-Modified` ``: The date and time the object was last modified in
2222
[RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format.
23+
4. `` `key` ``: The key of the object.
24+
5. `` `Event-Type` ``: The type of the event, this is only supported in
25+
[Object Notifications](/docs/buckets/object-notifications.md).
2326

2427
## SQL Operations
2528

@@ -31,6 +34,16 @@ Query supports following comparison operators:
3134
4. `>=` and `<=`: Greater than or equal and less than or equal
3235
5. `AND`: Combine multiple conditions in a query.
3336

37+
## In Memory Operations
38+
39+
Tigris supports `IN`, `NOT IN`, and `REGEXP` operators for filtering results.
40+
Since these operations are performed in memory, they must be combined with SQL
41+
operations mentioned above. For example:
42+
43+
1. `` WHERE `Content-Type` = "text/plain" AND key REGEXP ".*\.txt$" ``
44+
2. `` WHERE `Content-Length` > 1024 AND `Content-Type` IN ("text/javascript", "text/css") ``.
45+
3. `` WHERE `Content-Length` != 65536 AND `Content-Type` NOT IN ("text/plain", "text/html") ``.
46+
3447
## Order by
3548

3649
You can sort the list using `ORDER BY`. For example, to retrieve all items
@@ -42,11 +55,11 @@ smaller than `64KB` ordered by `Content-Type`:
4255

4356
Example queries that can be performed:
4457

45-
1. `` `Content-Type` = "text/plain" ``
46-
2. `` `Content-Type` >= "text/c" AND `Content-Type` < "text/j" ``
47-
3. `` `Content-Length` > 0 ORDER BY `Content-Length` ASC ``
48-
4. `` `Content-Length` != 65536 AND `Content-Type` = "text/plain" ``
49-
5. `` `Last-Modified` > "2024-06-23T10:38:46Z" ``
58+
1. `` WHERE `Content-Type` = "text/plain" ``
59+
2. `` WHERE `Content-Type` >= "text/c" AND `Content-Type` < "text/j" ``
60+
3. `` WHERE `Content-Length` > 0 ORDER BY `Content-Length` ASC ``
61+
4. `` WHERE `Content-Length` != 65536 AND `Content-Type` = "text/plain" ``
62+
5. `` WHERE `Last-Modified` > "2024-06-23T10:38:46Z" ``
5063

5164
## Next steps
5265

0 commit comments

Comments
 (0)