Elasticsearch から
本ガイドでは、ElasticsearchからMilvus 2.xへデータを移行するための包括的なステップバイステップのプロセスを提供します。本ガイドに従うことで、Milvus 2.xの高度な機能と改善されたパフォーマンスを活用しながら、効率的にデータを移行することができます。
前提条件
- ソフトウェアのバージョン
- ソース Elasticsearch:7.xまたは8.x
- ターゲットMilvus: 2.x
- インストールの詳細については、Elasticsearchのインストールと Milvusのインストールをご参照ください。
- 必要なツール
- Milvus-migrationツール。インストールの詳細については、マイグレーションツールのインストールを参照してください。
- マイグレーションでサポートされるデータタイプ移行元の Elasticsearch インデックスから移行するフィールドのデータ型は以下の通りです -dense_vector、keyword、text、long、integer、double、float、boolean、object。ここに記載されていないデータ型は、現在移行をサポートしていません。MilvusコレクションとElasticsearchインデックス間のデータマッピングの詳細についてはフィールドマッピングリファレンスを参照してください。
- Elasticsearch インデックスの要件
- 移行元の Elasticsearch インデックスには
dense_vector型のベクトルフィールドが含まれている必要があります。ベクトルフィールドがないとマイグレーションを開始できません。
- 移行元の Elasticsearch インデックスには
マイグレーションファイルの設定
サンプルのマイグレーション設定ファイルをmigration.yaml として保存し、実際の条件に基づいて設定を変更します。コンフィグファイルは任意のローカルディレクトリに自由に置くことができます。
dumper: # configs for the migration job.
worker:
workMode: "elasticsearch" # operational mode of the migration job.
reader:
bufferSize: 2500 # buffer size to read from Elasticsearch in each batch. A value ranging from 2000 to 4000 is recommended.
meta: # meta configs for the source Elasticsearch index and target Milvus 2.x collection.
mode: "config" # specifies the source for meta configs. currently, onlly `config` is supported.
version: "8.9.1"
index: "qatest_index" # identifies the Elasticsearch index to migrate data from.
fields: # fields within the Elasticsearch index to be migrated.
- name: "my_vector" # name of the Elasticsearch field.
type: "dense_vector" # data type of the Elasticsearch field.
dims: 128 # dimension of the vector field. required only when `type` is `dense_vector`.
- name: "id"
pk: true # specifies if the field serves as a primary key.
type: "long"
- name: "num"
type: "integer"
- name: "double1"
type: "double"
- name: "text1"
maxLen: 1000 # max. length of data fields. required only for `keyword` and `text` data types.
type: "text"
- name: "bl1"
type: "boolean"
- name: "float1"
type: "float"
milvus: # configs specific to creating the collection in Milvus 2.x
collection: "Collection_01" # name of the Milvus collection. defaults to the Elasticsearch index name if not specified.
closeDynamicField: false # specifies whether to disable the dynamic field in the collection. defaults to `false`.
shardNum: 2 # number of shards to be created in the collection.
consistencyLevel: Strong # consistency level for Milvus collection.
source: # connection configs for the source Elasticsearch server
es:
urls:
- "http://10.15.1.***:9200" # address of the source Elasticsearch server.
username: "" # username for the Elasticsearch server.
password: "" # password for the Elasticsearch server.
target:
mode: "remote" # storage location for dumped files. valid values: `remote` and `local`.
remote: # configs for remote storage
outputDir: "migration/milvus/test" # output directory path in the cloud storage bucket.
cloud: "aws" # cloud storage service provider. Examples: `aws`, `gcp`, `azure`, etc.
region: "us-west-2" # region of the cloud storage; can be any value if using local Minio.
bucket: "zilliz-aws-us-****-*-********" # bucket name for storing data; must align with configs in milvus.yaml for Milvus 2.x.
useIAM: true # whether to use an IAM Role for connection.
checkBucket: false # checks if the specified bucket exists in the storage.
milvus2x: # connection configs for the target Milvus 2.x server
endpoint: "http://10.102.*.**:19530" # address of the target Milvus server.
username: "****" # username for the Milvus 2.x server.
password: "******" # password for the Milvus 2.x server.
次の表は、コンフィグファイル例のパラメータを説明したものです。コンフィグファイルの全リストはMilvus Migration を参照してください:Elasticsearch から Milvus 2.x への移行をご参照ください。
dumperパラメータ 説明 dumper.worker.workMode移行ジョブの動作モード。Elasticsearch のインデックスから移行する場合は elasticsearchに設定します。dumper.worker.reader.bufferSize各バッチでElasticsearchから読み込むバッファサイズ。単位:KB。 metaパラメータ 説明 meta.modemeta configs のソースを指定します。現在のところ、 configのみがサポートされています。meta.indexデータを移行する Elasticsearch インデックスを指定します。 meta.fields移行する Elasticsearch インデックス内のフィールド。 meta.fields.nameElasticsearch フィールドの名前。 meta.fields.maxLenフィールドの最大長。このパラメータは meta.fields.typeがkeywordまたはtextの場合のみ必要です。meta.fields.pkフィールドが主キーの役割を果たすかどうかを指定します。 meta.fields.typeElasticsearch フィールドのデータ型。現在 Elasticsearch でサポートされているデータ型は以下の通りです:dense_vector、keyword、text、long、integer、double、float、boolean、object。 meta.fields.dimsベクトルフィールドの次元。このパラメータは meta.fields.typeがdense_vectorの場合のみ必要です。meta.milvusMilvus 2.x でのコレクション作成に固有の設定。 meta.milvus.collectionMilvusコレクションの名前。指定しない場合、Elasticsearchインデックス名がデフォルトです。 meta.milvus.closeDynamicFieldコレクションのダイナミックフィールドを無効にするかどうかを指定します。デフォルトは falseです。動的フィールドの詳細については、動的フィールドの有効化を参照してください。meta.milvus.shardNumコレクションに作成するシャードの数。シャードの詳細は、"用語" を参照してください。 meta.milvus.consistencyLevelMilvus におけるコレクションの整合性レベル。詳細は、"一貫性" を参照してください。 sourceパラメータ 説明 source.es接続元 Elasticsearch サーバの接続設定。 source.es.urls接続元 Elasticsearch サーバのアドレス。 source.es.usernameElasticsearch サーバのユーザ名。 source.es.passwordElasticsearch サーバのパスワード targetパラメータ 説明 target.modeダンプされたファイルの保存場所。有効な値:
-local: ダンプしたファイルをローカルディスクに保存します。
-remote: ダンプしたファイルをオブジェクトストレージに保存します。target.remote.outputDirクラウドストレージバケット内の出力ディレクトリパス。 target.remote.cloudクラウドストレージサービスプロバイダ。値の例: awsgcp,azure.target.remote.regionクラウドストレージのリージョン。ローカルのMinIOを使用する場合は、任意の値を指定できます。 target.remote.bucketデータを保存するバケット名。値はMilvus 2.xの設定と同じでなければなりません。詳細はシステム設定を参照してください。 target.remote.useIAM接続にIAM Roleを使用するかどうか。 target.remote.checkBucket指定したバケットがオブジェクトストレージに存在するかどうかを確認するかどうか。 target.milvus2x接続先Milvus 2.xサーバの接続設定 target.milvus2x.endpoint接続先Milvusサーバのアドレス target.milvus2x.usernameMilvus 2.xサーバのユーザ名。このパラメータはMilvusサーバでユーザ認証が有効になっている場合に必要です。詳細については、認証の有効化を参照してください。 target.milvus2x.passwordMilvus 2.xサーバのパスワード。このパラメータは、Milvus サーバでユーザ認証が有効になっている場合に必要です。詳細については、「認証の有効化」を参照してください。
移行タスクの開始
以下のコマンドで移行タスクを開始します。{YourConfigFilePath} は設定ファイルmigration.yaml が存在するローカルディレクトリに置き換えてください。
./milvus-migration start --config=/{YourConfigFilePath}/migration.yaml
以下はマイグレーションが成功した場合のログ出力例です:
[task/load_base_task.go:94] ["[LoadTasker] Dec Task Processing-------------->"] [Count=0] [fileName=testfiles/output/zwh/migration/test_mul_field4/data_1_1.json] [taskId=442665677354739304]
[task/load_base_task.go:76] ["[LoadTasker] Progress Task --------------->"] [fileName=testfiles/output/zwh/migration/test_mul_field4/data_1_1.json] [taskId=442665677354739304]
[dbclient/cus_field_milvus2x.go:86] ["[Milvus2x] begin to ShowCollectionRows"]
[loader/cus_milvus2x_loader.go:66] ["[Loader] Static: "] [collection=test_mul_field4_rename1] [beforeCount=50000] [afterCount=100000] [increase=50000]
[loader/cus_milvus2x_loader.go:66] ["[Loader] Static Total"] ["Total Collections"=1] [beforeTotalCount=50000] [afterTotalCount=100000] [totalIncrease=50000]
[migration/es_starter.go:25] ["[Starter] migration ES to Milvus finish!!!"] [Cost=80.009174459]
[starter/starter.go:106] ["[Starter] Migration Success!"] [Cost=80.00928425]
[cleaner/remote_cleaner.go:27] ["[Remote Cleaner] Begin to clean files"] [bucket=a-bucket] [rootPath=testfiles/output/zwh/migration]
[cmd/start.go:32] ["[Cleaner] clean file success!"]
結果の確認
移行タスクが実行されると、APIコールを実行したり、Attuを使用して移行されたエンティティの数を表示できます。詳細については、Attuおよびget_collection_stats() を参照してください。
フィールドマッピングの参照
Elasticsearch インデックスのフィールド型が Milvus コレクションのフィールド型にどのようにマッピングされているかを理解するために以下の表を確認してください。
Milvus でサポートされているデータ型の詳細については、サポートされているデータ型を参照してください。
| Elasticsearch フィールドタイプ | Milvus フィールドタイプ | 説明 |
|---|---|---|
| dense_vector | FloatVector | ベクタの次元はマイグレーション中も変更されません。 |
| キーワード | VarChar | 最大長を設定します (1 から 65,535)。制限を超える文字列はマイグレーションエラーを引き起こす可能性があります。 |
| テキスト | VarChar | 最大長(1~65,535)を設定します。制限を超える文字列はマイグレーションエラーを引き起こす可能性があります。 |
| long | Int64 | - |
| 整数 | Int32 | - |
| double | Double | - |
| float | フロート | - |
| boolean | ブール | - |
| オブジェクト | JSON | - |