milvus-logo

search()

This method conducts a vector similarity search.

Invocation

new milvusClient(MILUVS_ADDRESS).dataManager.search(SearchReq);

Parameters

SearchReq(object)

ParameterDescriptionTypeRequired
collection_nameName of the collection to search onStringTrue
search_paramsSearch parametersSearchParams (see the table below)True
vectorsOriginal vector to search withNumber[][]True
vector_typeSearch parametersVectorTypes (see the table below)True
output_fields(optional)Vector or scalar field to be returnedString[]False
travel_timestamp(optional)Timestamp that is used for Time Travel. Users can specify a timestamp in a search to get results based on a data view at a specified point in time.NumberFalse
partitions_names(optional)An array of the names of the partitions to search onString[]False
expr(optional)Boolean expression to filter the dataStringFalse

SearchParams(object)

ParameterDescriptionTypeRequired
anns_fieldVector field nameStringTrue
topkSearch result countsStringFalse
metric_typeMetric typeMetricTypesFalse
paramsSpecial parametersSearchParamTrue
round_decimalSpecial parametersNumberFalse

MetricTypes(string)

ValueDescription
L2Euclidean distance
IPInner product
HAMMINGHamming distance
JACCARDJaccard distance
TANIMOTOTanimoto distance
SUBSTRUCTURESuperstructure
SUPERSTRUCTURESubstructure

VectorTypes

ValueDescription
100Binary
101Float

SearchParam

Please refer https://milvus.io/docs/index.md

Example

new milvusClient(MILUVS_ADDRESS).dataManager.search({
  collection_name: 'my_collection',
  expr: "",
  vectors: [[1, 2, 3, 4]],
  search_params: {
    anns_field: 'vector_01',
    topk: 4,
    metric_type: "L2",
    params: JSON.stringify({ nprobe: 1024 }),
  },
  output_fields: ["age"],
  vector_type: 100,
});

Return

// search return
{
  status: { error_code: 'Success', reason: '' },
  results: [
    { score: 22, age: '434848878802251176' },
    { score: 22, age: '434848878802251181' },
    { score: 23, age: '434848878802251173' },
    { score: 25, age: '434848878802251179' }
  ]
}