Skip to content

Opt-in Weaviate multi-tenancy, vector compression, and advanced index options#38215

Draft
dudanogueira wants to merge 2 commits into
langgenius:mainfrom
dudanogueira:feat/weaviate-multitenancy-compression
Draft

Opt-in Weaviate multi-tenancy, vector compression, and advanced index options#38215
dudanogueira wants to merge 2 commits into
langgenius:mainfrom
dudanogueira:feat/weaviate-multitenancy-compression

Conversation

@dudanogueira

@dudanogueira dudanogueira commented Jun 30, 2026

Copy link
Copy Markdown

Summary

Adds opt-in, default-off options to the Weaviate vector backend: native multi-tenancy, vector compression, and configurable index type / distance metric. Existing behavior is unchanged when the flags are off, and existing datasets keep their persisted layout.

Stacked on #38214 (Weaviate 1.38 / client 4.22) — it uses the client 4.22 quantizer/index APIs, so it should merge after that PR. Until then this PR's diff also includes the 1.38 upgrade commit.

  • Multi-tenancy (WEAVIATE_MULTI_TENANCY_ENABLED): new datasets sharing an embedding model are stored as isolated tenants in one shared collection (tenant = dataset id) instead of one collection per dataset. The chosen layout is persisted in index_struct, so existing datasets are never silently migrated.
  • Compression (WEAVIATE_COMPRESSION): rq | pq | bq | sq with tuning knobs; a flat index is restricted to bq.
  • Index type (WEAVIATE_INDEX_TYPE): hnsw | flat | dynamic, plus WEAVIATE_DYNAMIC_INDEX_THRESHOLD and WEAVIATE_DISTANCE_METRIC. Dynamic index requires ASYNC_INDEXING=true on the server (added to the compose files, default off) with a clear error hint.
  • Optional WEAVIATE_REPLICATION_FACTOR.

All data operations are routed through a tenant-scoped collection helper; tenant create/remove is handled on collection creation and delete.

Fixes #38212

Screenshots

Before After
N/A — backend / configuration only (no UI) N/A

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) — both pass. Frontend pnpm exec vp staged N/A (no frontend changes).

From Claude Code

- Bump image to cr.weaviate.io/semitechnologies/weaviate:1.38.1 across
  docker-compose.yaml, docker-compose.middleware.yaml, and the template
- Bump weaviate-client 4.20.5 -> 4.22.0 (vdb-weaviate package + uv.lock)
- Add missing WEAVIATE_GRPC_ENDPOINT / EXPOSE_WEAVIATE_GRPC_PORT entries to
  api/.env.example, integration test env, and middleware.env.example
@dudanogueira dudanogueira requested a review from a team June 30, 2026 10:05
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 30, 2026
… options

Adds backward-compatible, default-off options to the Weaviate vector backend:

- Multi-tenancy (WEAVIATE_MULTI_TENANCY_ENABLED): new datasets sharing an
  embedding model are stored as isolated tenants in one shared collection
  (tenant = dataset id) instead of one collection per dataset. Existing
  datasets keep their persisted layout; the layout is recorded in index_struct.
- Vector compression (WEAVIATE_COMPRESSION): rq | pq | bq | sq with tuning knobs;
  flat index restricted to bq.
- Index type (WEAVIATE_INDEX_TYPE): hnsw | flat | dynamic, plus
  WEAVIATE_DYNAMIC_INDEX_THRESHOLD and WEAVIATE_DISTANCE_METRIC.
  Dynamic index requires ASYNC_INDEXING on the server; added
  ASYNC_INDEXING env to the compose files (default off) and a clear error hint.
- Optional WEAVIATE_REPLICATION_FACTOR.

All data operations are routed through a tenant-scoped collection helper; tenant
create/remove is handled on delete and collection creation. Adds 25 unit tests
covering index/compression building, the flat+non-BQ constraint, tenant scoping,
and factory layout selection; existing tests updated for the new surface.
@dudanogueira dudanogueira force-pushed the feat/weaviate-multitenancy-compression branch from 2140c2a to d1670f6 Compare June 30, 2026 10:12
@dudanogueira dudanogueira marked this pull request as draft June 30, 2026 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optional Weaviate native multi-tenancy, vector compression, and advanced index options

1 participant