Skip to main content

Create an External Collection

Public Preview

An external collection is a type of data collection in Zilliz Cloud that accesses data from external storage systems or database tables such as AWS S3 and Iceberg without copying it into Zilliz Cloud. It acts as a query layer over data lakes while maintaining compatibility with Zilliz Cloud query interfaces.

Notes

You can create an external collection only in an on-demand compute database. Support for creating external collections in serving Dedicated clusters is coming soon.

Overview​

In a typical AI data pipeline, users may already have stored their data in Parquet or other formats on their storage system, such as AWS S3. To make Zilliz Cloud consume this externally stored data, users usually need to import it into Zilliz Cloud's own storage using Extract-Transform-Load (ETL) pipelines.

This bring-your-data-to-Zilliz Cloud workflow creates redundant data that is hard to synchronize and adds to the engineering maintenance burden to ensure data consistency.

YQXWwPQ3vheYa4b8398cWoPNnyN

To resolve these issues, Zilliz Cloud delivers external collections that let you access your externally stored data from Zilliz Cloud without worrying about data synchronization and ETL pipelines.

Q6F4wtcd2h3PnKbnMxncw3urn3f

Once created, an external collection can access your data directly and keep it in the same place where you store it. In the background, Zilliz Cloud creates manifest files to record the mappings between the Zilliz Cloud metadata and the rows in external data files. After the manifest files are ready, you can create indexes in the external collection as you would in any managed collection.

When your data changes, manually triggering a sub-second refresh updates the metadata, keeping Zilliz Cloud always up to date.

External collections are available in the databases for on-demand computing.

Step 1: Create schema​

As with creating a managed collection, you also need to create a schema before creating an external collection. However, the schema is slightly different from that of a managed collection.

