メインコンテンツまでスキップ
バージョン: User Guides (Cloud)

構造体の配列

エンティティ内の構造体の配列フィールドは、構造体要素の順序付きセットを格納します。配列内の各構造体は、複数のベクトルおよびスカラーフィールドで構成される同じ事前定義されたスキーマを共有します。

以下は、構造体の配列フィールドを含むコレクションからのエンティティ例です。

{
'id': 0,
'title': 'Walden',
'title_vector': [0.1, 0.2, 0.3, 0.4, 0.5],
'author': 'Henry David Thoreau',
'year_of_publication': 1845,
'chunks': [
{
'text': 'When I wrote the following pages, or rather the bulk of them...',
'text_vector': [0.3, 0.2, 0.3, 0.2, 0.5],
'chapter': 'Economy',
},
{
'text': 'I would fain say something, not so much concerning the Chinese and...',
'text_vector': [0.7, 0.4, 0.2, 0.7, 0.8],
'chapter': 'Economy'
}
]
// hightlight-end
}

上記の例では、chunks フィールドが構造体の配列フィールドであり、各構造体要素には texttext_vectorchapter というフィールドが含まれています。

使用タイミング

現代のAIアプリケーションは、自律走行からマルチモーダル検索まで、ますますネスト化された異種データに依存しています。伝統的なフラットなデータモデルは、「多数の注釈付きチャンクを持つ1つの文書」や「複数の観測された操作を持つ1つの運転シーン」のような複雑な関係性を表現するのに苦労します。ここがZilliz Cloudの構造体の配列データ型が輝く場所です。

構造体の配列がアプリケーションのシナリオに適しているかどうかを迅速に判断するには、以下のような点を考慮してください:

  • データが階層構造になっており、多数の注釈付きチャンクを持つ1つの文書などです。

  • 上記の例のように、検索結果はチャンクではなく文書そのものであるべきです。

  • 検索結果には多数の重複エンティティが含まれており、グルーピング、重複排除、リランキングなどの技術を使用して最終的な結果を取得するのが難しい状況です。

上記の質問に「はい」と答える場合は、構造体の配列を使用する必要があります。

制限事項

  • データ型

    コレクションを作成する際、構造体型を配列フィールド内の要素のデータ型として使用できます。ただし、既存のコレクションに構造体の配列を追加することはできず、Zilliz Cloudは構造体型をコレクションフィールドのデータ型として使用することをサポートしていません。

    配列フィールド内の構造体は同じスキーマを共有し、これは配列フィールドを作成する際に定義する必要があります。

    構造体スキーマには、以下の表に示すように、ベクトルとスカラーの両方のフィールドが含まれます:

    フィールドタイプ

    データ型

    ベクトル

    FLOAT_VECTOR

    スカラー

    VARCHAR

    INT8/16/32/64

    FLOAT

    DOUBLE

    BOOLEAN

    コレクションレベルと構造体内のベクトルフィールドの両方を合わせたベクトルフィールドの数は、クラスタの上限を超えないようにしてください。詳細はZilliz Cloud Limitsを参照してください。

  • Nullable & デフォルト値

    構造体の配列フィールドはnullableではなく、デフォルト値を受け入れません。

  • 関数

    構造体内でスカラーフィールドからベクトルフィールドを導出する関数を使用することはできません。

  • インデックスタイプ & メトリックタイプ

    コレクション内のすべてのベクトルフィールドにはインデックスを付ける必要があります。構造体の配列フィールド内のベクトルフィールドにインデックスを付けるには、Zilliz Cloudは埋め込みリストを使用して各構造体要素内のベクトル埋め込みを整理し、埋め込みリスト全体にインデックスを付けます。

    AUTOINDEX をインデックスタイプとして使用し、以下のメトリックタイプのいずれかを使用して、構造体の配列フィールド内の埋め込みリストのインデックスを作成できます。

    インデックスタイプ

    メトリックタイプ

    備考

    AUTOINDEX

    MAX_SIM_COSINE

    以下のタイプの埋め込みリスト用:

    • FLOAT_VECTOR

    MAX_SIM_IP

    MAX_SIM_L2

    構造体の配列フィールド内のスカラーフィールドはインデックスをサポートしていません。

  • アップサートデータ

    構造体はマージモードによるアップサートをサポートしていません。ただし、オーバーライドモードでアップサートを実行して、構造体のデータを更新することは可能です。マージモードとオーバーライドモードの違いについては、Upsert Entitiesを参照してください。

  • スカラーによるフィルタリング

    クエリや検索内のフィルタリング式で、構造体の配列またはその構造体要素内のフィールドを使用することはできません。

