fix: remove embedding vector from Milvus search output_fields#265
Open
octo-patch wants to merge 1 commit into
Open
Conversation
…ech#238) The embedding vector field is not needed in search results since RetrievalResult.embedding is only used in __repr__ and not consumed by any downstream agent code. Requesting it in output_fields causes MilvusException (code=65535, message=field embedding not exist) in certain Milvus versions/configurations (e.g. Milvus docker standalone). Pass None for embedding in RetrievalResult to maintain API compatibility. Co-Authored-By: Octopus <liyuan851277048@icloud.com>
Collaborator
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: octo-patch The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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.
Fixes #238
Problem
In some Milvus configurations (e.g. Milvus docker standalone, Milvus server deployments), requesting the
embeddingvector field as an output field inclient.search()raises:This causes
search_data()to fail entirely, making the whole query pipeline crash with aRuntimeError.Root Cause
The
output_fields=["embedding", "text", "reference", "metadata"]parameter requests the dense vector field back from Milvus. Some Milvus versions or server configurations do not support returning vector fields viaoutput_fields, resulting in the above exception.Importantly,
RetrievalResult.embeddingis never used downstream — it only appears in__repr__(). No agent code reads the embedding from search results, making this retrieval unnecessary and wasteful (embeddings can be thousands of floats per result).Solution
"embedding"fromoutput_fieldsin both regular search and hybrid search callsNonefor theembeddingparameter when constructingRetrievalResultThis eliminates the exception, reduces data transfer from Milvus, and has no functional impact since the embedding value from search results is never consumed.
Testing
Verified against existing
tests/vector_db/test_milvus.pytest suite —test_search_datapasses as before since it only checks the result is aRetrievalResultinstance, not itsembeddingvalue.