Skip to content

Commit d87cdfb

Browse files
authored
Merge pull request #148 from weaviate/jose/object-ttl
Add support for object_ttl in weaviate-cli.
2 parents 89ba9b0 + 4634a58 commit d87cdfb

9 files changed

Lines changed: 834 additions & 15 deletions

File tree

.claude/skills/operating-weaviate-cli/SKILL.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,29 @@ weaviate-cli delete collection --collection MyCollection --json
139139
weaviate-cli delete collection --all --json
140140
```
141141

142-
Key create options: `--multitenant`, `--auto_tenant_creation`, `--auto_tenant_activation`, `--shards N`, `--vectorizer <type>`, `--named_vector`, `--replication_deletion_strategy`
142+
Key create options: `--multitenant`, `--auto_tenant_creation`, `--auto_tenant_activation`, `--shards N`, `--vectorizer <type>`, `--named_vector`, `--replication_deletion_strategy`, `--object_ttl_type`, `--object_ttl_time`, `--object_ttl_filter_expired`, `--object_ttl_property_name` (only when `object_ttl_type=property`)
143143

144-
Mutable fields: `--async_enabled`, `--replication_factor`, `--vector_index`, `--description`, `--training_limit`, `--auto_tenant_creation`, `--auto_tenant_activation`, `--replication_deletion_strategy`
144+
Mutable fields: `--async_enabled`, `--replication_factor`, `--vector_index`, `--description`, `--training_limit`, `--auto_tenant_creation`, `--auto_tenant_activation`, `--replication_deletion_strategy`, `--object_ttl_type`, `--object_ttl_time`, `--object_ttl_filter_expired`, `--object_ttl_property_name` (only when `object_ttl_type=property`)
145+
146+
#### Object TTL
147+
148+
```bash
149+
# Create with timestamp-based TTL (requires inverted_index timestamp for existing collections)
150+
weaviate-cli create collection --collection MyTTL --inverted_index timestamp --object_ttl_type create --object_ttl_time 3600 --json
151+
152+
# Create with property-based TTL (date property, time=0 means expire at exact property date)
153+
weaviate-cli create collection --collection MyTTL --object_ttl_type property --object_ttl_time 0 --object_ttl_property_name expiresAt --json
154+
155+
# Enable TTL on existing collection
156+
weaviate-cli update collection --collection MyTTL --object_ttl_type create --object_ttl_time 3600 --object_ttl_filter_expired true --json
157+
158+
# Disable TTL (use "disable", not "disabled")
159+
weaviate-cli update collection --collection MyTTL --object_ttl_type disable --json
160+
```
161+
162+
TTL types: `create` (by `_creationTimeUnix`), `update` (by `_lastUpdateTimeUnix`), `property` (by custom date property), `disable`
163+
164+
**Note**: `--object_ttl_time` is in seconds. Value of `0` is valid for property type (expire at exact date). Timestamp types (`create`/`update`) require a minimum of 60 seconds.
145165

146166
See [references/collections.md](references/collections.md) for full options.
147167

@@ -161,6 +181,8 @@ Key data options: `--consistency_level`, `--auto_tenants N`, `--tenants "T1,T2"`
161181

162182
Key query options: `--properties "title,keywords"`, `--tenants "T1"`, `--target_vector "default"`, `--consistency_level`
163183

184+
**Note**: `--consistency_level` values must be **lowercase**: `one`, `quorum`, `all` (not `ONE`, `QUORUM`, `ALL`).
185+
164186
See [references/data.md](references/data.md) and [references/search.md](references/search.md).
165187

166188
### Tenants
@@ -222,6 +244,8 @@ weaviate-cli delete user --user_name test-user --json
222244

223245
Permission format: `action:target`. See [references/rbac.md](references/rbac.md) for full permission reference.
224246

247+
**Shell quoting**: Permissions with wildcards must be quoted to prevent shell globbing: `-p 'crud_data:*'` (not `-p crud_data:*`, which fails in zsh with `no matches found`).
248+
225249
### Cluster & Nodes
226250

227251
```bash
@@ -305,11 +329,14 @@ hot/active <--> cold/inactive
305329
- Data operations require tenants in `hot`/`active` state
306330

307331
### RBAC Workflow
308-
1. `create role --role_name X -p <permission>` -- create role with permissions
309-
2. `create user --user_name Y` -- create user (returns API key)
332+
1. `create role --role_name X -p '<permission>'` -- create role with permissions (quote wildcards!)
333+
2. `create user --user_name Y --store` -- create user and auto-save API key into active config
310334
3. `assign role --role_name X --user_name Y` -- assign role to user
311335
4. Verify: `get role --role_name X` and `get user --user_name Y`
312-
5. Cleanup: `revoke role` -> `delete role` / `delete user`
336+
5. Test as new user: `weaviate-cli --config-file <config> --user Y <command> --json`
337+
6. Cleanup: `revoke role` -> `delete role` / `delete user`
338+
339+
**Prerequisite**: The Weaviate cluster must be deployed with `DYNAMIC_USERS=true` for `create user` to work. Without it, only static API key users (configured at deploy time) are available.
313340

314341
### Backup Workflow
315342
1. `create backup --backend s3 --backup_id my-backup --wait` -- wait for completion
@@ -325,6 +352,14 @@ hot/active <--> cold/inactive
325352
5. `cancel replication <UUID>` -- cancel if needed
326353
6. `delete replication <UUID>` -- cleanup completed operation
327354

