Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support offset in search param #1614

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pymilvus/client/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,14 +596,24 @@ def search_requests_with_expr(
params = param.get("params", {})
if not isinstance(params, dict):
raise ParamError(message=f"Search params must be a dict, got {type(params)}")

search_params = {
"topk": limit,
"params": params,
"round_decimal": round_decimal,
"offset": param.get("offset", 0),
"ignore_growing": ignore_growing,
}

# parse offset
if "offset" in kwargs and "offset" in param:
raise ParamError(message="Provide offset both in kwargs and param, expect just one")

offset = kwargs.get("offset") or param.get("offset")
if offset is not None:
if not isinstance(offset, int):
raise ParamError(message=f"wrong type for offset, expect int, got {type(offset)}")
search_params["offset"] = offset

if param.get("metric_type", None) is not None:
search_params["metric_type"] = param["metric_type"]

Expand Down
7 changes: 4 additions & 3 deletions pymilvus/orm/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,6 @@ def search(
similar metricy types, the value must be of type str.
* *offset* (``int``, optional)
offset for pagination.
* *limit* (``int``, optional)
limit for the search results and pagination.
* *params of index: *nprobe*, *ef*, *search_k*, etc
Corresponding search params for a certain index.
example for param::
Expand All @@ -602,7 +600,7 @@ def search(
}

limit (``int``): The max number of returned record, also known as `topk`.
expr (``str``): The boolean expression used to filter attribute. Default to None.
expr (``str``, Optional): The boolean expression used to filter attribute.

example for expr::

Expand All @@ -627,6 +625,9 @@ def search(
The callback function which is invoked after server response successfully.
It functions only if _async is set to True.

* *offset* (``int``, optinal)
offset for pagination.

* *consistency_level* (``str/int``, optional)
Which consistency level to use when searching in the collection.

Expand Down
Loading