Skip to Content
We are live but in Staging 🎉

INVERTED

When your workload includes lots of filtering (for example, status == "active", category in ["books", "electronics"], or metadata["country"] == "EG"), scanning every record becomes expensive.

An INVERTED index solves this by pre-building a lookup structure that maps field values → the IDs that contain them, so filters can be answered quickly.

In Dodil VBase (Milvus-backed), INVERTED is a scalar index that accelerates filtering. It doesn’t change vector similarity math—it helps you narrow candidates fast.

When to use an INVERTED index

Use INVERTED when you frequently:

  • Filter by exact values
    • Example: category == "electronics"
  • Filter or match on text fields (VARCHAR)
    • Example: tenant == "acme" or source == "github"
  • Filter inside JSON fields (by indexing a specific JSON path)
    • Example: metadata["region"] == "eu-west"

If your queries always do “vector search + filters”, INVERTED can make the filter phase much faster—especially on large collections.

How it works

Think of INVERTED as two conceptual mappings:

  1. Forward mapping: id → value (what each record contains)
  2. Inverted mapping: value → [ids...] (which records contain a value)

So when you run category == "electronics", the engine looks up “electronics” and immediately gets the matching IDs—no full scan.

Supported field types

INVERTED is designed for scalar filtering. You can create it on most scalar fields, including:

  • BOOL
  • INT8/16/32/64
  • FLOAT/DOUBLE
  • VARCHAR
  • JSON
  • ARRAY (depending on field definition and query patterns)

Create an INVERTED index on a scalar field

Below is a Dodil-flavored example using the Python SDK.

from dodil import Client from dodil.vbase import VBaseConfig # Authorize c = Client( service_account_id="...", service_account_secret="...", ) # Connect vbase = c.vbase.connect( VBaseConfig( host="vbase-db-<id>.infra.dodil.cloud", port=443, scheme="https", db_name="db_<id>", ) ) # Build index params index_params = vbase.prepare_index_params() # Add an INVERTED index on a scalar field index_params.add_index( field_name="category", index_type="INVERTED", index_name="category_inverted", ) # Create the index vbase.create_index( collection_name="products", index_params=index_params, )

Why index names matter

Use descriptive names so operations are obvious later:

  • category_inverted
  • tenant_inverted
  • metadata_country_inverted

Create an INVERTED index on a JSON path

You can index one JSON key/path at a time. This lets you accelerate queries like:

  • metadata["country"] == "EG"
  • metadata["tier"] == "enterprise"
# Build index params index_params = vbase.prepare_index_params() index_params.add_index( field_name="metadata", # the JSON field name index_type="INVERTED", index_name="metadata_country_inverted", params={ # JSON path to index (Milvus-style path string) "json_path": "metadata[\"country\"]", # How the engine should cast the JSON value while indexing # (e.g. "varchar", "int64", "bool", ...) "json_cast_type": "varchar", }, ) vbase.create_index( collection_name="users", index_params=index_params, )

Tip: Only index JSON keys you actually filter on. Indexing too many JSON paths increases build time and storage.

Drop an index

If you no longer need an index, remove it by name:

vbase.drop_index( collection_name="products", index_name="category_inverted", )

Depending on your VBase/Milvus version and your load state, you may need to release a collection before dropping certain scalar indexes. If drop_index() fails with a “collection is loaded” type error, release the collection and retry.

Best practices

  • Create indexes after inserting most of your data: avoids rebuilding too often.
  • Index only what you filter on: each index adds build cost and storage.
  • Keep filters selective: INVERTED is most helpful when it substantially reduces candidates.
  • Validate performance: compare latency before/after for your real query shapes.

Next steps

  • If you’re doing many filtered searches, learn how to combine filtering with vector search in VBase.
  • Explore other scalar indexes (like BITMAP) depending on your field cardinality and query patterns.
Last updated on