search

Function

Retrieves vectors in a database that are similar to the passed vectors.

Prototype

def search(embeddings, k, filter_dict)

Parameters

Parameter

Data Type

Required/Optional

Description

embeddings

Union[List[List[float]], List[Dict[int, float]]]

Required

Dense or sparse vector. For a dense vector, the data type is List[List[float]]; for a sparse vector, the data type is List[Dict[int, float]].

k

Integer

Optional

Number of returned similar vectors. The value is greater than 0. The default value is 3. The value range is (0, 10000].

filter_dict

Dict

Optional

Dictionary consisting of retrieval criteria. Currently, only document IDs can be filtered. The filtered document IDs are passed in a list. The length of the ID list cannot exceed 1000 × 1000. For example, if you need to filter the documents whose IDs are 1, 2, and 4, the input dictionary is {"document_id": [1, 2, 4]}.

Return Value

Data Type

Description

Tuple[List[List[float]], List[List[int]]]

Two pieces of data are returned. The first piece of data indicates the score list of the similar vectors, and the second one indicates the ID list of the similar vectors.