メインコンテンツまでスキップ

Snapshot をデータソースとして使用

Milvus snapshot から external collection を作成するには、snapshot metadata JSON path を external_source として使用し、external_spec.format"milvus-table" に設定します。

external collection を refresh すると、Milvus はソースの segment manifests をターゲットの external segments にマッピングします。メインの column data は snapshot source から参照されたままになり、生成された function outputs や変換された delete logs など、ターゲット所有のデータはターゲット collection 配下に書き込まれます。

始める前に

external collection を作成する前に、以下を確認してください。

  • ソース snapshot が、Milvus v3.0.x server と互換性のある Zilliz Cloud cluster 内の collection から作成されていること。

  • ソース collection 自体が external collection ではないこと。

  • external_source が具体的な snapshot metadata JSON file を指していること。例: s3://bucket/snapshots/{source_collection_id}/metadata/{snapshot_id}.json

  • 各ターゲット data field が、対応するソース field name に external_field を設定していること。

  • ターゲット schema が、マッピングされた data fields についてソース snapshot schema と一致していること。

ソース snapshot が、v3.0.x release の Milvus instance と互換性のある Zilliz Cloud cluster 上で作成された collection からのものではない場合、ソース schema がターゲット schema と一致しない場合、snapshot metadata JSON に manifest 情報がない場合、またはソースが別の external collection である場合、作成または refresh は失敗します。

Milvus snapshot から external collection を作成する

次の例では、既存の snapshot から milvus-table external collection を作成し、それを refresh します。

Step 1: snapshot metadata path を取得する

通常の Milvus collection から snapshot を作成または選択し、その後 describe して object-storage location を取得します。

python
from pymilvus import DataType, MilvusClient

client = MilvusClient(
uri="YOUR_CLUSTER_ENDPOINT",
token="YOUR_CLUSTER_TOKEN"
)

snapshot_info = client.describe_snapshot(
snapshot_name="analytics_snapshot_20260321",
include_collection_info=True
)

external_source = f"s3://bucket/{snapshot_info.s3_location}"

Step 2: milvus-table external collection を作成して refresh する

schema が snapshot source collection と一致する external collection を作成します。external_spec.format"milvus-table" に設定し、各ターゲット data field の external_field を対応するソース field name に設定します。

python
schema = client.create_schema(
external_source=external_source,
external_spec="""{
"format": "milvus-table",
"extfs": {
"cloud_provider": "aws",
"region": "us-west-2",
"access_key_id": "YOUR_ACCESS_KEY",
"access_key_value": "YOUR_SECRET_KEY"
}
}""",
)

schema.add_field(
field_name="id",
datatype=DataType.INT64,
is_primary=True,
external_field="id",
)
schema.add_field(
field_name="embedding",
datatype=DataType.FLOAT_VECTOR,
dim=768,
external_field="embedding",
)

client.create_collection(
collection_name="snapshot_external_collection",
schema=schema,
)

データを refresh する

collection の準備ができたら、refresh してデータの metadata と indexes を作成します。詳細については、External Collection を作成する を参照してください。

Ctrl I