構造体の配列を追加

Zilliz Cloudクラスターで構造体の配列を使用するには、コレクションを作成する際に配列フィールドを定義し、要素のデータ型をStructに設定する必要があります。プロセスは以下の通りです:

  1. 配列フィールドとしてフィールドをコレクションスキーマに追加する際、フィールドのデータ型を DataType.ARRAY に設定します。

  2. フィールドの element_type 属性を DataType.STRUCT に設定して、フィールドを構造体の配列にします。

  3. 構造体スキーマを作成し、必要なフィールドを含めます。次に、フィールドの struct_schema 属性で構造体スキーマを参照します。

  4. フィールドの max_capacity 属性を適切な値に設定し、このフィールドに含まれる各エンティティが保持できる構造体の最大数を指定します。

  5. (任意)構造体要素内の任意のフィールドについて mmap.enabled を設定し、構造体内のホットデータとコールドデータのバランスを調整できます。

以下は、構造体の配列を含むコレクションスキーマを定義する方法です:

from pymilvus import MilvusClient, DataType

schema = MilvusClient.create_schema()

# コレクションにプライマリフィールドを追加
schema.add_field(field_name="id", datatype=DataType.INT64, is_primary=True, auto_id=True)

# コレクションにいくつかのスカラーフィールドを追加
schema.add_field(field_name="title", datatype=DataType.VARCHAR, max_length=512)
schema.add_field(field_name="author", datatype=DataType.VARCHAR, max_length=512)
schema.add_field(field_name="year_of_publication", datatype=DataType.INT64)

# コレクションにベクトルフィールドを追加
schema.add_field(field_name="title_vector", datatype=DataType.FLOAT_VECTOR, dim=5)

# 構造体スキーマを作成
struct_schema = MilvusClient.create_struct_field_schema()

# 構造体にスカラーフィールドを追加
struct_schema.add_field("text", DataType.VARCHAR, max_length=65535)
struct_schema.add_field("chapter", DataType.VARCHAR, max_length=512)

# mmap有効化で構造体にベクトルフィールドを追加
struct_schema.add_field("text_vector", DataType.FLOAT_VECTOR, mmap_enabled=True, dim=5)

# 構造体スキーマを要素型が `DataType.STRUCT` である配列フィールドで参照
schema.add_field("chunks", datatype=DataType.ARRAY, element_type=DataType.STRUCT,
struct_schema=struct_schema, max_capacity=1000)

上記のコード例のハイライトされた行は、コレクションスキーマに構造体の配列を含める手順を示しています。

インデックスパラメータの設定

コレクション内のベクトルフィールドと要素構造体内に定義されたベクトルフィールドの両方を含む、すべてのベクトルフィールドについてインデックス作成は必須です。

埋め込みリストにインデックスを付けるには、インデックスタイプを AUTOINDEX に設定し、Zilliz Cloudクラスターが埋め込みリスト間の類似性を測定するために MAX_SIM_COSINE をメトリックタイプとして使用します。

# インデックスパラメータを作成
index_params = MilvusClient.prepare_index_params()

# コレクション内のベクトルフィールドのインデックスを作成
index_params.add_index(
field_name="title_vector",
index_type="AUTOINDEX",
metric_type="L2",
)

# 要素構造体内のベクトルフィールドのインデックスを作成
index_params.add_index(
field_name="chunks[text_vector]",
index_type="AUTOINDEX",
metric_type="MAX_SIM_COSINE",
)

