Indexing the embeddings
Now that we can generate a vector for the desired type of data using the corresponding ML model, we would like to index vectors for VSS. Here, we’ll introduce the VECTOR field type which, together with TEXT, TAG, NUMERIC, and GEO, complete the types of data that can be indexed by Redis Stack. Using redis-cli to create an index as usual, we can index the embedding as follows:
FT.CREATE doc_idx ON HASH PREFIX 1 doc: SCHEMA content AS content TEXT genre AS genre TAG embedding VECTOR HNSW 6 TYPE FLOAT32 DIM 384 DISTANCE_METRIC COSINE
We can index the JSON document in a similar fashion:
FT.CREATE doc_idx ON JSON PREFIX 1 doc: SCHEMA $.content as content TEXT $.genre AS genre TAG $.embedding VECTOR HNSW 6 TYPE FLOAT32 DIM 384 DISTANCE_METRIC COSINE
This index includes the content of the document and the embedding and uses the related types: TEXT and VECTOR. In the next subsections, we will explain the meaning of the arguments for the vector similarity...