Skip to content

Commit

Permalink
Allow specifying custom options for multi-tenancy on a schema
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronmccord2 committed Jul 2, 2024
1 parent fa93d2d commit 05b9439
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,30 @@ client.live?
client.ready?
```

### Tenants

Any schema can be multi-tenant

```ruby
client.schema.create(
# Other keys...
mutli_tenant: true, # passes { enabled: true } to weaviate
)
```

You can also manually specify your multi tenancy configuration with a hash

```ruby
client.schema.create(
# Other keys...
mutli_tenant: { enabled: true, autoTenantCreation: true, autoTenantActivation: true },
)
```

See [Weaviate Multi-tenancy operations](https://weaviate.io/developers/weaviate/manage-data/multi-tenancy). Note that the mix of snake case(used by Ruby) and lower camel case(used by Weaviate) is intentional as that hash is passed directly to Weaviate.

All data methods in this library support an optional `tenant` argument which must be passed if multi-tenancy is enabled on the related collection

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Expand Down
6 changes: 5 additions & 1 deletion lib/weaviate/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ def create(
req.body["vectorizer"] = vectorizer unless vectorizer.nil?
req.body["moduleConfig"] = module_config unless module_config.nil?
req.body["properties"] = properties unless properties.nil?
req.body["multiTenancyConfig"] = {enabled: true} unless multi_tenant.nil?
if multi_tenant.is_a?(Hash)
req.body["multiTenancyConfig"] = multi_tenant
elsif multi_tenant.present?
req.body["multiTenancyConfig"] = {enabled: true}
end
req.body["invertedIndexConfig"] = inverted_index_config unless inverted_index_config.nil?
req.body["replicationConfig"] = replication_config unless replication_config.nil?
end
Expand Down

0 comments on commit 05b9439

Please sign in to comment.