Skip to content
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

v1.11: Add STARTS WITH to filter expression reference #3019

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Changes from 3 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
36 changes: 35 additions & 1 deletion learn/filtering_and_sorting/filter_expression_reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ NOT genres IN [horror, comedy]

`CONTAINS` filters results containing partial matches to the specified string pattern, similar to a [SQL `LIKE`](https://dev.mysql.com/doc/refman/8.4/en/string-comparison-functions.html#operator_like).

The following expression returns all dairy products whose name start with `"kef"`, such as kefir:
The following expression returns all dairy products whose names contain `"kef"`:

```
dairy_products.name CONTAINS kef
Expand All @@ -185,6 +185,40 @@ curl \
"containsFilter": true
}'
```

This will also enable the [`STARTS WITH`](#starts_with) operator.
</Capsule>

### `STARTS_WITH` <NoticeTag type="experimental" label="experimental" />
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved

`STARTS_WITH` filters results whose values start with the specified string pattern.
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved

The following expression returns all dairy products whose name start with `"kef"`:

```
dairy_products.name STARTS WITH kef
```

The negated form of the above expression can be written as:

```
dairy_products.name NOT STARTS WITH kef
NOT dairy_product.name STARTS WITH kef
```

<Capsule intent="note" title="Activating `STARTS_WITH`">
guimachiavelli marked this conversation as resolved.
Show resolved Hide resolved
This is an experimental feature. Use the experimental features endpoint to activate it:

```sh
curl \
-X PATCH 'http://localhost:7700/experimental-features/' \
-H 'Content-Type: application/json' \
--data-binary '{
"containsFilter": true
}'
```

This will also enable the [`CONTAINS`](#contains) operator.
</Capsule>

### `NOT`
Expand Down