Skip to main content

Quickstart to External Data Lake Search

Public Preview

External data lake search lets you search massive datasets with zero-copy access to data in external storage or imported into Zilliz Cloud, without keeping compute resources running continuously. You can create collections from external volumes or imported files, build indexes and refresh metadata via the project data plane endpoint, and start an on-demand cluster only when you need to run search or query workloads.

To do so, the procedure is as follows:

Before you start​

  • Create storage integration.

    A storage integration is a profile that records your data location with access credentials. To set up storage integration, follow the steps to create an AWS S3, Google GCS, or Azure storage integration and obtain the storage integration ID.

  • Create an external volume.

    An external volume is a path within storage integration. Ensure that your raw data is on that path. You can create multiple external volumes from the same storage integration. To create an external volume, refer to External Volumes.

Step 1: Connect to a project endpoint.​

Before working on a database, connect to the project endpoint. You can obtain the project endpoint on the quickstart page after enabling on-demand compute on the Zilliz Cloud console.

Notes

External collection operations require an API key for authentication. This flow does not support username:password authentication.

python
from pymilvus import MilvusClient, DataType

# connect to database
client = MilvusClient(
# a project-specific on-demand compute endpoint
uri="https://{project-id}.{region}.api.zillizcloud.com",
token="YOUR_API_KEY"
)

Step 2: (Optional) Create a database.​

Zilliz Cloud ships with a default database. If you choose that, skip this step. You can also create a database as follows.

python
client.create_database(
db_name="my_database"
)

Step 3: Create an external collection.​

Once the database is ready, you can create external collections in it. An external collection maps its columns to the data files you specify and attaches on-demand compute resources for the searches in that collection.

Unlike managed collections that require you to import your raw data into the collection, external collections generate metadata from your raw data via sub-second refresh operations.

The following example demonstrates how to set up the mapping relationship between collection fields and your data files. When creating the schema, specify the volume path and data format. This quickstart uses an Iceberg table. For the complete list of supported data sources and formats, see Supported data sources and formats.

python
schema = MilvusClient.create_schema(
external_source='volume://my_volume/iceberg/metadata/00001-xxx.metadata.json',
external_spec='{"format": "iceberg-table", "snapshot_id": "1234567890123456789"}'
)

schema.add_field(
field_name="vector",
datatype=DataType.FLOAT_VECTOR,
dim=1536,
# highlight-next
external_field="embedding" # field name in the external data file
)

schema.add_field(
field_name="product_id",
datatype=DataType.VARCHAR,
max_length=32,
nullable=True,
# highlight-next
external_field="product_id"
)

schema.add_field(
field_name="title",
datatype=DataType.VARCHAR,
max_length=512,
nullable=True,
# highlight-next
external_field="title"
)

schema.add_field(
field_name="main_category",
datatype=DataType.VARCHAR,
max_length=64,
nullable=True,
# highlight-next
external_field="main_category"
)

schema.add_field(
field_name="price",
datatype=DataType.DOUBLE,
nullable=True,
# highlight-next
external_field="price"
)

schema.add_field(
field_name="average_rating",
datatype=DataType.DOUBLE,
nullable=True,
# highlight-next
external_field="average_rating"
)

schema.add_field(
field_name="rating_number",
datatype=DataType.INT64,
nullable=True,
# highlight-next
external_field="rating_number"
)

Then you can create a collection with the above schema. If you decide to use the default database, you can safely skip the db_name parameter.

python
client.use_database(
db_name="my_database"
)

# create the collection
client.create_collection(
collection_name="my_collection",
schema=schema
)

Use a collection from a dedicated cluster as the data source​

The steps above create an external collection from data files on an external volume. You can also use a collection on another dedicated cluster as the data source: when creating the schema, set external_source to the milvus:// URI of the source collection.

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.

  • 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.

  • Connect to the project endpoint with your API key and the query cluster ID (in Python, option={"cluster_id": "<query cluster id>"}).

  • 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. Cloud providers: AWS regions are supported.

