コレクションフィールドを変更する
コレクションフィールドのプロパティを変更して、列の制約を変更したり、より厳格なデータ整合性ルールを適用したりできます。
各コレクションは1つのプライマリフィールドのみで構成されています。コレクション作成時に設定したプライマリフィールドやそのプロパティを変更することはできません。
各コレクションには1つのパーティションキーしか持てません。コレクション作成時に設定したパーティションキーは変更できません。
Alter VarCharフィールド
VarCharフィールドには、max_length
という名前のプロパティがあり、フィールド値に含めることができる最大文字数を制限します。max_length
プロパティは変更できます。
次の例では、コレクションがVarCharという名前のフィールドvarchar
を持ち、そのmax_length
プロパティを設定します。
- Python
- Java
- NodeJS
- Go
- cURL
from pymilvus import MilvusClient
client = MilvusClient(
uri="YOUR_CLUSTER_ENDPOINT",
token="YOUR_CLUSTER_TOKEN"
)
client.alter_collection_field(
collection_name="my_collection",
field_name="varchar",
field_params={
"max_length": 1024
}
)
import io.milvus.v2.client.MilvusClientV2;
import io.milvus.v2.client.ConnectConfig;
import io.milvus.v2.service.collection.request.*;
ConnectConfig config = ConnectConfig.builder()
.uri("YOUR_CLUSTER_ENDPOINT")
.token("YOUR_CLUSTER_TOKEN")
.build();
MilvusClientV2 client = new MilvusClientV2(config);
client.alterCollectionField(AlterCollectionFieldReq.builder()
.collectionName("my_collection")
.fieldName("varchar")
.property("max_length", "1024")
.build());
// TODO
// TODO
// TODO
Alter ARRAYフィールド
配列のフィールドには、element_type
とmax_Capacity
の2つのプロパティがあります。前者は配列内の要素のデータ型を決定し、後者は配列内の最大要素数を制限します。max_Capacity
プロパティのみを変更できます。
次の例では、コレクションにarrayという名前の配列
フィールドがあり、そのmax_bility
プロパティを設定することを前提としています。
- Python
- Java
- NodeJS
- Go
- cURL
client.alter_collection_field(
collection_name="my_collection",
field_name="array",
field_params={
"max_capacity": 64
}
)
client.alterCollectionField(AlterCollectionFieldReq.builder()
.collectionName("my_collection")
.fieldName("array")
.property("max_capacity", "64")
.build());
await client.alterCollectionFieldProperties({
collection_name: "my_collection",
field_name: 'array',
properties: {
max_capacity: 64
}
});
// TODO
// TODO
フィールドレベルのmmap設定を変更する
メモリマッピング(Mmap)により、ディスク上の大きなファイルに直接メモリアクセスできるため、Zilliz Cloudはインデックスとデータをメモリとハードドライブの両方に保存できます。このアプローチにより、アクセス頻度に基づいてデータ配置ポリシーを最適化し、検索パフォーマンスに影響を与えることなくコレクションのストレージ容量を拡張できます。
次の例では、コレクションにdoc_chunk
という名前のフィールドがあると仮定し、そのmmap_enable
プロパティを設定します。
- Python
- Java
- NodeJS
- Go
- cURL
client.alter_collection_field(
collection="my_collection",
field_name="doc_chunk",
properties={"mmap.enabled": True}
)
client.alterCollectionField(AlterCollectionFieldReq.builder()
.collectionName("my_collection")
.fieldName("doc_chunk")
.property("mmap.enabled", "True")
.build());
await client.alterCollectionProperties({
collection_name: "my_collection",
field_name: 'doc_chunk',
properties: {
'mmap.enabled': true,
}
});
// TODO
// TODO