| 330 | } |
| 331 | |
| 332 | void ZVecPyCollection::bind_dql_methods( |
| 333 | py::class_<Collection, Collection::Ptr> &col) { |
| 334 | // Query with the GIL released, then materialize all hits into |
| 335 | // (id, score, fields, vectors) tuples in one crossing (see docs_to_tuples). |
| 336 | // execute_for_python captures the docs and the schema snapshot atomically |
| 337 | // under one read lock, so concurrent DDL cannot desynchronize them, while |
| 338 | // the binding signature stays unchanged from the legacy per-doc binding. |
| 339 | col.def( |
| 340 | "Query", |
| 341 | [](const Collection &self, const SearchQuery &query) { |
| 342 | return execute_for_python(self, query); |
| 343 | }, |
| 344 | py::arg("query"), |
| 345 | "Execute a query and return results as a list of " |
| 346 | "(id, score, fields, vectors) tuples materialized in one batch.") |
| 347 | // MultiQuery: multi query with reranker |
| 348 | .def( |
| 349 | "Query", |
| 350 | [](const Collection &self, const MultiQuery &query) { |
| 351 | return execute_for_python(self, query); |
| 352 | }, |
| 353 | py::arg("query"), |
| 354 | "Execute a multi query with re-ranking and return results as a " |
| 355 | "list of (id, score, fields, vectors) tuples materialized in one " |
| 356 | "batch.") |
| 357 | .def( |
| 358 | "QueryInternalIds", |
| 359 | [](const Collection &self, const SearchQuery &query, |
| 360 | bool return_scores) -> py::object { |
| 361 | Result<InternalIdsQueryResult> result; |
| 362 | { |
| 363 | py::gil_scoped_release release; |
| 364 | result = self.query_internal_ids(query, return_scores); |
| 365 | } |
| 366 | auto output = unwrap_expected(std::move(result)); |
| 367 | auto ids = owned_array(std::move(output.ids)); |
| 368 | if (!return_scores) return ids; |
| 369 | return py::make_tuple(std::move(ids), |
| 370 | owned_array(std::move(output.scores))); |
| 371 | }, |
| 372 | py::arg("query"), py::arg("return_scores") = false, |
| 373 | R"doc(Execute a single query and return internal numeric IDs. |
| 374 | |
| 375 | Accepts the same single-target SearchQuery object as Query. Returns an owning |
| 376 | int64 array, or (IDs, float32 scores) with return_scores=True. Scores include |
| 377 | refinement. Eligible dense queries use the specialized low-latency path; |
| 378 | other query shapes use regular Query semantics. Use ResolveInternalIds to |
| 379 | convert IDs to user primary keys. |
| 380 | )doc") |
| 381 | .def( |
| 382 | "ResolveInternalIds", |
| 383 | [](const Collection &self, const std::vector<int64_t> &ids) { |
| 384 | Result<std::vector<std::optional<std::string>>> result; |
| 385 | { |
| 386 | py::gil_scoped_release release; |
| 387 | result = self.resolve_internal_ids(ids); |
| 388 | } |
| 389 | return unwrap_expected(std::move(result)); |
nothing calls this directly
no test coverage detected