Create the collection with the schema as usual. For each field, set external_field to the name of the corresponding field in the source collection. You can omit external_spec, because the format of a milvus:// source defaults to milvus-table.

python
from pymilvus import MilvusClient, DataType

# Connect to the project endpoint with an API key and the query cluster ID
client = MilvusClient(
uri="https://{project-id}.{region}.api.zillizcloud.com",
token="YOUR_API_KEY",
db_name="my_database",
option={"cluster_id": "<query cluster id>"}
)

# Point the schema to the source collection; external_spec is omitted
schema = MilvusClient.create_schema(
external_source="milvus://in01-xxxxxxxxxxxxxxx/default/products"
)

# Map each field to the corresponding field in the source collection
schema.add_field(
field_name="vector",
datatype=DataType.FLOAT_VECTOR,
dim=1536,
external_field="embedding"
)

schema.add_field(
field_name="product_id",
datatype=DataType.VARCHAR,
max_length=32,
external_field="product_id"
)

schema.add_field(
field_name="title",
datatype=DataType.VARCHAR,
max_length=512,
external_field="title"
)

# Create the collection
client.create_collection(
collection_name="my_collection",
schema=schema
)

Create indexes and refresh the collection as described in Step 4. For an external collection 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(
collection_name="my_collection",
external_source="milvus://in01-xxxxxxxxxxxxxxx/default/products"
)

Once the refresh completes, create an on-demand cluster and conduct searches as described in Step 5 and Step 6. For details, see Use a Collection from a Serving Cluster as Data Source.

Step 4: Create indexes and refresh the collection.​

You can create indexes in an external database as you do in managed collections. All vector fields should be indexed, and you can select to index some scalar fields for fast metadata filtering. However, you need to call refresh to build the index.

python
index_params = client.prepare_index_params()

# Add indexes
index_params.add_index(
field_name="vector",
index_type="AUTOINDEX",
metric_type="COSINE"
)

index_params.add_index(
field_name="main_category",
index_type="AUTOINDEX"
)

client.create_index(
db_name="my_database",
collection_name="my_collection",
index_params=index_params
)

Then refresh the external collection. You can omit externalSource and externalSpec to reuse the collection schema, or provide both to refresh the collection schema from a new source.

python
# refresh the external database
job_id = client.refresh_external_collection(
collection_name="my_collection"
)

Then you can create a loop to wrap the progress-monitoring calls and track the refresh operation's progress.

python
progress = client.get_refresh_external_collection_progress(job_id=job_id)

Step 5: Create an on-demand cluster​

Once your external collection is ready, you need to attach it to an on-demand cluster for on-demand searches. The following command creates a cluster and returns its ID.

bash
export CONTROL_PLANE_ENDPOINT="https://api.cloud.zilliz.com"

curl --request POST \
--url "${CONTROL_PLANE_ENDPOINT}/v2/clusters/createOnDemandCluster" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json" \
-d '{
"projectId": "proj-xxxxxxxxxxxxxxxxxxx",
"regionId": "aws-us-west-2",
"clusterName": "my-on-demand",
"cuSize": 8,
"autoSuspend": 60
}'

# inxx-xxxxxxxxxxxxx

By default, the cluster automatically suspends for 60 seconds after the last request, and you can set it to a value that suits your use cases.

Step 6: Conduct searches.​

When you need to conduct searches, queries, or hybrid searches, you can attach to the on-demand cluster created in the previous step through a session.

python
session = client.session(
cluster_id="inxx-xxxxxxxxxxxxx"
)

# 1536-dimensional vector
query_vector = [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, -0.26286205330961354, ..., 0.9029438446296592]
res = session.search(
db_name="my_database",
collection_name="my_collection",
anns_field="vector",
data=[query_vector],
limit=3,
output_fields=["product_id", "title", "main_category", "price", "average_rating", "rating_number"]
)

Then, you can explore your data and find the most valuable subset. Then you can connect to a serving cluster, import the data into it, and serve it for production.