mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 11:49:53 -05:00
### Does this PR have any customer impact? Yes ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Feature ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) No ### Are you introducing any new config? If yes, do you have tests with and without them being set? No ### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md)) ### Description The results of vector search + filtering on the DiskANN index might become unordered after iterative searches. It's necessary to re-order the results. Adds a wrapper select query to the join query and re-order by the orderVar. To force the planner to re-order the query, `SELECT document FROM (JOIN c1 ON c1.ctid = c2.ctid limit k) ORDER BY c1.orderVal + 0` ---- #### AI description (iteration 1) #### PR Classification Enhancement to re-order search results after filtering in vector search using DiskANN. #### PR Summary This pull request introduces a mechanism to re-order search results after applying filters in vector search using DiskANN. - `src/aggregation/bson_aggregation_vector_search.c`: Added a new function `ReorderQueryResults` to wrap the join query and re-order results by a specified variable. - `src/test/regress/expected/bson_aggregation_pipeline_tests_vector_diskann.out`: Updated expected output to reflect the new query structure and re-ordering logic.