コレクションを作成

スキーマとインデックスが準備できたら、構造体の配列フィールドを含むコレクションを作成できます。

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

client.create_collection(
collection_name="my_collection",
schema=schema,
index_params=index_params
)

データの挿入

コレクションを作成した後、構造体の配列を含むデータを以下のように挿入できます。

# サンプルデータ
data = {
'title': 'Walden',
'title_vector': [0.1, 0.2, 0.3, 0.4, 0.5],
'author': 'Henry David Thoreau',
'year_of_publication': 1845,
'chunks': [
{
'text': 'When I wrote the following pages, or rather the bulk of them...',
'text_vector': [0.3, 0.2, 0.3, 0.2, 0.5],
'chapter': 'Economy',
},
{
'text': 'I would fain say something, not so much concerning the Chinese and...',
'text_vector': [0.7, 0.4, 0.2, 0.7, 0.8],
'chapter': 'Economy'
}
]
}

# データを挿入
client.insert(
collection_name="my_collection",
data=[data]
)
さらにデータが必要ですか?
import json
import random
from typing import List, Dict, Any

# 実際に存在する古典的作品(タイトル、著者、年)
BOOKS = [
("Pride and Prejudice", "Jane Austen", 1813),
("Moby Dick", "Herman Melville", 1851),
("Frankenstein", "Mary Shelley", 1818),
("The Picture of Dorian Gray", "Oscar Wilde", 1890),
("Dracula", "Bram Stoker", 1897),
("The Adventures of Sherlock Holmes", "Arthur Conan Doyle", 1892),
("Alice's Adventures in Wonderland", "Lewis Carroll", 1865),
("The Time Machine", "H.G. Wells", 1895),
("The Scarlet Letter", "Nathaniel Hawthorne", 1850),
("Leaves of Grass", "Walt Whitman", 1855),
("The Brothers Karamazov", "Fyodor Dostoevsky", 1880),
("Crime and Punishment", "Fyodor Dostoevsky", 1866),
("Anna Karenina", "Leo Tolstoy", 1877),
("War and Peace", "Leo Tolstoy", 1869),
("Great Expectations", "Charles Dickens", 1861),
("Oliver Twist", "Charles Dickens", 1837),
("Wuthering Heights", "Emily Brontë", 1847),
("Jane Eyre", "Charlotte Brontë", 1847),
("The Call of the Wild", "Jack London", 1903),
("The Jungle Book", "Rudyard Kipling", 1894),
]

# 古典作品の一般的な章名
CHAPTERS = [
"Introduction", "Prologue", "Chapter I", "Chapter II", "Chapter III",
"Chapter IV", "Chapter V", "Chapter VI", "Chapter VII", "Chapter VIII",
"Chapter IX", "Chapter X", "Epilogue", "Conclusion", "Afterword",
"Economy", "Where I Lived", "Reading", "Sounds", "Solitude",
"Visitors", "The Bean-Field", "The Village", "The Ponds", "Baker Farm"
]

# プレースホルダーテキストスニペット(19世紀の散文を模倣)
TEXT_SNIPPETS = [
"When I wrote the following pages, or rather the bulk of them...",
"I would fain say something, not so much concerning the Chinese and...",
"It is a truth universally acknowledged, that a single man in possession...",
"Call me Ishmael. Some years ago—never mind how long precisely...",
"It was the best of times, it was the worst of times...",
"All happy families are alike; each unhappy family is unhappy in its own way.",
"Whether I shall turn out to be the hero of my own life, or whether that station...",
"You will rejoice to hear that no disaster has accompanied the commencement...",
"The world is too much with us; late and soon, getting and spending...",
"He was an old man who fished alone in a skiff in the Gulf Stream..."
]

def random_vector() -> List[float]:
return [round(random.random(), 1) for _ in range(5)]

def generate_chunk() -> Dict[str, Any]:
return {
"text": random.choice(TEXT_SNIPPETS),
"text_vector": random_vector(),
"chapter": random.choice(CHAPTERS)
}

