search
API Definition |
void search(Index::idx_t n, const float *x, Index::idx_t k, float *distances, Index::idx_t *labels) const override; |
|---|---|
Function |
Queries the feature vectors for AscendIndex and returns IDs of the most similar k features based on the input feature vectors. |
Input |
idx_t n: number of feature vectors to be queried. const float *x: feature vector data. idx_t k: number of the most similar results to be returned. |
Output |
float *distances: distance between a vector and the first k nearest vectors. When the number of valid retrieval results is less than k, the remaining invalid distance is filled with 65504 or -65504 (depending on the metric). idx_t *labels: IDs of the first k nearest vectors that are queried. If the number of valid retrieval results is less than k, the remaining invalid labels are filled with -1. |
Return Value |
N/A |
Restrictions |
The length of the queried feature vector data x must be dim x n, and the lengths of distances and labels must be k x n. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown. The value of n cannot be greater than 1e9. The value of k cannot be greater than 1024. |
Important Notes |
If brute-force search algorithms are used in a small library, the performance may deteriorate when the base library capacity and the number of batches are large. In this case, increase the value of resources (defaults to 128 MB for brute-force search algorithms) in AscendIndexConfig. |