{"id":2586,"library":"milvus-lite","title":"Milvus Lite","description":"Milvus Lite is a lightweight, embedded version of Milvus, a high-performance vector database, designed for rapid prototyping, local development, and edge devices. It provides core vector search functionalities and shares the same API as Milvus Standalone and Distributed deployments, ensuring a consistent development experience across various scales. Data is persisted locally in an SQLite file. The library is actively maintained as part of the `pymilvus` ecosystem, with the current version being 2.5.1.","status":"active","version":"2.5.1","language":"en","source_language":"en","source_url":"https://github.com/milvus-io/milvus-lite.git","tags":["vector database","embeddings","AI","machine learning","vector search","RAG"],"install":[{"cmd":"pip install -U pymilvus[milvus-lite]","lang":"bash","label":"Recommended Installation"},{"cmd":"pip install -U milvus-lite","lang":"bash","label":"Install milvus-lite package directly"}],"dependencies":[{"reason":"Required programming language environment.","package":"Python","optional":false},{"reason":"Needed for command-line data dumping/migration functionality.","package":"pymilvus[bulk_writer]","optional":true}],"imports":[{"note":"Milvus Lite is accessed via the MilvusClient from the pymilvus library by specifying a local file URI.","symbol":"MilvusClient","correct":"from pymilvus import MilvusClient"},{"note":"For explicit server control (e.g., setting base directory), default_server is imported from 'milvus', not 'milvus_lite'.","wrong":"from milvus_lite import default_server","symbol":"default_server","correct":"from milvus import default_server"}],"quickstart":{"code":"from pymilvus import MilvusClient, DataType\nimport os\n\n# Ensure a clean slate for demonstration\nif os.path.exists(\"milvus_demo.db\"): \n    os.remove(\"milvus_demo.db\")\n\n# 1. Set up a Milvus client with a local file for persistence\nclient = MilvusClient(uri=\"./milvus_demo.db\")\n\n# 2. Create schema\nschema = MilvusClient.create_schema(\n    auto_id=False,\n    enable_dynamic_field=True,\n)\nschema.add_field(field_name=\"id\", datatype=DataType.INT64, is_primary=True)\nschema.add_field(field_name=\"vector\", datatype=DataType.FLOAT_VECTOR, dim=5)\nschema.add_field(field_name=\"text\", datatype=DataType.VARCHAR, max_length=256)\n\n# 3. Create a collection\ncollection_name = \"demo_collection\"\nclient.create_collection(\n    collection_name=collection_name,\n    schema=schema,\n    # You can specify an index here, Milvus Lite will optimize internally\n    # index_params=MilvusClient.prepare_index_params(metric_type=\"L2\")\n)\n\n# 4. Insert data\ndata = [\n    {\"id\": 1, \"vector\": [0.1, 0.2, 0.3, 0.4, 0.5], \"text\": \"The quick brown fox\"},\n    {\"id\": 2, \"vector\": [0.5, 0.4, 0.3, 0.2, 0.1], \"text\": \"Jumps over the lazy dog\"},\n    {\"id\": 3, \"vector\": [0.8, 0.7, 0.6, 0.5, 0.4], \"text\": \"A fast animal\"},\n]\nclient.insert(collection_name=collection_name, data=data)\nclient.flush(collection_name=collection_name)\n\n# 5. Search for similar vectors\nsearch_vectors = [[0.15, 0.25, 0.35, 0.45, 0.55]]\nres = client.search(\n    collection_name=collection_name,\n    data=search_vectors,\n    limit=2,\n    output_fields=[\"text\"],\n)\nprint(\"Search Results:\", res)\n\n# 6. Query data by ID\nquery_res = client.query(collection_name=collection_name, filter=\"id in\", output_fields=[\"text\"])\nprint(\"Query Results:\", query_res)\n\n# Clean up (optional for next run)\nclient.drop_collection(collection_name=collection_name)\nclient.close() # Important to close client to ensure data is written to disk\n\nprint(\"Milvus Lite demo finished successfully!\")\n","lang":"python","description":"This quickstart demonstrates how to initialize Milvus Lite using `MilvusClient` with a local database file, define a collection schema, insert data (vectors and scalar fields), perform a vector similarity search, and query data. The `uri` parameter for `MilvusClient` points to a local file, which acts as the Milvus Lite database."},"warnings":[{"fix":"Evaluate your scale requirements early. For larger datasets or production, plan to migrate to other Milvus deployments. Milvus Lite provides a command-line tool for data migration.","message":"Milvus Lite is designed for small-scale prototyping (typically less than a million vectors) or edge devices. It is not recommended for large-scale production deployments where Milvus Standalone, Distributed, or Zilliz Cloud should be used instead.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If precise control over index types or more advanced indexing is critical, ensure you are on version 2.4.11 or later for IVF_FLAT support. For full index flexibility, use a non-Lite Milvus deployment.","message":"Prior to Milvus Lite version 2.4.11, only the FLAT index type was supported, regardless of any other index type specified during collection creation. For versions 2.4.11 and later, both FLAT and IVF_FLAT are supported, with automatic internal switching (FLAT for <100,000 vectors, IVF_FLAT for >=100,000 vectors).","severity":"breaking","affected_versions":"< 2.4.11"},{"fix":"If your application requires partitions, user management, or aliases, you must use Milvus Standalone, Milvus Distributed, or Zilliz Cloud.","message":"Milvus Lite does not support advanced Milvus features such as partitions, users/roles/RBAC (Role-Based Access Control), or aliases. Attempting to use these features will result in errors or unexpected behavior.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be mindful of the `uri` parameter when transitioning an application developed with Milvus Lite to a different Milvus deployment. The rest of the client-side code should largely remain compatible.","message":"While Milvus Lite uses the same Python client API (`pymilvus`) as other Milvus deployments, the `uri` parameter for `MilvusClient` differs. For Milvus Lite, it's a local file path (e.g., './milvus_demo.db'). For other deployments, it's a network endpoint (e.g., 'http://localhost:19530' or a Zilliz Cloud endpoint).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}