Skip to content

Commit

Permalink
Merge pull request #82 from zilliztech/fix-search
Browse files Browse the repository at this point in the history
fix: get index params safty
  • Loading branch information
shanghaikid authored Jun 20, 2024
2 parents c348879 + 99c5471 commit 529bd47
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
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

0 comments on commit 529bd47

Please sign in to comment.