Skip to content

Allow specifying custom options for multi-tenancy on a schema #47

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

Merged
Show file tree
Hide file tree
Changes from all 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
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