Rate This Document
Findability
Accuracy
Completeness
Readability

Search

API Definition

int Search(int n, const float* x, int k, float* distances, int64_t* labels, int num_thread);

Function

Search for a graph.

Parameters

Parameter

Description

Data Type

Value Range

n

Data volume.

int

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

x

Data.

const float*

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

k

Number of nearest neighbors.

int

[1, n], where n indicates the data volume.

distances

Distance array.

float *

The value cannot be null. The expected length is n × K_features.

labels

ID array of the search result.

int64_t*

The value cannot be null. The expected length is n × K_features.

num_thread

Number of threads used for search.

int

[1, std::thread::hardware_concurrency()]

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. Otherwise, 0 is returned.