Orama Vector Search Implementation Steps
Implementing a vector search involves the following key steps (using a 1536-dimensional vector as an example):
- Index Creation::
const vectorIndex = create({
schema: {
name: 'string',
embedding: 'vector[1536]' // 明确定义向量维度
}
}); - Data insertion::
insert(vectorIndex, {
name: '音频特征向量',
embedding: [0.12, 0.34, ..., 0.98] // 实际1536维数组
}); - Perform a search::
const results = search(vectorIndex, {
mode: 'vector', // 必须显式指定搜索模式
similarity: 0.8 // 可选相似度阈值
});
Note: Vector dimensions must be explicitly defined in the schema, and the actual insertion of data should ensure that the dimensions are consistent. Hybrid search can use `hybrid` mode, through the `weights` parameter to adjust the proportion of weights between text and vector search.
This answer comes from the articleOrama: a high-performance full-text book and vector search engineThe































