3.4 KiB
3.4 KiB
slug
| slug |
|---|
| /get-interfaces-of-api |
get - Retrieve
get() is used to retrieve documents from a collection without performing vector similarity search.
It supports filtering by IDs, metadata, and documents.
:::info
This interface is only available when using the Client. For more information about the Client, see Client.
:::
Prerequisites
-
You have installed pyseekdb. For more information about how to install pyseekdb, see Get Started.
-
You have connected to the database. For more information about how to connect to the database, see Client.
-
You have created a collection and inserted data. For more information about how to create a collection and insert data, see create_collection - Create a collection and add - Insert data.
Request parameters
get()
| Parameter | Type | Required | Description | Example value |
|---|---|---|---|---|
ids |
List[float] or List[List[float]] | Yes | The ID or list of IDs to retrieve. | [1.0, 2.0, 3.0] |
where |
dict | No | The metadata filter. | {"category": {"$eq": "AI"}} |
where_document |
dict | No | The document filter. | {"$contains": "machine"} |
limit |
dict | No | The maximum number of results to return. | {"category": {"$eq": "AI"}} |
offset |
dict | No | The number of results to skip for pagination. | {"$contains": "machine"} |
include |
List[str] | No | The list of fields to include: ["documents", "metadatas", "embeddings"]. |
["documents", "metadatas", "embeddings"] |
:::info
If no parameters are provided, all data is returned.
:::
Request example
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)
Response parameters
- If a single ID is provided: The result contains the get object for that ID.
- If multiple IDs are provided: A list of QueryResult objects, one for each ID.
- If filters are provided: A QueryResult object containing all matching results.