accesspatterns.dev

A vector is just an attribute

A vector is a list of numbers on an item. An index is what makes it searchable.

Why

There is no vector attribute type. A vector is an L of N, a list of numbers, sitting on the item beside everything else. What makes it searchable is a vector index, and that is declared at the top level of CreateTable under VectorIndexes rather than as a variant of a GSI, because it is not one: it has no key schema, and you search it by distance rather than querying it by key.

The index pins two things at creation that you cannot change afterwards: how many dimensions each vector has, and which distance function compares them. Everything else about the vector is unchecked. Write three numbers into a three-dimensional index and it is happy; write three different numbers that mean something else entirely and it is just as happy.

One rule here runs backwards from everything the course has taught so far. Every key attribute has to be declared in AttributeDefinitions. The vector attribute must not be, and a CreateTable that declares it is rejected.

The base table keeps exactly what you wrote. The index holds 32-bit copies, so a value written at full double precision reads back through the index very slightly rounded. At three dimensions that is invisible, and at 384 it is still far below anything that changes a ranking.

A vector is an ordinary list-of-numbers attribute; the index is what makes it searchable, and it fixes the dimensions and the distance function for good.

PaintChart

These rows are real and already here. Running an operation against them downloads a DynamoDB-compatible engine, about 850 KB, and executes it in this tab.

Try an example

Crimson's rgb sits alongside name and family as an ordinary attribute. It is a list of three numbers, an L of N. There is no vector type in DynamoDB.

pk(pk)
name
family
rgb
COLOUR#crimson
CrimsonS
redS
[220, 20, 60]L
COLOUR#brick
BrickS
redS
[140, 30, 30]L
COLOUR#rose
RoseS
redS
[250, 120, 130]L
COLOUR#navy
NavyS
blueS
[20, 30, 110]L
COLOUR#azure
AzureS
blueS
[40, 110, 230]L
COLOUR#sky
SkyS
blueS
[140, 200, 245]L
COLOUR#forest
ForestS
greenS
[20, 90, 40]L
COLOUR#lime
LimeS
greenS
[110, 220, 60]L
COLOUR#mint
MintS
greenS
[170, 230, 190]L
COLOUR#amber
AmberS
yellowS
[250, 190, 40]L
COLOUR#rust
RustS
yellowS
[180, 90, 20]L
COLOUR#slate
SlateS
neutralS
[90, 100, 110]L
COLOUR#charcoal
CharcoalS
neutralS
[40, 42, 45]L

Run an operation to see the raw engine response.

table PaintChartkeys pkitems 13