Skip to content

Commit

Permalink
Check partition_names and output_fields when search (milvus-io#613)
Browse files Browse the repository at this point in the history
Signed-off-by: dragondriver <[email protected]>
  • Loading branch information
longjiquan authored Jul 20, 2021
1 parent 5f8292d commit 90d6b06
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
17 changes: 17 additions & 0 deletions pymilvus/client/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,20 @@ def is_legal_search_data(data):
return True


def is_legal_output_fields(output_fields):
if output_fields is None:
return True

if not isinstance(output_fields, list):
return False

for field in output_fields:
if not is_legal_field_name(field):
return False

return True


def is_legal_partition_name_array(tag_array):
if tag_array is None:
return True
Expand Down Expand Up @@ -302,6 +316,9 @@ def check_pass_param(*args, **kwargs):
elif key in ("search_data",):
if not is_legal_search_data(value):
_raise_param_error(key, value)
elif key in ("output_fields",):
if not is_legal_output_fields(value):
_raise_param_error(key, value)
# elif key in ("records",):
# if not is_legal_records(value):
# _raise_param_error(key, value)
Expand Down
8 changes: 7 additions & 1 deletion pymilvus/client/stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,13 @@ def search_with_expression(self, collection_name, data, anns_field, param, limit
ParamError: If parameters are invalid
BaseException: If the return result from server is not ok
"""
check_pass_param(limit=limit, anns_field=anns_field, search_data=data)
check_pass_param(
limit=limit,
anns_field=anns_field,
search_data=data,
partition_name_array=partition_names,
output_fields=output_fields,
)
with self._connection() as handler:
kwargs["_deploy_mode"] = self._deploy_mode
return handler.search_with_expression(collection_name, data, anns_field, param, limit, expression, partition_names, output_fields, timeout, **kwargs)
Expand Down

0 comments on commit 90d6b06

Please sign in to comment.