Skip to content

Commit

Permalink
Add docs for Vectorize $in and $nin (#18149)
Browse files Browse the repository at this point in the history
* Add docs for Vectorize $in and $nin

* Add $nin example
  • Loading branch information
garrettgu10 authored Nov 13, 2024
1 parent 1a0eb38 commit 33a2e94
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/content/changelogs/vectorize.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ productLink: "/vectorize/"
productArea: Developer platform
productAreaLink: /workers/platform/changelog/platform/
entries:
- publish_date: "2024-11-13"
title: Added support for `$in` and `$nin` metadata filters
description: |-
Vectorize now supports `$in` and `$nin` clauses in [metadata filters](/vectorize/reference/metadata-filtering/).
- publish_date: "2024-10-28"
title: Improved query latency through REST API
description: |-
Expand Down
17 changes: 16 additions & 1 deletion src/content/docs/vectorize/reference/metadata-filtering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ Optional `filter` property on `query()` method specifies metadata filter:
| -------- | ----------- |
| `$eq` | Equals |
| `$ne` | Not equals |
| `$in` | In |
| `$nin` | Not in |

- `filter` must be non-empty object whose compact JSON representation must be less than 2048 bytes.
- `filter` object keys cannot be empty, contain `" | .` (dot is reserved for nesting), start with `$`, or be longer than 512 characters.
- `filter` object non-nested values can be `string`, `number`, `boolean`, or `null` values.
- For `$eq` and `$ne`, `filter` object non-nested values can be `string`, `number`, `boolean`, or `null` values.
- For `$in` and `$nin`, `filter` object values can be arrays of `string`, `number`, `boolean`, or `null` values.

### Namespace versus metadata filtering

Expand All @@ -63,6 +66,18 @@ Both [namespaces](/vectorize/best-practices/insert-vectors/#namespaces) and meta
{ "someKey": { "$ne": "hbo" } }
```

#### `$in` operator

```json
{ "someKey": { "$in": ["hbo", "netflix"] } }
```

#### `$nin` operator

```json
{ "someKey": { "$nin": ["hbo", "netflix"] } }
```

#### Implicit logical `AND` with multiple keys

```json
Expand Down

0 comments on commit 33a2e94

Please sign in to comment.