bug: fix default search_param in milvus.py #4683
Closed
+2
−2
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.
Describe the bug
A bug in haystack/blob/main/haystack/document_stores/milvus.py.
In MilvusDocumentStore, search_param, line 167:
self.search_param = search_param or {"nprobe": 10}
And in line 433:
param={"metric_type": self.metric_type, **self.search_param},
query with milvus2 will give an error due to this incorrect parameter passing
Error message
ERROR:pymilvus.decorators:RPC error: [search], <MilvusException: (code=1, message=fail to search on all shard leaders, err=All attempts results:
attempt #1: UnexpectedError, error: fail to Search, QueryNode ID=14, reason=Search 14 failed, reason [UnexpectedError] Error in virtual knowhere::DatasetPtr knowhere::IVF_NM::Query(const DatasetPtr&, const Config&, faiss::BitsetView) at IndexIVF_NM.cpp:216: [json.exception.out_of_range. 403] key 'nprobe' not found err %!w()
attempt #2 canceled
)>, <Time:{'RPC start': '2023-04-17 10:19:17.569321', 'RPC error': '2023-04-17 10:19:17.987552'}>
Error Reason
According to https://milvus.io/docs/search.md , search_params = {"metric_type": "L2", "params": {"nprobe": 10}, "offset": 5}
But in line 433, it will be search_params = {"metric_type": "L2", "nprobe": 10}, if user uses default self.search_param
Method of correction
change line 433 into:
param={"metric_type": self.metric_type, "params": self.search_param},
or change line167 and related describe:
self.search_param = search_param or {"params":{"nprobe": 10}}