355+
### Object TTL Workflow
356+
1. `create collection --object_ttl_type create --object_ttl_time 3600` -- create with TTL (or `update collection` to enable later)
357+
2. TTL requires server-side `objects_ttl_delete_schedule` runtime config to be set (e.g., `@every 10s`)
358+
3. `get collection --collection X` -- verify `objectTtlConfig` in response
359+
4. `update collection --object_ttl_type disable` -- disable TTL (stops background deletion)
360+
5. For timestamp-based TTL on existing collections: `--inverted_index timestamp` must be set at creation or already enabled
361+
6. For property-based TTL: the date property must exist, be `date` type, and have filterable or rangeable index
362+
328363
### Alias Workflow
329364
1. `create collection --collection Movies_v1` -- create the target collection
330365
2. `create alias Movies Movies_v1` -- create alias pointing to collection

.claude/skills/operating-weaviate-cli/references/collections.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@ weaviate-cli create collection \
3939
- `--named_vector` -- Enable named vectors
4040
- `--named_vector_name` -- Named vector name (default: "default")
4141
- `--replication_deletion_strategy` -- delete_on_conflict, no_automated_resolution, time_based_resolution
42+
- `--object_ttl_type` -- TTL event type: create, update, property (default: "create")
43+
- `--object_ttl_time` -- Time to live in seconds (default: None, TTL disabled when omitted)
44+
- `--object_ttl_filter_expired` -- Filter expired-but-not-yet-deleted objects from queries
45+
- `--object_ttl_property_name` -- Date property name for TTL when `object_ttl_type=property` (default: "releaseDate"). **Only valid when `--object_ttl_type=property`**; rejected otherwise.
46+
47+
**Object TTL examples:**
48+
```bash
49+
# Delete objects 1 hour after creation
50+
weaviate-cli create collection --collection Movies --object_ttl_type create --object_ttl_time 3600
51+
52+
# Delete objects 24 hours after last update, filtering expired objects
53+
weaviate-cli create collection --collection Movies --object_ttl_type update --object_ttl_time 86400 --object_ttl_filter_expired
54+
55+
# Delete objects based on default date property (releaseDate)
56+
weaviate-cli create collection --collection Movies --object_ttl_type property --object_ttl_time 0
57+
58+
# Delete objects based on a custom date property (e.g. for clusters not using weaviate-cli schema)
59+
weaviate-cli create collection --collection MyCollection --object_ttl_type property --object_ttl_time 86400 --object_ttl_property_name expiresAt --json
60+
```
4261

4362
## Update Collection (mutable fields only)
4463
```bash
@@ -49,10 +68,28 @@ weaviate-cli update collection \
4968
--json
5069
```
5170

52-
Mutable fields: `--async_enabled`, `--replication_factor`, `--vector_index`, `--description`, `--training_limit`, `--auto_tenant_creation`, `--auto_tenant_activation`, `--replication_deletion_strategy`
71+
Mutable fields: `--async_enabled`, `--replication_factor`, `--vector_index`, `--description`, `--training_limit`, `--auto_tenant_creation`, `--auto_tenant_activation`, `--replication_deletion_strategy`, `--object_ttl_type`, `--object_ttl_time`, `--object_ttl_filter_expired`, `--object_ttl_property_name` (only when `object_ttl_type=property`)
5372

5473
**Immutable (cannot change after creation):** multitenant, vectorizer, named_vector, shards
5574

75+
**Object TTL options for update:**
76+
- `--object_ttl_type` -- TTL event type: create, update, property, **disable** (default: "create")
77+
- `--object_ttl_time` -- Time to live in seconds (set together with type to enable TTL)
78+
- `--object_ttl_filter_expired` -- Filter expired-but-not-yet-deleted objects (type: bool)
79+
- `--object_ttl_property_name` -- Date property name when `object_ttl_type=property` (default: "releaseDate"). **Only valid when `--object_ttl_type=property`**; rejected otherwise.
80+
81+
**Object TTL examples:**
82+
```bash
83+
# Enable TTL: delete objects 2 hours after creation
84+
weaviate-cli update collection --collection Movies --object_ttl_type create --object_ttl_time 7200
85+
86+
# Disable TTL on an existing collection
87+
weaviate-cli update collection --collection Movies --object_ttl_type disable
88+
89+
# Set TTL by custom date property on an existing collection
90+
weaviate-cli update collection --collection MyCollection --object_ttl_type property --object_ttl_time 86400 --object_ttl_property_name expiresAt --json
91+
```
92+
5693
## Delete Collection
5794
```bash
5895
weaviate-cli delete collection --collection "MyCollection" --json

.github/workflows/main.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
runs-on: ubuntu-latest
3030
strategy:
3131
matrix:
32-
version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
32+
version: [ "3.10", "3.11", "3.12", "3.13" ]
3333
steps:
3434
- uses: actions/checkout@v5
3535
- uses: actions/setup-python@v6
@@ -67,7 +67,7 @@ jobs:
6767
runs-on: ubuntu-latest
6868
strategy:
6969
matrix:
70-
version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
70+
version: [ "3.10", "3.11", "3.12", "3.13" ]
7171
steps:
7272
- uses: actions/checkout@v5
7373
- uses: actions/setup-python@v6
@@ -96,7 +96,7 @@ jobs:
9696
runs-on: ubuntu-latest
9797
strategy:
9898
matrix:
99-
version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
99+
version: [ "3.10", "3.11", "3.12", "3.13" ]
100100
steps:
101101
- uses: actions/checkout@v5
102102
- uses: actions/setup-python@v6

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ classifiers =
3737
include_package_data = True
3838
python_requires = >=3.9
3939
install_requires =
40-
weaviate-client>=4.16.7
40+
weaviate-client>=4.19.0
4141
click==8.1.7
4242
semver>=3.0.2
4343
numpy>=1.24.0

0 commit comments

Comments
 (0)