feat: add Document and DocumentSearchResponse classes for document search API #592
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
This PR adds response model classes for the document search API, enabling a clean and intuitive interface for working with search results.
id,score, and dynamic field accessProblem
The document search API needs response models that allow users to easily access search results. Documents can have dynamic fields (varying per index schema), so the
Documentclass needs to support flexible field access patterns.Solution
The
Documentclass provides three ways to access fields:The class also supports:
idandscorepropertieskeys(),values(),items()for iterationinoperator for field existence checksto_dict()for serializationUsage Example
Test Plan
doc["field"])Related
Note
Low Risk
Low risk: this is additive (new dataclasses + exports) with unit tests; primary impact is new public API surface and lazy-import wiring.
Overview
Adds document-search response models. Introduces
Document(supportsid/scoreplus dynamic fields via attribute access,[], andget()) andDocumentSearchResponse(wrapsdocuments, optionalusage, and_response_info).Exposes these types through
pinecone.db_data.dataclassesand top-levelpineconelazy imports, and adds unit tests covering field access patterns, dict-like behavior, equality/serialization, and basic response usage.Written by Cursor Bugbot for commit 64ab854. This will update automatically on new commits. Configure here.