Interface TableVectorColumnDefinition

Overview

Represents the syntax for defining a vector column in a table, which has no shorthand/"loose" equivalent.

Of the example format:

columns: {
vectorCol: { type: 'vector', dimension: 3 },
}

This may then be used through astra-db-ts as a DataAPIVector:

import { vector } from '@datastax/astra-db-ts';

await table.insertOne({
vectorCol: vector([1, 2, 3]),
});

// Or, if vectorize (auto-embedding-generation) is enabled:
await table.insertOne({
vectorCol: 'Alice went to the beach',
});

Keep in mind though, that a vector index must still be created on this column (through Table.createVectorIndex or CQL directly) to enable vector search on this column.

The dimension

The dimension must be a positive integer, and represents the number of elements in the vector.

Note that, at the time of writing, the dimension must still be specified, even if a service block is present.

The service block

You may specify the service block to enable vectorize (auto-embedding-generation) for the column.

If this is configured, then you can pass a string to the vector column instead of a vector directly, and have the Data API automatically embed it for you, using the model of your choice.

If the service field is present, then InferTableSchema will also type the column as string | DataAPIVector | null instead of just DataAPIVector | null.

See

  • Table.createVectorIndex
  • DataAPIVector
interface TableVectorColumnDefinition {
    dimension: number;
    service?: VectorizeServiceOptions;
    type: "vector";
}

Properties

dimension: number
type: "vector"