def generate_record(record_id: int) -> Dict[str, Any]:
title, author, year = random.choice(BOOKS)
num_chunks = random.randint(1, 5) # 1つの本に1〜5のチャンク
chunks = [generate_chunk() for _ in range(num_chunks)]
return {
"title": title,
"title_vector": random_vector(),
"author": author,
"year_of_publication": year,
"chunks": chunks
}

# 1000件のレコードを生成
data = [generate_record(i) for i in range(1000)]

# 生成されたデータを挿入
client.insert(collection_name="my_collection", data=data)

構造体の配列フィールドに対するベクトル検索

コレクションのベクトルフィールドと構造体の配列内のベクトル検索を実行できます。

具体的には、検索要求のanns_fieldパラメータの値として、構造体の配列フィールドの名前と構造体要素内のターゲットベクトルフィールドの名前を連結し、EmbeddingListを使用してクエリベクトルを整理します。

📘ノート

Zilliz CloudはEmbeddingListを提供しており、構造体の配列内の埋め込みリストに対する検索のためのクエリベクトルをより整理して配置できます。EmbeddingListには少なくとも1つのベクトル埋め込みが含まれ、返されるtopKエンティティ数が期待されます。

ただし、EmbeddingListは範囲検索またはグループ化検索のパラメータなしのsearch()要求でのみ使用でき、search_iterator()要求では使用できません。

from pymilvus.client.embedding_list import EmbeddingList

# 各クエリ埋め込みリストは単一の検索をトリガー
embeddingList1 = EmbeddingList()
embeddingList1.add([0.2, 0.9, 0.4, -0.3, 0.2])

embeddingList2 = EmbeddingList()
embeddingList2.add([-0.2, -0.2, 0.5, 0.6, 0.9])
embeddingList2.add([-0.4, 0.3, 0.5, 0.8, 0.2])

# 単一の埋め込みリストを使用した検索
results = client.search(
collection_name="my_collection",
data=[ embeddingList1 ],
anns_field="chunks[text_vector]",
search_params={"metric_type": "MAX_SIM_COSINE"},
limit=10
)

# 複数の埋め込みリストを使用した検索
results = client.search(
collection_name="my_collection",
data=[ embeddingList1, embeddingList2 ],
anns_field="chunks[text_vector]",
search_params={"metric_type": "MAX_SIM_COSINE"},
limit=10
)

ベクトル検索を実行すると、結果として、入力した埋め込みリストの各要素と最も類似した構造体のベクトルが返されます。各埋め込みリストは、入力した埋め込みリストの数と同じ数の結果を返します。

たとえば、embeddingList1 には1つの埋め込みが含まれているため、結果には1つの構造体が返されます。一方、embeddingList2 には2つの埋め込みが含まれているため、結果には2つの構造体が返されます。

検索結果の解釈

検索結果を解釈する際には、埋め込みリストが構造体の配列内の個々の構造体に対応していることを考慮する必要があります。

def interpret_search_results(results):
for i, result in enumerate(results):
print(f"埋め込み {i+1} の結果:")
for entity in result:
print(f" ID: {entity['id']}")
print(f" 距離: {entity['distance']}")
print(f" 構造体: {entity['entity']}")
print()

# 埋め込みリスト1(1つの埋め込みのみ)
embeddingList1 = EmbeddingList()
embeddingList1.add([0.2, 0.9, 0.4, -0.3, 0.2])

results = client.search(
collection_name="my_collection",
data=[ embeddingList1 ],
anns_field="chunks[text_vector]",
search_params={"metric_type": "MAX_SIM_COSINE"},
limit=10
)

interpret_search_results(results)

# 埋め込みリスト2(2つの埋め込み)
embeddingList2 = EmbeddingList()
embeddingList2.add([-0.2, -0.2, 0.5, 0.6, 0.9])
embeddingList2.add([-0.4, 0.3, 0.5, 0.8, 0.2])

