首页 DashVector Product Overview Terms Advanced parameters for vector search

Advanced parameters for vector search

更新时间: 2026-01-18 19:35:40

This topic describes how to set advanced parameters for vector search.

You can use VectorQuery to set advanced search parameters.

Set the number of candidates for each vector in a multi-vector search

title_vector = [0.1, 0.2, 0.3, 0.4]
content_vector = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6]
vectors = {
    "title": VectorQuery(vector=title_vector, num_candidates=10),
    "content": VectorQuery(vector=content_vector),
}
ret = collection.query(
    vector=vectors,
    topk=20,
)

In the code above, the title vector is set to retrieve 10 results. For the content vector, the num_candidates parameter is not set, so the number of results is determined by the topk parameter, which is 20.

Enable linear (brute-force) search

print(collection.query(vector=VectorQuery(np.random.rand(768), is_linear=True)))
Important
  1. Do not enable linear search in a production environment because it significantly degrades search performance.

  2. Enabling linear search does not guarantee a 100% recall rate.

    1. For collections with quantization enabled, calculations are performed on quantized data, which may result in a recall rate of less than 100%.

    2. For collections without quantization enabled, the recall rate is 100%.

Adjust the ef parameter for HNSW search

print(collection.query(vector=VectorQuery(np.random.rand(768), ef=100)))

In a Hierarchical Navigable Small World (HNSW) index, the ef parameter specifies the number of candidates to explore during a search. For more information, see the referenced document. By adjusting the ef value, you can find a balance between search performance and recall. A larger ef value increases recall but may decrease search performance. A smaller ef value improves search performance but may decrease recall.

The ef parameter accepts a value from 0 to 4,294,967,295. If you set the value to 0, the default ef value is used.

Note
  1. Beyond a certain point, increasing the ef value may no longer improve performance or recall.

  2. Do not use an excessively large ef value in a production environment because it can negatively impact search efficiency.

RNN search

A Radius Nearest Neighbor (RNN) search adds a condition to a standard vector search. This search returns only documents where the distance to the query vector does not exceed the specified radius threshold.

print(collection.query(vector=VectorQuery(np.random.rand(768), radius=1.0)))

The interpretation of the radius parameter differs based on the distance metric:

  1. For Euclidean and cosine distances, documents are returned if score <= radius.

  2. For inner product distance, documents are returned if score >= radius.

Note

The number of results returned by an RNN search is also limited by the topk parameter.

上一篇: Multi-vector retrieval 下一篇: Product specifications