search_with_filter

API definition

void search_with_filter(idx_t n, const float *x, idx_t k, float *distances, idx_t *labels, const void *filters) const;

Function

Queries the AscendIndexSQ feature vectors and returns IDs of the most similar k features based on the input feature vectors. It also provides the CID-based filtering function. filters is a uint32_t array with the length of n × 6. Every six uint32_t values form a filter. The first four digits (128 bits) of each filter indicate the corresponding CID, and the last two digits indicate the left-closed range of the corresponding timestamp, that is, [x, y).

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 void *filters: filter criteria.

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

  • Range of n: 0 < n < 1e9.
  • The value of k cannot be greater than 4096.
  • x must be a non-null pointer with a length of dims × n. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • distances and labels must be non-null pointers with a length of k × n. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • filters must be a non-null pointer and a uint32_t array whose length is n × 6. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.