Skip to Content
We are live but in Staging 🎉

String fields are how you store text attributes (metadata) next to your vectors — things like:

  • Document title, URL, file name
  • Customer / tenant IDs
  • Tags (“invoice”, “support”, “legal”)
  • Source identifiers (“slack”, “email”, “notion”)

In DODIL VBase, string fields map to a VARCHAR field type.

Key rules

1) You must set a maximum length

When you define a string field, you must provide:

  • datatype=DataType.VARCHAR
  • max_length=<number>

max_length is the maximum number of bytes a value can take. The allowed range is 1 → 65,535.

Because it is measured in bytes, not “characters”, using UTF-8 content (Arabic, emoji, etc.) means some values may consume more bytes per character.

2) Optional: allow nulls and/or set a default

You can make a string field optional by setting:

  • nullable=True

And you can provide a fallback value with:

  • default_value="..."

This is useful when you want inserts to succeed even if a specific attribute is missing.

3) Optional: dynamic fields

If you enable dynamic fields (enable_dynamic_fields=True), you can insert extra scalar fields that were not pre-declared in your schema.

This can be convenient during early prototyping, but it also makes schemas harder to reason about at scale (more inconsistent fields, more complex filters).

Example: add string fields to a collection schema

This example creates a collection with two string fields:

  • title: up to 256 bytes, optional, default to "Untitled"
  • source: up to 64 bytes, optional

Assumption: you already have a vbase connection (see the Connect section in the docs).

# Python 3.10+ from dodil.vbase import VBaseConfig from dodil.vbase import DataType from dodil import Client c = Client( service_account_id="...", service_account_secret="...", ) vbase = c.vbase.connect( VBaseConfig( host="vbase-db-<id>.infra.dodil.cloud", port=443, scheme="https", db_name="db_<id>", ) ) # Build a schema using the underlying schema builder. # (We expose `vbase.raw` for full compatibility with the backend engine.) schema = vbase.raw.create_schema( auto_id=False, enable_dynamic_fields=True, ) schema.add_field( field_name="title", datatype=DataType.VARCHAR, max_length=256, nullable=True, default_value="Untitled", ) schema.add_field( field_name="source", datatype=DataType.VARCHAR, max_length=64, nullable=True, ) # Primary key schema.add_field( field_name="id", datatype=DataType.INT64, is_primary=True, ) # Vector field schema.add_field( field_name="embedding", datatype=DataType.FLOAT_VECTOR, dim=768, ) # Create the collection vbase.create_collection( collection_name="docs", schema=schema, )
Last updated on