Skip to content

Vector Indexes

A vector index is a collection of chunks with embeddings that allow for efficient nearest-neighbor search.

Create a Vector Index:

When creating a vector index you must specify the embedding model that will be used to produce the vectors. This ensures i) that only vectors of the correct dimensions are stored in the vector index, ii) the correct model is used for retrieval when querying the index.

const vectorIndexCreateArgs: OneContext.VectorIndexCreateType = OneContext.VectorIndexCreateSchema.parse({
  API_KEY: API_KEY,
  vectorIndexName: vectorIndexName,
  modelName: "BAAI/bge-base-en-v1.5"
})

OneContext.createVectorIndex(vectorIndexCreateArgs).then((res) => {console.log(res)})

List all Vector Indexes:

A list of all vector indexes can be displayed as follows

const VectorIndexListArgs: OneContext.ListVectorIndicesType = OneContext.ListVectorIndicesSchema.parse({
  API_KEY: API_KEY
})
OneContext.listVectorIndices(VectorIndexListArgs).then((res) => {console.log(res)})

Delete a Vector Index:

const vectorIndexDeleteArgs: OneContext.VectorIndexDeleteType = OneContext.VectorIndexDeleteSchema.parse({
API_KEY: API_KEY,
vectorIndexName: vectorIndexName
})

OneContext.deleteVectorIndex(vectorIndexDeleteArgs).then((res) => {console.log(res)})