Search

API definition

APP_ERROR Search(const AscendIndexSearchParams& searchParams);

Function

Queries the feature vectors for AscendIndexGreat and returns the distance and IDs of the most similar topK features based on the input feature vectors.

Input

For details about the searchParams structure, see AscendIndexSearchParams.

size_t n: number of feature vectors to be queried.

std::vector<float>& queryData: feature vector data.

int topK: number of the most similar results to be returned.

Output

std::vector<float>& dists: distance between a vector and the topK nearest vectors.

std::vector<int64_t>& labels: IDs of the topK nearest vectors that are queried. If the number of valid retrieval results is less than topK, the remaining invalid labels are padded with -1.

Return value

APP_ERROR: return status. For details, see Return Code Reference.

Restrictions

  • topK ∈ (0, 4096]
  • n ∈ (0, 10000]
  • queryData cannot be empty, and the data length must be greater than or equal to n × dim.
  • dists cannot be empty, and the data length must be greater than or equal to n × topK.
  • labels cannot be empty, and the data length must be greater than or equal to n × topK.