fix: support legacy search query bodies#668
Open
pragnyanramtha wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
queryrequest-body parameter to sync, async, and gRPC-backedsearch()/search_records()search(namespace=..., query={...}, fields=[...])call shapeFixes #661.
Validation
uv sync --dev --no-install-projectuv run --no-sync pytest tests/unit/test_index_search.py tests/unit/test_async_search.py tests/unit/test_grpc_index.py tests/unit/test_search_records_alias.py tests/unit/test_async_search_records_alias.py -q(142 passed)uv run --no-sync pytest tests/unit/test_client_timeout_parity.py tests/unit/test_backcompat_search_shims.py tests/unit/test_response_info_populated.py tests/unit/test_async_response_info.py -q(75 passed)uv run --no-sync ruff check pinecone/_internal/data_plane_helpers.py pinecone/index/__init__.py pinecone/async_client/async_index.py pinecone/grpc/__init__.py tests/unit/test_index_search.py tests/unit/test_async_search.py tests/unit/test_grpc_index.py tests/unit/test_search_records_alias.py tests/unit/test_async_search_records_alias.pyuv run --no-sync ruff format --check pinecone/_internal/data_plane_helpers.py pinecone/index/__init__.py pinecone/async_client/async_index.py pinecone/grpc/__init__.py tests/unit/test_index_search.py tests/unit/test_async_search.py tests/unit/test_grpc_index.py tests/unit/test_search_records_alias.py tests/unit/test_async_search_records_alias.pyuv run --no-sync mypy --strict pinecone/_internal/data_plane_helpers.py pinecone/index/__init__.py pinecone/async_client/async_index.py pinecone/grpc/__init__.pygit diff --checkNote
Medium Risk
Touches public
search()/search_records()request building across sync, async, and gRPC clients, so regressions could affect search request shapes and validation. Risk is mitigated by added unit coverage for legacyqueryusage and param-mixing errors.Overview
Adds support for passing a legacy
queryrequest-body object tosearch()/search_records()across the syncIndex,AsyncIndex, and REST-backedGrpcIndexsearch APIs.Centralizes search request-body construction/validation in
_build_search_records_body, including mutual-exclusion rules (queryvs direct params),top_k/source validation, rerank required keys checks, and consistent normalization of dense vs sparse/hybrid vector shapes (with a gRPC-specific option to preserve the existing dense-vector wire format).Extends unit tests to cover legacy
querypassthrough, rejection of mixedquery+direct params, and updated alias forwarding to include the newqueryargument.Reviewed by Cursor Bugbot for commit 7fc0678. Bugbot is set up for automated code reviews on this repo. Configure here.