Preparation​

  • You have obtained an API key with sufficient permissions (read/write on the target and read on the source for cross-cluster sources). Username:password tokens are not accepted.

    For details, refer to API Keys.

  • For data-file sources (parquet, iceberg-table, lance-table, vortex), you have integrated your object storage bucket and created an external volume containing the target data files.

    For details, refer to AWS, GCP, and Azure docs.

    For details, refer to External Volumes.

  • For a collection from another dedicated cluster, the source is a regular collection (not another external collection) on a dedicated cluster compatible with Milvus v3.0.x in the same project and region as the target, and the target is a database for on-demand search accessed through the project endpoint with a query cluster.

  • Cross-cluster sources (milvus://) are available through SDKs and the RESTful API only in the current release — the console does not support this source type yet. Cloud providers: AWS regions are supported.

Support data sources​

Zilliz Cloud supports the following data sources, and you should provide the corresponding external sources in the format you choose.

  • parquet

    Set external_source to the folder containing the target Parquet files.

  • vortex,

    Set external_source to the folder containing the Vortex columnar files for version 0.56.

  • lance-table

    Set external_source to a folder path that contains sub-folders, such as _transactions, _versions, and data.

  • iceberg-table

    Set external_source to the metadata.json file of the Iceberg table, and pass in the snapshot ID, as in

    python
    external_spec={
    "format": "iceberg-table",
    "snapshot_id": "473984310232959286"
    }
  • milvus-table

    Set external_source to a milvus:// URI. On Zilliz Cloud, external_source accepts two schemes: volume://<volume_name>/<path> and milvus://<instance_id>/<db_name>/<collection_name>. The milvus:// scheme points to a collection on another dedicated cluster compatible with Milvus v3.0.x in the same project and region. The scheme must be lowercase, all three segments are required (including default as the database name), and a single trailing slash is tolerated.

    For this source, external_spec is optional. If you omit it or its format field, the format defaults to milvus-table. For details, refer to Use a Collection from a Serving Cluster as Data Source.

Set up schema​

Once you have an external volume containing the target data files, create the schema to map collection columns to Parquet files (parquet), a lance table (lance-table), an Iceberg table (iceberg-table), or Vortex files of the 0.56.0 format (vortex).

For a cross-cluster source, set external_source to a milvus:// URI instead. The external_spec parameter is optional for such a source; if you omit it or its format field, the format defaults to milvus-table. The snapshot_id and extfs settings do not apply to milvus:// sources.

Notes

The external source should end with a forward slash (/) to indicate this is a folder.

python
schema = MilvusClient.create_schema(
external_source='volume://my_volume/path/to/a/folder/',
external_spec='{"format": "parquet"}'
)

Step 2: Add fields​

Once the schema is ready, you can add fields as follows:

python
schema.add_field(
field_name="product_id",
datatype=DataType.INT64,
# highlight-next
external_field="id" # field name in the external data file
)
schema.add_field(
field_name="product_name",
datatype=DataType.VARCHAR,
max_length=512,
# highlight-next
external_field="name"
)
schema.add_field(
field_name="embedding",
datatype=DataType.FLOAT_VECTOR,
dim=768,
# highlight-next
external_field="vector"
)

Step 3: Create a collection​

After adding all the fields to the schema, you can create the external collection.

Notes

You can create external collections in a database at the project level, which is usually associated with an on-demand cluster.

python
from pymilvus import MilvusClient, DataType
import time

# connect the database
client = MilvusClient(
uri="https://{project-id}.{region}.vectordb.zillizcloud.com",
token="YOUR_API_KEY"
)

client.use_database(
db_name="my_database"
)
# create the collection
client.create_collection(
collection_name="test_collection",
schema=schema
)

Step 4: Create indexes​

You can create indexes for external collection columns as you do in managed collections.

python
index_params = client.prepare_index_params()
# Add indexes
index_params.add_index(
field_name="embedding",
index_type="AUTOINDEX",
metric_type="COSINE"
)
index_params.add_index(
field_name="product_name",
index_type="AUTOINDEX"
)
client.create_index(
db_name="my_database",
collection_name="test_collection",
index_params=index_params
)

Step 5: Refresh data​

Once the collection is ready, refresh it to create the metadata and indexes for your data.

For external collections created from a collection on another dedicated cluster (milvus://):

  • A refresh re-binds the external collection to the external_source passed in the request and syncs the latest data. Omitting external_source reuses the persisted source, and the refresh still syncs the latest data from it.

  • A refresh job transitions from RefreshInProgress to RefreshCompleted or RefreshFailed. A second refresh submitted while one is in progress is rejected. Refresh waits for index building to finish, so its duration scales with data size — from seconds to hours for large collections.

python
job_id = client.refresh_external_collection(
db_name="my_database",
collection_name="test_collection"
)
while True:
progress = client.get_refresh_external_collection_progress(job_id=job_id)
print(f" {progress.state}: {progress.progress}%")
if progress.state == "RefreshCompleted":
elapsed = progress.end_time - progress.start_time
print(f" Completed in {elapsed}ms")
break
elif progress.state == "RefreshFailed":
print(f" Failed: {progress.reason}")
break
time.sleep(2)

The refresh operation is asynchronous, so you need to set up an iteration to monitor its progress.

If you use the RESTful API, check the progress of a refresh job with Describe External Collection Refresh Job, or list the refresh jobs with List External Collection Refresh Jobs.

Notes
  • The refresh operation scans the metadata of the data files and generates the manifest files accordingly. It usually takes 150-250 ms.

  • The manifest files record the mapping between the metadata in Milvus and the rows in external files.

  • If there is an update to your source data, you need to manually call refresh again to keep Zilliz Cloud up to date.

  • A refresh that requires removing all active metadata without any insertions results in a denial.

  • For external collections in a database for on-demand computing, you do not need to load and release them manually.

Troubleshooting​

The following table lists the errors you may encounter when you create or refresh an external collection whose source is a collection on another dedicated cluster (milvus://), and how to resolve them.

ScenarioError messageResolution
Malformed URI or missing segmentinvalid external_source: external_source must be milvus://<instance_id>/<db_name>/<collection_name>Correct the URI so that it includes all three segments.
Source instance does not exist, or you lack read permission on itSource cluster <id> does not exist or you do not have permission to read it.Check the instance ID and the permissions of your API key.
Source collection does not existSource collection <name> on cluster <id> is unavailable: ... collection not found ...Check the database name and the collection name.
Format conflictexternal_spec.format must be "milvus-table" (or omitted) for a milvus:// source, got "parquet"Omit external_spec, or set its format to milvus-table.
Concurrent refreshRefresh job <id> is already in progress for collection <name>; wait for it to complete before refreshing again.Wait for the current refresh job to complete.

Follow-ups​

Once you have refreshed the external collection, you can perform similarity searches and queries in the external collection as you would in any managed collection, except that collections in a database for on-demand computing must be attached to an on-demand cluster for searches and queries. For details, refer to Create On-Demand Cluster and its sibling pages.

Before conducting DQL operations, such as search, query, get, and hybrid search, you need to create a session to attach the compute resources of an on-demand cluster. For details, refer to On-Demand DQL Operations.

Collection as Source

You can use a collection on another Zilliz Cloud dedicated cluster as the data source of an external collection. | Cloud