Skip to content

Commit f17b6a5

Browse files
authored
fix: Omit empty index types (#2745)
Signed-off-by: yangxuan <[email protected]>
1 parent 9e448a1 commit f17b6a5

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

pymilvus/client/prepare.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1140,8 +1140,9 @@ def create_index_request(cls, collection_name: str, field_name: str, params: Dic
11401140
for tk, tv in params.items():
11411141
if tk == "dim" and (not tv or not isinstance(tv, int)):
11421142
raise ParamError(message="dim must be of int!")
1143-
kv_pair = common_types.KeyValuePair(key=str(tk), value=utils.dumps(tv))
1144-
index_params.extra_params.append(kv_pair)
1143+
if tv:
1144+
kv_pair = common_types.KeyValuePair(key=str(tk), value=utils.dumps(tv))
1145+
index_params.extra_params.append(kv_pair)
11451146

11461147
return index_params
11471148

pymilvus/milvus_client/index.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ def get_index_configs(self) -> Dict:
5050
"efConstruction": 100,
5151
}
5252
"""
53-
return {
54-
"index_type": self.index_type,
55-
**self._configs,
56-
}
53+
configs = self._configs
54+
# Omit index_type if it's empty
55+
if self.index_type:
56+
configs["index_type"] = self.index_type
57+
return configs
5758

5859
def to_dict(self) -> Dict:
5960
"""All params"""

0 commit comments

Comments
 (0)