A number field is a scalar field that stores numeric values—either whole numbers (integers) or decimal numbers (floating-point). You use number fields for things you want to filter, range query, or join into business logic, like prices, quantities, counters, timestamps, and flags.
Supported number types
VBase supports the same numeric scalar field types as Milvus.
| Type | What it stores | Common examples |
|---|---|---|
BOOL | Boolean values (true / false) | is_active, is_verified |
INT8 | 8-bit signed integer | small counters, tiny enums |
INT16 | 16-bit signed integer | medium counters, small IDs |
INT32 | 32-bit signed integer | quantities, counters |
INT64 | 64-bit signed integer | timestamps, large counters/IDs |
FLOAT | 32-bit floating-point number | scores, measurements |
DOUBLE | 64-bit floating-point number | finance/precision-critical values |
When to use number fields
Number fields are often paired with vector search to make results context-aware.
- E-commerce: filter by
price,in_stock,rating - Observability: filter by
latency_ms,status_code,error_rate - Security: filter by
risk_score,is_blocked,event_ts
Example mental model:
“Find similar items AND match my business rules (price < 100, is_active = true).”
Add number fields to a schema
Below is an example schema that adds:
ageasINT64that allowsnulland defaults to18priceasFLOATthat allowsnull(no default)
Tip: If you enable dynamic fields, you can insert scalar fields that weren’t declared ahead of time. This is flexible, but it’s usually best to keep critical fields explicitly declared.
# Python 3.10+
from dodil import Client
from dodil.vbase import VBaseConfig, CollectionSchema, FieldSchema, DataType
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>",
)
)
fields = [
# Primary key
FieldSchema(name="pk", dtype=DataType.INT64, is_primary=True, auto_id=False),
# Number fields
FieldSchema(name="age", dtype=DataType.INT64, nullable=True, default_value=18),
FieldSchema(name="price", dtype=DataType.FLOAT, nullable=True),
# Vector field (example)
FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=1536),
]
schema = CollectionSchema(
fields=fields,
description="Products with numeric fields",
enable_dynamic_field=True,
)
vbase.create_collection(
collection_name="products",
schema=schema,
)