From 7bd70cf6bdb7c8ddcd26025a6c1cd2d4cf427a76 Mon Sep 17 00:00:00 2001 From: AlexShen-Oguri <176059206+AlexShen-Oguri@users.noreply.github.com> Date: Mon, 30 Nov 2026 21:54:34 -0500 Subject: [PATCH] Run single-connection hybrid queries in sequence The semantic and keyword queries share a Psycopg connection, which serializes cursor operations. Preserve the result order for reranking. Co-authored-by: OpenAI Codex --- examples/hybrid_search/cross_encoder.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/hybrid_search/cross_encoder.py b/examples/hybrid_search/cross_encoder.py index c4e6eea..3d65899 100644 --- a/examples/hybrid_search/cross_encoder.py +++ b/examples/hybrid_search/cross_encoder.py @@ -64,9 +64,10 @@ async def main(): await create_schema(conn) await insert_data(conn) - # perform queries in parallel - results = await asyncio.gather(semantic_search(conn, query), keyword_search(conn, query)) - results = rerank(query, results) + # Psycopg serializes queries on a shared connection. + semantic_results = await semantic_search(conn, query) + keyword_results = await keyword_search(conn, query) + results = rerank(query, [semantic_results, keyword_results]) print(results)