[PR #257] [MERGED] fix: Fix hybrid search bugs #264

Closed
opened 2026-02-16 05:17:09 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langchain-postgres/pull/257
Author: @dishaprakash
Created: 10/7/2025
Status: Merged
Merged: 10/9/2025
Merged by: @averikitsch

Base: mainHead: bug-fix


📝 Commits (6)

  • 0505073 fix: Fix hybrid search bugs
  • 71cf9ff Update async_vectorstore.py
  • 7c108a0 Update async_vectorstore.py
  • cc1a7a9 Merge branch 'main' into bug-fix
  • 661774c Merge branch 'main' into bug-fix
  • c8c9727 Update async_vectorstore.py

📊 Changes

1 file changed (+13 additions, -16 deletions)

View changed files

📝 langchain_postgres/v2/async_vectorstore.py (+13 -16)

📄 Description

This PR fixes the 2nd Major issue in https://github.com/langchain-ai/langchain-postgres/issues/234, related to Configuration and Querying Issues

Issue breakdown:

Inconsistent k Parameter: For hybrid searches, the dense search LIMIT was tied to the final k parameter, while the sparse search used its own secondary_top_k.
Late Initialization of HybridSearchConfig: The HybridSearchConfig was initialized after the k parameter was calculated, which could lead to incorrect behavior if the config was passed dynamically via kwargs.

Overview of the changes:

  1. The __query_collection method now uses a separate dense_limit for the dense search query.
    If HybridSearchConfig is active, dense_limit is set to primary_top_k. For dense-only searches, dense_limit defaults to the final k value, preserving the existing behavior.

  2. The hybrid_search_config is now initialized at the beginning of __query_collection, ensuring that any kwargs overrides are handled before k or dense_limit are calculated.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/langchain-postgres/pull/257 **Author:** [@dishaprakash](https://github.com/dishaprakash) **Created:** 10/7/2025 **Status:** ✅ Merged **Merged:** 10/9/2025 **Merged by:** [@averikitsch](https://github.com/averikitsch) **Base:** `main` ← **Head:** `bug-fix` --- ### 📝 Commits (6) - [`0505073`](https://github.com/langchain-ai/langchain-postgres/commit/0505073ad88f0e490b19b75cdfd516e21fb5d311) fix: Fix hybrid search bugs - [`71cf9ff`](https://github.com/langchain-ai/langchain-postgres/commit/71cf9ffb115d3325eecd09d3307ffbcea0e192f0) Update async_vectorstore.py - [`7c108a0`](https://github.com/langchain-ai/langchain-postgres/commit/7c108a0e0c6a092b4f72ff620bd4001524606509) Update async_vectorstore.py - [`cc1a7a9`](https://github.com/langchain-ai/langchain-postgres/commit/cc1a7a9dadf75b46cfd79e29447e10d69b111c31) Merge branch 'main' into bug-fix - [`661774c`](https://github.com/langchain-ai/langchain-postgres/commit/661774c1bc6654415baca6b7c563305f9186bac3) Merge branch 'main' into bug-fix - [`c8c9727`](https://github.com/langchain-ai/langchain-postgres/commit/c8c9727e29384837213a62caaadbbc7d24fed360) Update async_vectorstore.py ### 📊 Changes **1 file changed** (+13 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `langchain_postgres/v2/async_vectorstore.py` (+13 -16) </details> ### 📄 Description This PR fixes the 2nd Major issue in https://github.com/langchain-ai/langchain-postgres/issues/234, related to Configuration and Querying Issues Issue breakdown: - **Inconsistent k Parameter:** For hybrid searches, the dense search LIMIT was tied to the final k parameter, while the sparse search used its own secondary_top_k. **Late Initialization of HybridSearchConfig:** The HybridSearchConfig was initialized after the k parameter was calculated, which could lead to incorrect behavior if the config was passed dynamically via `kwargs`. Overview of the changes: - 1. The __query_collection method now uses a separate `dense_limit` for the dense search query. If HybridSearchConfig is active, dense_limit is set to primary_top_k. For dense-only searches, dense_limit defaults to the final k value, preserving the existing behavior. 2. The hybrid_search_config is now initialized at the beginning of `__query_collection`, ensuring that any `kwargs` overrides are handled before `k` or `dense_limit` are calculated. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 05:17:09 -05:00
yindo closed this issue 2026-02-16 05:17:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchain-postgres#264