NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI, #2267 most downloaded on PyPI
Python SDK for Milvus
Latest stable
3.0.3
Last release 12 days ago
10 Nov 2026
Ships fairly regularly
a new release about every 3 weeks
Nearly every release is documented
notes for 60 of the last 60 stable releases
1 version withdrawn
withdrawn after publishing
7 years old
150 releases · first in 2019
Drag across the ruler to compare, or tap a release to open it.
MilvusClient provides a simple and easy-to-use alternative to the legacy ORM approach. It adopts a purely functional approach to simplify interactions
MilvusClient provides a simple and easy-to-use alternative to the legacy ORM approach. It adopts a purely functional approach to simplify interactions with the server. Each MilvusClient establishes a gRPC connection to the server you specified. To set up multiple connections, you can create multiple MilvusClient instances.
You can run the following command to install the latest PyMilvus or update your PyMilvus to this version.
pip install --upgrade pymilvus==v2.3.7
After the installation, you can check the pymilvus version by running the following
from pymilvus import __version__
print(__version__)
#v2.3.7
from pymilvus import MilvusClient
# Authentication not enabled
client = MilvusClient("http://localhost:19530")
# Authentication enabled with the root user
client = MilvusClient(
uri="http://localhost:19530",
token="root:Milvus",
db_name="default"
)
# Authentication enabled with a non-root user
client = MilvusClient(
uri="http://localhost:19530",
token="user:password", # replace this with your token
db_name="default"
)
In this version, PyMilvus adds a MilvusClient module that incorporates several functional methods, aligning its functionality overall with that of the legacy ORM module.
In addition to the documents, you can also refer to the example sets in our GitHub repo.
If you are having trouble or have questions about PyMilvus, ask your question on our PyMilvus Community Forum. Once you get an answer, it’d be great if you could work it back into this documentation and contribute!
We are committed to building a collaborative, exuberant open-source community for PyMilvus. Therefore, contributions to PyMilvus are welcome from everyone. Refer to Contributing Guideline before making contributions to this project. You can file an issue or contact us on Slack if you need any assistance or want to propose your ideas about PyMilvus.
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Support python3.12 by @XuanYang-cn in https://github.com/milvus-io/pymilvus/pull/1861
Full Changelog: https://github.com/milvus-io/pymilvus/compare/v2.3.5...v2.3.6
add limit for too large ef to avoid huge latency for iterator(#1814) by @MrPresent-Han in https://github.com/milvus-io/pymilvus/pull/1815
Full Changelog: https://github.com/milvus-io/pymilvus/compare/v2.3.4...v2.3.5
enhance: remove partition existance check by @yah01 in https://github.com/milvus-io/pymilvus/pull/1792
Full Changelog: https://github.com/milvus-io/pymilvus/compare/v2.3.3...v2.3.4
Change unimpleted log level to debug by @xiaocai2333 in https://github.com/milvus-io/pymilvus/pull/1760
Full Changelog: https://github.com/milvus-io/pymilvus/compare/v2.3.2...v2.3.3
Support new DataType: Array by @xiaocai2333 in https://github.com/milvus-io/pymilvus/pull/1681
Full Changelog: https://github.com/milvus-io/pymilvus/compare/v2.3.1...v2.3.2
Use flush_ts and collection_name when getting flush state by @bigsheeper in https://github.com/milvus-io/pymilvus/pull/1675
Full Changelog: https://github.com/milvus-io/pymilvus/compare/v2.3.0...v2.3.1
Add the load_state api by @SimFG in https://github.com/milvus-io/pymilvus/pull/1258
load_state api by @SimFG in https://github.com/milvus-io/pymilvus/pull/1258Full Changelog: https://github.com/milvus-io/pymilvus/compare/v2.2.15...v2.3.0
Nothing published for this version
Enable ignored checker PYI024 by @XuanYang-cn in https://github.com/milvus-io/pymilvus/pull/1702
Full Changelog: https://github.com/milvus-io/pymilvus/compare/v2.2.16...v2.2.17
Fix lint error by @yhmo in https://github.com/milvus-io/pymilvus/pull/1668
Full Changelog: https://github.com/milvus-io/pymilvus/compare/v2.2.15...v2.2.16
Enable to set offet&limit in search params.
Support rename db for collection
Nothing published for this version
By setting the "ensure_ascii=False" parameter in the "json.dumps" function, non-ASCII characters in the data are not escaped during the "insert" opera
By setting the "ensure_ascii=False" parameter in the "json.dumps" function, non-ASCII characters in the data are not escaped during the "insert" operation. After inserting non-ASCII characters without escaping, users can also use them as keys in expression filtering from the JSON field. The following is a sample code snippet.
import numpy as np
from pymilvus import MilvusClient, DataType
dimension = 128
collection_name = "books"
client = MilvusClient("http://localhost:19530")
schema = client.create_schema(auto_id=True)
schema.add_field("id", DataType.INT64, is_primary=True)
schema.add_field("embeddings", DataType.FLOAT_VECTOR, dim=dimension)
schema.add_field("info", DataType.JSON)
index_param = client.prepare_index_params("embeddings", metric_type="L2")
client.create_collection_with_schema(collection_name, schema, index_param)
rng = np.random.default_rng(seed=19530)
rows = [
{"embeddings": rng.random((1, dimension))[0],
"info": {"title": "Lord of the Flies", "author": "William Golding"}},
{"embeddings": rng.random((1, dimension))[0],
"info": {"作者": "J.D.塞林格", "title": "麦田里的守望者", }},
{"embeddings": rng.random((1, dimension))[0],
"info": {"Título": "Cien años de soledad", "autor": "Gabriel García Márquez"}},
]
client.insert(collection_name, rows)
result = client.query(collection_name, filter="info['作者'] == 'J.D.塞林格' or info['Título'] == 'Cien años de soledad'",
output_fields=["info"],
consistency_level="Strong")
for hit in result:
print(f"hit: {hit}")
The output will be:
hit: {'info': {'作者': 'J.D.塞林格', 'title': '麦田里的守望者'}, 'id': 442210659570062545}
hit: {'info': {'Título': 'Cien años de soledad', 'autor': 'Gabriel García Márquez'}, 'id': 442210659570062546}
Nothing published for this version
- JSON support - Dynamic schema - Partition key - Connection management
[[FEATURE]: Has an utility function to parse if the connection is to Zilliz cloud or opensource Milvus](https://github.com/milvus-io/pymilvus/issues/1
>>> utility.get_server_type(using="default")
"milvus"
>>> utility.list_indexes(collection_name, field_name=vec_field)
[vec_field_idx]
from pymilvus import connections
uri = "https://username:password@exampledomain.com:19530"
connections.connect(uri=uri)
// set MILVUS_URI in env
$ export MILVUS_URI=https://username:password@exampledomain.com:19530
>>> from pymilvus import connections
>>> connections.connect()
>>> connections.get_connection_addr("default")
{"address": "exampledomain.com:19530", "user": username}
# .env.example in https://github.com/milvus-io/pymilvus/blob/master/.env.example
# Please copy this file and rename as .env, pymilvus will read .env file if provided
MILVUS_URI=
# MILVUS_URI=https://username:password@in01-random123.xxx.com:19530
# Milvus connections configs
MILVUS_CONN_ALIAS=default
MILVUS_CONN_TIMEOUT=10
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Fix some bugs, improve some search performance
Fix some bugs, improve some search performance
|Methods in 2.1.x| Methods in 2.2.x|
utility| Methods in 2.1.x | Methods in 2.2.x |
|---|---|
utility.create_credential |
utility.create_user |
[No change]utility.reset_password |
utility.reset_password |
utility.update_credential |
utility.update_password |
utility.delete_credential |
utility.delete_user |
utility.list_cred_users |
utility.list_usernames |
| - | utility.list_roles |
| - | utility.list_user |
| - | utility.list_users |
Roleutility.do_bulk_insertutility.get_bulk_insert_stateutility.list_bulk_insert_tasksflushCollection.flush()Add properties support when init Collection
Collection(name="a", data=data, schema=schema, properties={"collection.ttl.seconds": 1800})
num_entities doesn't invoke flush insidecreate_index:flush inside.Collection.drop:Collection.release() and index.drop() inside.calc_distance()Nothing published for this version
Nothing published for this version
Nothing published for this version
```python collection.load(replica_number=2)
collection.load(replica_number=2)
collection.get_replicas()
VARCHAR data typeVARCHAR field in schema, also VARCHAR field can be used as primary field:FieldSchema(name="pk", dtype=DataType.VARCHAR, is_primary=True, auto_id=False, max_length=100)
VARCHAR field:entities = [
[str(i) for i in range(num_entities)],
]
insert_result = collection.insert(entities)
VARCHAR field, for now, the only supported index for string is Trie:collection.create_index(field_name="pk", index_name="index_on_varchar")
Just like other data type, scalar filtering expression on VARCHAR field is also supported, besides basic filters, prefix match is also supported. Please visist milvus.io for more detailed information.
VARCHAR field as output fields is also supported when you are about to do a search or query:
res = collection.query(expr='pk > "str"', output_fields=["pk"])
Now, you can specify index name when you create index for field.
collection.create_index(field_name="field", index_name="index_name", index_params={})
collection.drop_index(index_name="index_name")
For backward compatibility, if you don't specify the index name, _default_idx will be used.
We add some APIs to support basic authentication:
If there are any users in Milvus server, then the user and password are required to setup a connection:
connections.connect(host="host", port="port", user="user", password="password")
For more detailed information, please refer to mep27.
Besides basic authentication, we also support to tls in RPC, you can setup a secure connection.
For one-way tls:
connections.connect(host=_HOST, port=_PORT, secure=True, server_pem_path="server.pem", server_name="localhost")
For two-way tls:
connections.connect(host=_HOST,
port=_PORT,
secure=True,
client_pem_path="client.pem",
client_key_path="client.key",
ca_pem_path="ca.pem",
server_name="localhost")
connections.connect(alias="test", uri="https://example.com:19530")
Add support for numpy.ndarray for vector field
Release date: 2022-04-02
Support secure gRPC channel for AWS
Release date: 2022-02-23
Mark Milvus class as deprecated. There'll be a warning every time you try to use 1.x Milvus class on Milvus 2.0.0.
Along with Milvus 2.0.0, we are so glad to announce the release of PyMilvus 2.0.0.
From this version, PyMilvus's releases will no longer follow the release of Milvus. We'll focus on improving the codes quality and ease-of-use, and of course, support for new features from Milvus.
As for PyMilvus 2.0.0, there are some exciting news we want to share with you.
For the convenience of the Milvus 1.x users, we had reserved PyMilvus 1.x APIs within all release-candidates versions of PyMilvus. Now it's time to say goodbye to those 1.x APIs if you're using Milvus 2.0.0.
Note: 1.x APIs means the usage of
Milvus()class.
Here's why:
The mixed usage of the 1.x APIs and the orm-styled APIs is not recommended, but you still can use 1.x APIs for Milvus 2.0.0 in PyMilvus2.0.0.
Here's what we've done to avoid the mixed usage:
Milvus object through the orm-styled APIs.Milvus class as deprecated. There'll be a warning every time you try to use 1.x Milvus class on Milvus 2.0.0.Flush in Milvus 2.0.0 refers to a completely different method. Whereas reads and writes are completely separated in Milvus 2.0.0, you don't need to flush to make the entity searchable by query node. Instead, consistency level is what you need to worry about.If you encounter any problems while upgrading PyMilvus to 2.0.0, don't worry, it's just a few steps away, and we're always here to help. Here're some tips:
Milvus() class and you are good to go.Note: There is no documentation elaborating the usage of the 1.x APIs on Milvus 2.0.0, and we're planning to remove these APIs in the next release of PyMilvus.
examples/hello_milvus.py in PyMilvus GitHub repository for the correct usages.Check parameters related to guarantee_timestamp
Release date: 2021-12-31
Fix hello milvus (#829)
Check parameters related to guarantee_timestamp (#826)
Fix check_pass_param check for ndarray
Release date:2021-11-1
Update SchemaNotReady exception msg when collection not exist
Release date:2021-10-11
Make wait for healthy timeout controllable
Release date:2021-09-10
Remove publish release package github action
Release date:2021-08-30
drop_collection (#658)Release date:2021-08-16 Compatible with Milvus v2.x
Release date:2021-08-16 Compatible with Milvus v2.x
Release date:2021-07-12 Compatible with Milvus 2.X
Release date:2021-07-12 Compatible with Milvus 2.X
Fixed bugs:
When search parameter limit is 0, it should return a meaningful error message (#583)
The callback of insert dose not take effect (#587)
Error message does not specify the reason accurately when search using vector with not matched dim (#592)
Fix float vector result handler crashed when dim not set (#603)
PyMilvus 2.x only supports Milvus 2.x and is not compatible with Milvus 1.x.
PyMilvus 2.x only supports Milvus 2.x and is not compatible with Milvus 1.x.
See Milvus v2.0.0-RC1 Release Notes
Following are changes on PyMilvus APIs in v2.0.0rc1.
The package name is changed to pymilvus, which means the former statement from milvus import Milvus is no longer valid. Please change it to the following statement.
from pymilvus import Milvus
Milvus v2.0.0-RC1 does not support delete, so all the APIs about delete are not supported in this release.
get_entity_by_id() is replaced by query().
These APIs have some changes: get_collection_stats() , create_index().
These APIs are removed: get_collection_info(), count_entities(), compact(), delete_entity_by_id(), get_entity_by_id(), reload_segments(), list_id_in_segment(), get_index_info(), search_in_segment(), get_config(), set_config().
These APIs are new in PyMilvus v2.0.0rc1: describe_collection(), load_partitions(), release_partitions(), describe_index(), get_partition_stats(), search_with_expression(), query().
Release date:2021-06-09 Compatible with Milvus v1.1.x
Release date:2021-06-09 Compatible with Milvus v1.1.x
Fix Pymilvus connection timeout bug( #545 #539 )
Release date:2021-05-28 Compatible with Milvus v1.1.x
Release date:2021-05-28 Compatible with Milvus v1.1.x
Control required version for grpcio and grpcio-tools (#522)
Update OWNER file
Release date:2021-04-29 Compatible with Milvus v1.1.x
Release date:2021-04-29 Compatible with Milvus v1.1.x
get_entity_by_id and delete_entity_by_id, add new parameter "partition_tag"release_collectionRelease date:2021-03-08 Compatible with Milvus v1.0.x
Release date:2021-03-08 Compatible with Milvus v1.0.x
Nothing published for this version
Not support python 3.5 any more
Incompatibly support hybrid functionality. The changed APIs are:
Upgrade method load_collection() to support specify partitions
load_collection() to support specify partitionsFix wrong result on 'has_partition' with http handler #237
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.