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

fix: get index params safty #82

Merged
merged 1 commit into from
Jun 20, 2024
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
4 changes: 2 additions & 2 deletions milvus_cli/Index.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def get_index_details(
rows.append(["Corresponding Field", index.field_name])
rows.append(["Index Name", index.index_name])

rows.append(["Index Type", index.params["index_type"]])
rows.append(["Metric Type", index.params["metric_type"]])
rows.append(["Index Type", index.params.get("index_type", "")])
rows.append(["Metric Type", index.params.get("metric_type", "")])
params = index.params.get("params", {})
paramsDetails = "\n- ".join(map(lambda k: f"{k[0]}: {k[1]}", params.items()))

Expand Down
14 changes: 8 additions & 6 deletions milvus_cli/scripts/data_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,19 @@ def search(obj):
type=click.Choice(obj.collection.list_field_names(collectionName)),
)
indexes = obj.index.list_indexes(collectionName, onlyData=True)
indexDetails = None
for index in indexes:
if index.field_name == annsField:
indexDetails = index
break

hasIndex = not not indexDetails
if indexDetails:
index_type = indexDetails._index_params["index_type"]
search_parameters = IndexTypesMap[index_type]["search_parameters"]
metric_type = indexDetails._index_params["metric_type"]
index_type = indexDetails._index_params.get("index_type", "AUTOINDEX")
metric_type = indexDetails._index_params.get("metric_type", "")
click.echo(f"Metric type: {metric_type}")
metricType = metric_type
search_parameters = IndexTypesMap[index_type]["search_parameters"]
params = []
for parameter in search_parameters:
paramInput = click.prompt(f"Search parameter {parameter}'s value")
Expand All @@ -282,11 +284,11 @@ def search(obj):
params = []

groupByField = click.prompt(
"Groups search results by a specified field to ensure diversity and avoid returning multiple results from the same group.",
default=None,
"Groups search by Field",
default="",
type=str,
)
if groupByField != None:
if groupByField != "":
params += [f"group_by_field:{groupByField}"]
roundDecimal = click.prompt(
"The specified number of decimal places of returned distance",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="milvus_cli",
version="v0.4.3",
version="v1.0.0",
author="Milvus Team",
author_email="[email protected]",
url="https://github.com/zilliztech/milvus_cli",
Expand Down