Skip to content

Conversation

@CShorten
Copy link
Contributor

Overview

Adds Weaviate as a vector database backend to Modaic with full support for vector search, metadata filtering, and complex data types.

Core Implementation

WeaviateBackend Class

  • Implements VectorDBBackend interface for local and cloud-hosted instances
  • Connection via __init__(url, api_key) or from_local() factory method
  • Full collection CRUD: create, drop, list, check existence
  • Record operations: add, retrieve by ID
  • Vector search with configurable k and metadata filtering

Data Handling

  • Automatic JSON serialization/deserialization for nested objects and dicts
  • Support for arrays of primitives and objects
  • Proper null/None value handling
  • UUID-based record identification

MQL Filter Translation

  • WeaviateTranslator converts Modaic queries to Weaviate filters
  • Supports logical operators (AND, OR, NOT), comparisons (==, !=, >, <, etc.), and collection operators (IN, CONTAIN, LIKE)

Type System Integration

  • Maps Modaic vector types (FLOAT, FLOAT16, BFLOAT16) to Weaviate formats
  • Supports HNSW, FLAT, and DYNAMIC index types
  • Distance metrics: cosine, L2, dot product, euclidean
  • Schema translation handles all Modaic types including optionals and nested structures

Test Coverage

  • Parameterized tests for local and hosted instances
  • MQL translation validation
  • Collection and record CRUD operations
  • Vector search with various k values and filter combinations
  • Multi-vector batch search
  • Null value handling (advantage over backends like Milvus Lite)
  • CustomContext test model covering all supported field types

All tests pass with proper resource cleanup.

@CShorten CShorten changed the title Add Weaviate to Vector Databases! Add Weaviate to Vector Databases Nov 11, 2025
@TyTodd
Copy link
Collaborator

TyTodd commented Nov 22, 2025

Thanks for submitting. Implementation looks great! I'm running the test cases on hosted mode and getting this error.

        results_k1 = vector_database.search(collection_name, "query", k=1)
>       assert results_k1[0][0].context == context1
               ^^^^^^^^^^^^^^^^
E       IndexError: list index out of range

tests/databases/vector_database/test_weaviate.py:325: IndexError
================================================================================================================================================================================================= warnings summary ==================================================================================================================================================================================================
tests/databases/vector_database/test_weaviate.py::test_search[hosted]
  /Users/tytodd/Desktop/Modaic/code/modaic/.venv/lib/python3.11/site-packages/weaviate/warnings.py:206: DeprecationWarning: Dep025: You are using the `vector_index_config` argument in `collection.config.create()`, which is deprecated.
              Use the `vector_config` argument instead defining `vector_index_config` as a sub-argument.
              
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================================================================================================================================================== short test summary info ==============================================================================================================================================================================================
FAILED tests/databases/vector_database/test_weaviate.py::test_search[hosted] - IndexError: list index out of range

Are you seeing this on your end?

Other than that I think its ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants