SearchWithExtraVal

API definition

APP_ERROR SearchWithExtraVal(uint32_t count, const void *features, const AttrFilter *attrFilter, bool shareAttrFilter, uint32_t topk, int64_t *labels, float *distances, uint32_t *validNums, const ExtraValFilter *extraValFilter, bool enableTimeFilter = true);

Function

Calculates the distance between the input feature and the base vector filtered by AttrFilter and ExtraValFilter, sorts the distance by TopK, and returns the corresponding distance and index.

Input

uint32_t count: number of features to be compared.

const void *features: feature to be compared. The Hamming distance requires data of the uint8_t type, and Int8cos requires data of the int8_t type. Currently, only Int8cos and Hamming distance are supported.

const AttrFilter *attrFilter: attribute filtering information. For details, see SearchWithExtraMask.

bool shareAttrFilter: extra attribute. Currently, only false is supported. Different queries do not share the same mask.

uint32_t topk: size of the TopK feature to be saved after the cosine distance is calculated.

const ExtraValFilter *extraValFilter: extra attribute filtering information. For details, see tokenBitSetLen.

bool enableTimeFilter: whether to filter the timestamp attribute. The default value is true. If enableTimeFilter is set to false, the timestamp attribute is not filtered.

Output

uint32_t *validNums: number of valid results obtained after each query vector is compared.

int64_t *labels: label of the TopK feature.

float *distances: distance of the TopK feature.

Return value

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

Restrictions

  • Value range of count: [1, 10240]
  • The length of features must be count × dim (vector dimension). Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • attrFilter: When shareAttrFilter is true, the length is 1. When shareAttrFilter is false, the length is count. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • Value range of topk: [1, 100000]
  • The length of labels must be count × topk. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • The length of distances must be count × topk. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • The length of validNums must be count. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.
  • The value of extraValFilter must be a null pointer or the length must be count. Otherwise, an out-of-bounds read/write error may occur, causing program breakdown.

SearchWithExtraVal cannot be used together with Search.