Skip to content

Commit 05b9439

Browse files
Allow specifying custom options for multi-tenancy on a schema
1 parent fa93d2d commit 05b9439

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,30 @@ client.live?
296296
client.ready?
297297
```
298298

299+
### Tenants
300+
301+
Any schema can be multi-tenant
302+
303+
```ruby
304+
client.schema.create(
305+
# Other keys...
306+
mutli_tenant: true, # passes { enabled: true } to weaviate
307+
)
308+
```
309+
310+
You can also manually specify your multi tenancy configuration with a hash
311+
312+
```ruby
313+
client.schema.create(
314+
# Other keys...
315+
mutli_tenant: { enabled: true, autoTenantCreation: true, autoTenantActivation: true },
316+
)
317+
```
318+
319+
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.
320+
321+
All data methods in this library support an optional `tenant` argument which must be passed if multi-tenancy is enabled on the related collection
322+
299323
## Development
300324

301325
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.

lib/weaviate/schema.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ def create(
4343
req.body["vectorizer"] = vectorizer unless vectorizer.nil?
4444
req.body["moduleConfig"] = module_config unless module_config.nil?
4545
req.body["properties"] = properties unless properties.nil?
46-
req.body["multiTenancyConfig"] = {enabled: true} unless multi_tenant.nil?
46+
if multi_tenant.is_a?(Hash)
47+
req.body["multiTenancyConfig"] = multi_tenant
48+
elsif multi_tenant.present?
49+
req.body["multiTenancyConfig"] = {enabled: true}
50+
end
4751
req.body["invertedIndexConfig"] = inverted_index_config unless inverted_index_config.nil?
4852
req.body["replicationConfig"] = replication_config unless replication_config.nil?
4953
end

0 commit comments

Comments
 (0)