search

Function

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

Prototype

def search(embeddings, k, filter_dict,  **kwargs)

Parameters

Parameter

Data Type

Required/Optional

Description

embeddings

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

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].

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]}. The default value of filter_dict is None.

kwargs

Dict

Optional

Keyword parameter, which can be used to specify the keyword parameter of the MilvusClient search method. output_fields can be used to specify the returned fields.

Return Value

Data Type

Description

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

Three pieces of data are returned. The first piece of data indicates the score list of the similar vectors, the second one indicates the ID list of the similar vectors, and the third one indicates the field value specified by output_fields under kwargs.