Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added pagination for azure ai search retriever #29525

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Anash3
Copy link
Contributor

@Anash3 Anash3 commented Jan 31, 2025

Description
This PR adds support for pagination in the Azure AI Search retriever. Currently, when top_k=None, the retriever only returns up to 50 results due to Azure's default limit. This change properly implements pagination to retrieve all matching documents when top_k=None, ensuring complete results.

Changes
Modified _search and _asearch methods to implement pagination using $top and $skip parameters.
Ensured top_k=None retrieves all results instead of being limited to 50.
Preserved original top_k behavior when explicitly set.
Added pagination support in both synchronous and asynchronous implementations.

Issue
Closes #27830

Implementation Notes
No changes to the public API or function signatures.
Backwards compatible—behavior remains unchanged for top_k values set explicitly.
More efficient than retrieving results in a single large batch.
Preserves all existing functionality, including metadata handling and document conversion.

Dependencies
None

Additional Notes
The implementation ensures proper pagination logic using $top and $skip.
Aligns with Azure AI Search best practices for retrieving large datasets.
Future extensions could include dynamic batch size optimization for better performance. 🚀

Copy link

vercel bot commented Jan 31, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Jan 31, 2025 6:18pm

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. community Related to langchain-community Ɑ: retriever Related to retriever module Ɑ: vector store Related to vector store module labels Jan 31, 2025
@Anash3 Anash3 changed the title Fix/azure db added pagination for azure ai search retriever Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Related to langchain-community Ɑ: retriever Related to retriever module size:M This PR changes 30-99 lines, ignoring generated files. Ɑ: vector store Related to vector store module
Projects
Status: Triage
Development

Successfully merging this pull request may close these issues.

AzureAISearch Retriever only returns up to 50 docs
1 participant