results = client.search(
collection_name="my_collection",
data=[ embeddingList2 ],
anns_field="chunks[text_vector]",
search_params={"metric_type": "MAX_SIM_COSINE"},
limit=10
)

interpret_search_results(results)

クエリ

構造体の配列フィールドを使用する際、構造体要素内のフィールドはスカラー検索で使用できません。構造体の配列内に含まれるデータを照会または検索するには、ベクトル検索を使用する必要があります。

# 構造体要素内のフィールドを使用したクエリは無効
# query = client.query(
# collection_name="my_collection",
# filter="chunks.text == 'When I wrote the following pages...",
# output_fields=["chunks"]
# )

# 代わりに、ベクトル検索を使用
from pymilvus.client.embedding_list import EmbeddingList

query_embedding = EmbeddingList()
query_embedding.add([0.3, 0.2, 0.3, 0.2, 0.5]) # 'text_vector'の値に対応

results = client.search(
collection_name="my_collection",
data=[query_embedding],
anns_field="chunks[text_vector]",
search_params={"metric_type": "MAX_SIM_COSINE"},
limit=10
)

for result in results:
for entity in result:
print(f"ID: {entity['id']}")
print(f"距離: {entity['distance']}")
print(f"構造体: {entity['entity']}")
print()

使用例

構造体の配列は、特にドキュメントのチャンク化、商品の特徴、ユーザーの嗜好など、エンティティ内に複数の関連する構造化データを格納する必要がある場合に便利です。

ドキュメントチャンク化

構造体の配列は、ドキュメントのチャンク化やRAG(Retrieval-Augmented Generation)アプリケーションに理想的です。各構造体には、ドキュメントの一部、その埋め込みベクトル、メタデータが含まれます。

from pymilvus import MilvusClient, DataType

# ドキュメントチャンク化のスキーマ
client = MilvusClient(
uri="YOUR_CLUSTER_ENDPOINT",
token="YOUR_CLUSTER_TOKEN"
)

schema = MilvusClient.create_schema()
schema.add_field(field_name="doc_id", datatype=DataType.INT64, is_primary=True, auto_id=True)
schema.add_field(field_name="doc_title", datatype=DataType.VARCHAR, max_length=512)
schema.add_field(field_name="doc_vector", datatype=DataType.FLOAT_VECTOR, dim=1536)

# チャンク構造体のスキーマ
chunk_schema = MilvusClient.create_struct_field_schema()
chunk_schema.add_field("text", DataType.VARCHAR, max_length=65535)
chunk_schema.add_field("chunk_vector", DataType.FLOAT_VECTOR, dim=1536, mmap_enabled=True)
chunk_schema.add_field("page_num", DataType.INT64)
chunk_schema.add_field("section", DataType.VARCHAR, max_length=512)

# チャンクフィールドを追加
schema.add_field("chunks", datatype=DataType.ARRAY, element_type=DataType.STRUCT,
struct_schema=chunk_schema, max_capacity=1000)

# インデックスを作成
index_params = MilvusClient.prepare_index_params()
index_params.add_index(
field_name="doc_vector",
index_type="AUTOINDEX",
metric_type="COSINE"
)
index_params.add_index(
field_name="chunks[chunk_vector]",
index_type="AUTOINDEX",
metric_type="MAX_SIM_COSINE"
)

# コレクションを作成
client.create_collection(
collection_name="document_chunks",
schema=schema,
index_params=index_params
)

# データを挿入
data = {
"doc_title": "Research Paper on Vector Databases",
"doc_vector": [0.1, 0.2, 0.3, ...],
"chunks": [
{
"text": "Vector databases are optimized for similarity search...",
"chunk_vector": [0.4, 0.5, 0.6, ...],
"page_num": 1,
"section": "Introduction"
},
{
"text": "Similarity search algorithms play a crucial role...",
"chunk_vector": [0.7, 0.8, 0.9, ...],
"page_num": 2,
"section": "Algorithms"
}
]
}

client.insert(collection_name="document_chunks", data=[data])

製品の特徴

