Rate This Document
Findability
Accuracy
Completeness
Readability

Search

API Definition

int Search(int nq, const float *xq, int topk, float *distances, int64_t *labels, int num_thread);

Function

Searches for a graph.

Parameters

Parameter

Data Type

Description

Value Range

nq

int

Data volume of the query vector set.

≥ 1. It is recommended that the value be less than 1 billion.

xq

const float *

Query vector set data.

The value cannot be null. The expected length is nq × dim (data volume × feature dimension).

topk

int

Number of nearest neighbors.

[1, nb], where nb indicates the data volume of the vector base library.

distances

float *

Distance array.

The value cannot be null. The expected length is nq × topk.

labels

int64_t *

ID array of the search result.

The value cannot be null. The expected length is nq × topk.

num_thread

int

Number of threads used for search.

[1, std::thread::hardware_concurrency()], where std::thread::hardware_concurrency() indicates the number of concurrent threads supported by the current system.

Return Value

Data Type

Description

int

If the parameter value exceeds the value range, -1 is returned. If this API is called before BuildSearcher or Load/Deserialize/LoadGraph is called, -1 is returned. In other cases, 0 is returned.