feat: Add query factory functions (text_query, vector_query) #591
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
Adds
text_query()andvector_query()factory functions that provide a simpler, more ergonomic API for constructing query objects to use withsearch_documents().Problem
Users need to import and instantiate
TextQueryandVectorQueryclasses directly, which is verbose for simple use cases.Solution
Added two factory functions that wrap the dataclass constructors:
text_query(field, query, boost=None, slop=None)- Creates aTextQueryfor full-text searchvector_query(field, values=None, sparse_values=None)- Creates aVectorQueryfor similarity searchBoth functions are exported from the
pineconepackage for convenient imports.Usage Examples
Related Issues
Note
Low Risk
Low risk: adds thin wrapper factory functions and exposes them via top-level lazy imports, with unit coverage; main impact is expanded public API surface and import/export behavior.
Overview
Adds new factory helpers
text_query()andvector_query()(inpinecone/db_data/query_helpers.py) to simplify constructingTextQuery/VectorQueryobjects forsearch_documents().Exports these helpers from the top-level
pineconepackage via the existing lazy-import mechanism, and adds unit tests validating parameter handling and.as_dict()serialization plus top-level importability.Written by Cursor Bugbot for commit 0dd0261. This will update automatically on new commits. Configure here.