Skip to main content
Version: V1.1.0

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)
ParameterTypeRequiredDescriptionExample value
namestringYesThe name of the collection to retrieve.my_collection
embeddingFunctionEmbeddingFunction | nullNoThe 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 embeddingFunction used in createCollection will 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

ParameterTypeRequiredDescriptionExample value
namestringYesThe name of the queried collection.my_collection
dimensionintNo384
embeddingFunctionEmbeddingFunctionNoDefaultEmbeddingFunction { name: 'default-embed', pipe: null, modelName: 'Xenova/all-MiniLM-L6-v2', revision: undefined, dtype: undefined, cacheDir: undefined, localFilesOnly: undefined, progressCallback: undefined }
distancestringNocosine
metadatadictNoReserved field, no data availableundefined

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
}