getCollection - Get a collection
The getCollection() method is used to retrieve a specified collection.
info
This API can only be used when connected with SeekdbClient. For more information about SeekdbClient, see SeekdbClient.
Prerequisites
-
You have installed seekdb-js. For more information, see Quick start.
-
You have installed the server mode of seekdb. For more information, see Deploy seekdb by using yum install.
-
You are connected to the database. For more information, see SeekdbClient.
-
The collection you are trying to retrieve exists. If the collection does not exist, an error will be returned.
Request parameters
getCollection(options: GetCollectionOptions)
| Parameter | Type | Required | Description | Example value |
|---|---|---|---|---|
name | string | Yes | The name of the collection to retrieve. | my_collection |
embeddingFunction | EmbeddingFunction | null | No | The embedding function. Pass null to indicate that no embedding function is used. | DefaultEmbeddingFunction() |
info
embeddingFunction (EmbeddingFunction, optional): The vector function for this collection.
- If not provided, the
embeddingFunctionused increateCollectionwill be used by default. - If set to null, the collection will not use a vector function.
- When documents/text are provided but no vector is provided, the vector function set here will be used for all operations (add, upsert, update, query, hybridSearch) on this collection.
Request example
import { SeekdbClient } from "seekdb";
// 1. Connect
const client = new SeekdbClient({
host: "127.0.0.1",
port: 2881,
user: "root",
password: "",
database: "test",
});
// Use the default embedding function to retrieve the collection
const collection = await client.getCollection({
name: 'my_collection'
});
// Do not use an embedding function
const collection2 = await client.getCollection({
name: 'my_collection',
embeddingFunction: null
});
Response parameters
| Parameter | Type | Required | Description | Example value |
|---|---|---|---|---|
name | string | Yes | The name of the queried collection. | my_collection |
dimension | int | No | 384 | |
embeddingFunction | EmbeddingFunction | No | DefaultEmbeddingFunction { name: 'default-embed', pipe: null, modelName: 'Xenova/all-MiniLM-L6-v2', revision: undefined, dtype: undefined, cacheDir: undefined, localFilesOnly: undefined, progressCallback: undefined } | |
distance | string | No | cosine | |
metadata | dict | No | Reserved field, no data available | undefined |
Response example
Collection {
name: 'my_collection',
dimension: 384,
distance: 'cosine',
embeddingFunction: DefaultEmbeddingFunction {
name: 'default-embed',
pipe: null,
modelName: 'Xenova/all-MiniLM-L6-v2',
revision: undefined,
dtype: undefined,
cacheDir: undefined,
localFilesOnly: undefined,
progressCallback: undefined
},
metadata: undefined
}
Collection {
name: 'my_collection',
dimension: 384,
distance: 'cosine',
embeddingFunction: undefined,
metadata: undefined
}