構造体の配列は、製品の特徴を表すためにも使用できます。各構造体は、特定の製品バリアントの特徴を表します。

# 製品特徴スキーマ
schema = MilvusClient.create_schema()
schema.add_field(field_name="product_id", datatype=DataType.INT64, is_primary=True, auto_id=True)
schema.add_field(field_name="product_name", datatype=DataType.VARCHAR, max_length=512)
schema.add_field(field_name="category", datatype=DataType.VARCHAR, max_length=512)

# 特徴構造体のスキーマ
feature_schema = MilvusClient.create_struct_field_schema()
feature_schema.add_field("feature_name", DataType.VARCHAR, max_length=512)
feature_schema.add_field("feature_value", DataType.VARCHAR, max_length=512)
feature_schema.add_field("feature_vector", DataType.FLOAT_VECTOR, dim=768, mmap_enabled=True)

schema.add_field("features", datatype=DataType.ARRAY, element_type=DataType.STRUCT,
struct_schema=feature_schema, max_capacity=100)

# コレクションを作成
client.create_collection(
collection_name="product_features",
schema=schema,
index_params=index_params
)

構造体の配列フィールドに対するベクトル検索

コレクションのベクトルフィールドと構造体の配列内のベクトル検索を実行できます。

具体的には、検索要求のanns_fieldパラメータの値として、構造体の配列フィールドの名前と構造体要素内のターゲットベクトルフィールドの名前を連結し、EmbeddingListを使用してクエリベクトルを整理します。

📘ノート

Zilliz CloudはEmbeddingListを提供しており、構造体の配列内の埋め込みリストに対する検索のためのクエリベクトルをより整理して配置できます。EmbeddingListには少なくとも1つのベクトル埋め込みが含まれ、返されるtopKエンティティ数が期待されます。

ただし、EmbeddingListは範囲検索またはグループ化検索のパラメータなしのsearch()要求でのみ使用でき、search_iterator()要求では使用できません。

from pymilvus.client.embedding_list import EmbeddingList

# 各クエリ埋め込みリストは単一の検索をトリガー
embeddingList1 = EmbeddingList()
embeddingList1.add([0.2, 0.9, 0.4, -0.3, 0.2])

embeddingList2 = EmbeddingList()
embeddingList2.add([-0.2, -0.2, 0.5, 0.6, 0.9])
embeddingList2.add([-0.4, 0.3, 0.5, 0.8, 0.2])

# 単一の埋め込みリストを使用した検索
results = client.search(
collection_name="my_collection",
data=[ embeddingList1 ],
anns_field="chunks[text_vector]",
search_params={"metric_type": "MAX_SIM_COSINE"},
limit=3,
output_fields=["chunks[text]"]
)

上記の検索リクエストでは、chunks[text_vector]を使用して構造体要素内のtext_vectorフィールドを参照しています。この構文を使用してanns_fieldおよびoutput_fieldsパラメータを設定できます。

出力は最も類似した3つのエンティティのリストになります。

出力
# [
# [
# {
# 'id': 461417939772144945,
# 'distance': 0.9675756096839905,
# 'entity': {
# 'chunks': [
# {'text': 'The world is too much with us; late and soon, getting and spending...'},
# {'text': 'All happy families are alike; each unhappy family is unhappy in its own way.'}
# ]
# }
# },
# {
# 'id': 461417939772144965,
# 'distance': 0.9555778503417969,
# 'entity': {
# 'chunks': [
# {'text': 'Call me Ishmael. Some years ago—never mind how long precisely...'},
# {'text': 'He was an old man who fished alone in a skiff in the Gulf Stream...'},
# {'text': 'When I wrote the following pages, or rather the bulk of them...'},
# {'text': 'It was the best of times, it was the worst of times...'},
# {'text': 'The world is too much with us; late and soon, getting and spending...'}
# ]
# }
# },
# {
# 'id': 461417939772144962,
# 'distance': 0.9469035863876343,
# 'entity': {
# 'chunks': [
# {'text': 'Call me Ishmael. Some years ago—never mind how long precisely...'},
# {'text': 'The world is too much with us; late and soon, getting and spending...'},
# {'text': 'He was an old man who fished alone in a skiff in the Gulf Stream...'},
# {'text': 'Call me Ishmael. Some years ago—never mind how long precisely...'},
# {'text': 'The world is too much with us; late and soon, getting and spending...'}
# ]
# }
# }
# ]
# ]

