MCPcopy Create free account
hub / github.com/alibaba/zvec / bind_query_params

Method bind_query_params

src/binding/python/model/param/python_param.cc:1181–1686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1179}
1180
1181void ZVecPyParams::bind_query_params(py::module_ &m) {
1182 // binding base query params
1183 py::class_<QueryParams, std::shared_ptr<QueryParams>> query_params(
1184 m, "QueryParam", R"pbdoc(
1185Base class for all query parameter configurations.
1186
1187This abstract base class defines common query settings such as search radius
1188and whether to force linear (brute-force) search. It should not be instantiated
1189directly; use derived classes like `HnswQueryParam` or `IVFQueryParam`.
1190
1191Attributes:
1192 type (IndexType): The index type this query is configured for.
1193 radius (float): Search radius for range queries. Used in combination with
1194 top-k to filter results. Default is 0.0 (disabled).
1195 is_linear (bool): If True, forces brute-force linear search instead of
1196 using the index. Useful for debugging or small datasets. Default is False.
1197 is_using_refiner (bool, optional): Whether to use refiner for the query. Default is False.
1198)pbdoc");
1199 query_params
1200 .def_property_readonly(
1201 "type",
1202 [](const QueryParams &self) -> IndexType { return self.type(); },
1203 "IndexType: The type of index this query targets.")
1204 .def_property_readonly(
1205 "radius",
1206 [](const QueryParams &self) -> float { return self.radius(); },
1207 "IndexType: The type of index this query targets.")
1208 .def_property_readonly(
1209 "is_linear",
1210 [](const QueryParams &self) -> bool { return self.is_linear(); },
1211 "bool: Whether to bypass the index and use brute-force linear "
1212 "search.")
1213 .def_property_readonly(
1214 "is_using_refiner",
1215 [](const QueryParams &self) -> bool {
1216 return self.is_using_refiner();
1217 },
1218 "bool: Whether to use refiner for the query.")
1219 .def(py::pickle(
1220 [](const QueryParams &self) { // __getstate__
1221 return py::make_tuple(self.type(), self.radius(), self.is_linear());
1222 },
1223 [](py::tuple t) { // __setstate__
1224 if (t.size() != 3)
1225 throw std::runtime_error("Invalid state for QueryParams");
1226 return std::shared_ptr<QueryParams>();
1227 }));
1228
1229 // binding hnsw query params
1230 py::class_<HnswQueryParams, QueryParams, std::shared_ptr<HnswQueryParams>>
1231 hnsw_params(m, "HnswQueryParam", R"pbdoc(
1232Query parameters for HNSW (Hierarchical Navigable Small World) index.
1233
1234Controls the trade-off between search speed and accuracy via the `ef` parameter.
1235
1236Attributes:
1237 type (IndexType): Always ``IndexType.HNSW``.
1238 ef (int): Size of the dynamic candidate list during search.

Callers

nothing calls this directly

Calls 15

initFunction · 0.85
index_type_to_stringFunction · 0.85
radiusMethod · 0.80
is_linearMethod · 0.80
is_using_refinerMethod · 0.80
set_radiusMethod · 0.80
set_is_linearMethod · 0.80
set_is_using_refinerMethod · 0.80
nprobeMethod · 0.80
ef_searchMethod · 0.80
set_default_operatorMethod · 0.80
typeMethod · 0.45

Tested by

no test coverage detected