メインコンテンツまでスキップ
バージョン: V1.0.0

get - 検索

get()は、ベクトル類似性検索を行わずに、collectionからdocumentsを検索するために使用されます。

ID、metadata、およびdocumentによるフィルタリングをサポートしています。

備考

このインターフェースは、Client接続を使用する場合にのみ利用できます。Clientの詳細については、Clientを参照してください。

前提条件​

  • pyseekdbがインストール済みであること。pyseekdbのインストール方法の詳細については、クイックスタートを参照してください。

  • データベースに接続されていること。接続操作の詳細については、Clientを参照してください。

  • collectionを作成し、対応するデータを挿入済みであること。collectionの作成とデータの挿入操作の詳細については、create_collection - Collectionの作成および add - データの挿入を参照してください。

リクエストパラメータ​

get()
パラメータ値の種類必須説明値の例
idsList[float] or List[List[float]]必須検索する単一IDまたはIDリスト[1.0, 2.0, 3.0]
wheredictオプションMetadataフィルター条件。{"category": {"$eq": "AI"}}
where_documentdictオプションDocumentフィルター条件。{"$contains": "machine"}
limitdictオプション返す結果の最大数。{"category": {"$eq": "AI"}}
offsetdictオプションページネーション時にスキップする結果数。{"$contains": "machine"}
includeList[str]オプション含めるフィールドのリスト:["documents", "metadatas", "embeddings"]。["documents", "metadatas", "embeddings"]
備考

パラメータが指定されていない場合、すべてのデータを返します。

リクエスト例​

import pyseekdb

# Create a client
client = pyseekdb.Client()

collection = client.get_collection("my_collection")

# Get by single ID
results = collection.get(ids="123")

# Get by multiple IDs
results = collection.get(ids=["1", "2", "3"])

# Get by metadata filter
results = collection.get(
where={"category": {"$eq": "AI"}},
limit=10
)

# Get by comparison operator
results = collection.get(
where={"score": {"$gte": 90}},
limit=10
)

# Get by $in operator
results = collection.get(
where={"tag": {"$in": ["ml", "python"]}},
limit=10
)

# Get by logical operators ($or)
results = collection.get(
where={
"$or": [
{"category": {"$eq": "AI"}},
{"tag": {"$eq": "python"}}
]
},
limit=10
)

# Get by document content filter
results = collection.get(
where_document={"$contains": "machine learning"},
limit=10
)

# Get with combined filters
results = collection.get(
where={"category": {"$eq": "AI"}},
where_document={"$contains": "machine"},
limit=10
)

# Get with pagination
results = collection.get(limit=2, offset=1)

# Get with specific fields
results = collection.get(
ids=["1", "2"],
include=["documents", "metadatas", "embeddings"]
)

# Get all data (up to limit)
results = collection.get(limit=100)

レスポンスパラメータ​

  • 単一のIDを指定した場合:そのIDを含むgetオブジェクトを返します。
  • 複数のIDを指定した場合:QueryResultオブジェクトをリストで返します。1つのIDに対応して1つのオブジェクトが返されます。
  • フィルターを指定した場合:一致するすべての結果を含むQueryResultオブジェクトを返します。

関連操作​