1. Prepare the embeddings
Store the embeddings in anARRAY<FLOAT> NOT NULL column. Make sure the stored and query vectors have the same dimension, and check the vector index requirements for this version.
2. Create the vector index
Choose a metric such as L2 distance or cosine similarity and set the index dimension to match your embeddings. Use the index creation examples for a new table or the ADD INDEX example for an existing table. After creating the index, use SHOW CREATE TABLE to confirm its definition.3. Run a top-k query
Put the function for your index metric inORDER BY, then use LIMIT to set how many matches to return. Sort approx_l2_distance in ascending order or approx_cosine_similarity in descending order. Check the requirements for indexed queries for restrictions on expressions and predicates.
4. Verify index usage
Run EXPLAIN on the query and look forVECTORINDEX: ON in the scan node. Use the vector index examples to test recall or tune search parameters on representative queries.