Search

Searches for multiple indexes. Currently, only AscendIndexSQ is supported.

API Definition

void Search(std::vector<Index *> indexes, Index::idx_t n, const float *x, Index::idx_t k,float *distances, Index::idx_t *labels, bool merged)

Function

Uses multiple indexes to perform retrieval.

Input

std::vector<Index *> indexes: multiple indexes to perform retrieval.

Index::idx_t n: number of queries for retrieval.

const float *x: feature vectors of queries for retrieval.

Index::idx_t k: number of the most similar results to be returned.

bool merged: whether to merge the retrieval results of multiple indexes.

Output

float *distances: distance between a vector and the first k nearest vectors.

idx_t *labels: IDs of the first k nearest vectors that are queried.

Return Value

N/A

Restrictions

  • Currently, indexes supports only AscendIndexSQ and the pointer whose slim is set to true. In addition, indexes.size() must be greater than 0.
  • The value of n cannot be greater than 1e9.
  • The value of k cannot be greater than 1024.
  • The x must be a non-null pointer with a length of dim x n. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • The distances and labels must be non-null pointers.
  • If merged is set to true, the length must be k x n. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • If merged is set to false, the length must be indexes.size() x k x n. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.