search
API definition |
void search(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels, const SearchParameters *params = nullptr) const override; |
|---|---|
Function |
Queries the feature vectors for AscendIndexIVFSP 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. const SearchParameters *params (not supported now): optional parameter in Faiss. The default value is nullptr. |
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 padded with 65504 or -65504. 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 padded with -1. |
Return value |
N/A |
Restrictions |
The length of the queried feature vector data x must be dims × n, and the lengths of distances and labels must be k × n. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown. The value range of n is 0 < n < 1e9, and the value of k cannot exceed 4096. |