dataパラメータに複数の埋め込みリストを含めることも可能で、これらの埋め込みリストそれぞれの検索結果を取得できます。

# 複数の埋め込みリストを使用した検索
results = client.search(
collection_name="my_collection",
data=[ embeddingList1, embeddingList2 ],
anns_field="chunks[text_vector]",
search_params={"metric_type": "MAX_SIM_COSINE"},
limit=3,
output_fields=["chunks[text]"]
)

print(results)

出力は各埋め込みリストに対して最も類似した3つのエンティティのリストになります。

出力
# [
# [
# {
# 'id': 461417939772144945,
# 'distance': 0.9675756096839905,
# 'entity': {
# 'chunks': [
# {'text': 'The world is too much with us; late and soon, getting and spending...'},
# {'text': 'All happy families are alike; each unhappy family is unhappy in its own way.'}
# ]
# }
# },
# {
# 'id': 461417939772144965,
# 'distance': 0.9555778503417969,
# 'entity': {
# 'chunks': [
# {'text': 'Call me Ishmael. Some years ago—never mind how long precisely...'},
# {'text': 'He was an old man who fished alone in a skiff in the Gulf Stream...'},
# {'text': 'When I wrote the following pages, or rather the bulk of them...'},
# {'text': 'It was the best of times, it was the worst of times...'},
# {'text': 'The world is too much with us; late and soon, getting and spending...'}
# ]
# }
# },
# {
# 'id': 461417939772144962,
# 'distance': 0.9469035863876343,
# 'entity': {
# 'chunks': [
# {'text': 'Call me Ishmael. Some years ago—never mind how long precisely...'},
# {'text': 'The world is too much with us; late and soon, getting and spending...'},
# {'text': 'He was an old man who fished alone in a skiff in the Gulf Stream...'},
# {'text': 'Call me Ishmael. Some years ago—never mind how long precisely...'},
# {'text': 'The world is too much with us; late and soon, getting and spending...'}
# ]
# }
# }
# ],
# [
# {
# 'id': 461417939772144663,
# 'distance': 1.9761409759521484,
# 'entity': {
# 'chunks': [
# {'text': 'It was the best of times, it was the worst of times...'},
# {'text': 'It is a truth universally acknowledged, that a single man in possession...'},
# {'text': 'Whether I shall turn out to be the hero of my own life, or whether that station...'},
# {'text': 'He was an old man who fished alone in a skiff in the Gulf Stream...'}
# ]
# }
# },
# {
# 'id': 461417939772144692,
# 'distance': 1.974656581878662,
# 'entity': {
# 'chunks': [
# {'text': 'It is a truth universally acknowledged, that a single man in possession...'},
# {'text': 'Call me Ishmael. Some years ago—never mind how long precisely...'}
# ]
# }
# },
# {
# 'id': 461417939772144662,
# 'distance': 1.9406685829162598,
# 'entity': {
# 'chunks': [
# {'text': 'It is a truth universally acknowledged, that a single man in possession...'}
# ]
# }
# }
# ]
# ]

上記のコード例では、embeddingList1は1つのベクトルを持つ埋め込みリストであり、embeddingList2は2つのベクトルを含んでいます。それぞれが個別の検索リクエストをトリガーし、top-Kに類似したエンティティのリストを期待します。

次のステップ

ネイティブな構造体の配列データ型の開発は、Zilliz Cloudが複雑なデータ構造を処理する能力における大きな進歩を表しています。その使用例をよりよく理解し、この新機能を最大限に活用するために、構造体の配列を使用したスキーマ設計を読むことをお勧めします。