{"id":13619163,"url":"https://github.com/patterns-ai-core/milvus","last_synced_at":"2025-05-01T14:33:51.267Z","repository":{"id":153891014,"uuid":"630589296","full_name":"patterns-ai-core/milvus","owner":"patterns-ai-core","description":"Ruby wrapper for the Milvus vector search database API","archived":false,"fork":false,"pushed_at":"2024-10-02T12:23:56.000Z","size":94,"stargazers_count":22,"open_issues_count":1,"forks_count":4,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-10-20T21:00:03.979Z","etag":null,"topics":["api-client","embedding-vectors","machine-learning","milvus","ml","ruby","rubyml","search-engine","vector-search"],"latest_commit_sha":null,"homepage":"http://rubydoc.info/gems/milvus","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/patterns-ai-core.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-20T17:52:05.000Z","updated_at":"2024-10-19T15:04:41.000Z","dependencies_parsed_at":"2024-01-07T10:50:54.464Z","dependency_job_id":"700c03c1-3835-4c45-8038-6991e2f27907","html_url":"https://github.com/patterns-ai-core/milvus","commit_stats":null,"previous_names":["patterns-ai-core/milvus","andreibondarev/milvus"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patterns-ai-core%2Fmilvus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patterns-ai-core%2Fmilvus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patterns-ai-core%2Fmilvus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patterns-ai-core%2Fmilvus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patterns-ai-core","download_url":"https://codeload.github.com/patterns-ai-core/milvus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224262951,"owners_count":17282452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","embedding-vectors","machine-learning","milvus","ml","ruby","rubyml","search-engine","vector-search"],"created_at":"2024-08-01T21:00:35.621Z","updated_at":"2025-05-01T14:33:51.258Z","avatar_url":"https://github.com/patterns-ai-core.png","language":"Ruby","readme":"# Milvus\n\n\u003cp\u003e\n    \u003cimg alt='Milvus logo' src='https://milvus.io/images/milvus_logo.svg' height='50' /\u003e\n    \u0026nbsp;\u0026nbsp;\n    \u003cimg alt='Ruby logo' src='https://user-images.githubusercontent.com/541665/230231593-43861278-4550-421d-a543-fd3553aac4f6.png' height='40' /\u003e\n\u003c/p\u003e\n\nRuby wrapper for the Milvus vector search database API.\n\nPart of the [Langchain.rb](https://github.com/andreibondarev/langchainrb) stack.\n\nAvailable for paid consulting engagements! [Email me](mailto:andrei@sourcelabs.io).\n\n![Tests status](https://github.com/andreibondarev/milvus/actions/workflows/ci.yml/badge.svg)\n[![Gem Version](https://badge.fury.io/rb/milvus.svg)](https://badge.fury.io/rb/milvus)\n[![Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/gems/milvus)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/andreibondarev/milvus/blob/main/LICENSE.txt)\n[![](https://dcbadge.vercel.app/api/server/WDARp7J2n8?compact=true\u0026style=flat)](https://discord.gg/WDARp7J2n8)\n[![X](https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social\u0026label=Follow%20%40rushing_andrei)](https://twitter.com/rushing_andrei)\n\n## API Docs\nhttps://docs.zilliz.com/reference/restful/data-plane-v2\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n    $ bundle add milvus\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n    $ gem install milvus\n\n## Usage\n\n### Instantiating API client\n\n```ruby\nrequire 'milvus'\n\nclient = Milvus::Client.new(\n    url: 'http://localhost:19530'\n)\n```\n\n### Using the Collections endpoints\n```ruby\n# Check if the collection exists.\nclient.collections.has(collection_name: \"example_collection\")\n```\n```ruby\n# Rename a collection.\nclient.collections.rename(collection_name: \"example_collection\", new_collection_name: \"example_collection\")\n```\n```ruby\n# Get collection stats\nclient.collections.get_stats(collection_name: \"example_collection\")\n```\n\n```ruby\n# Data types: https://github.com/patterns-ai-core/milvus/blob/main/lib/milvus/constants.rb\n\n# Creating a new collection schema\nclient.collections.create(\n  collection_name: \"example_collection\",\n  auto_id: true,\n  fields: [\n    {\n      fieldName: \"book_id\",\n      isPrimary: true,\n      autoID: false,\n      dataType: \"Int64\"\n    },\n    {\n      fieldName: \"content\",\n      dataType: \"VarChar\",\n      elementTypeParams: {\n        max_length: \"512\"\n      }\n    },\n    {\n      fieldName: \"vector\",\n      dataType: \"FloatVector\",\n      elementTypeParams: {\n        dim: 1536\n      }\n    }\n  ]\n)\n```\n```ruby\n# Descrbie the collection\nclient.collections.describe(collection_name: \"example_collection\")\n```\n```ruby\n# Drop the collection\nclient.collections.drop(collection_name: \"example_collection\")\n```\n```ruby\n# Load the collection to memory before a search or a query\nclient.collections.load(collection_name: \"example_collection\")\n```\n```ruby\n# Load status of a specific collection.\nclient.collections.get_load_state(collection_name: \"example_collection\")\n```\n```ruby\n# List all collections in the specified database.\nclient.collections.list\n```\n```ruby\n# Release a collection from memory after a search or a query to reduce memory usage\nclient.collections.release(collection_name: \"example_collection\")\n```\n\n### Inserting Data\n```ruby\nclient.entities.insert(\n  collection_name: \"example_collection\",\n  data: [\n    { id: 1, content: \"The quick brown fox jumps over the lazy dog\", vector: ([0.1]*1536) },\n    { id: 2, content: \"Lorem ipsum dolor sit amet, consectetur adipiscing elit\", vector: ([0.2]*1536) },\n    { id: 3, content: \"Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua\", vector: ([0.3]*1536) }\n  ]  \n)\n```\n```ruby\n# Delete the entities with the boolean expression you created\nclient.entities.delete(\n  collection_name: \"example_collection\",\n  filter: \"book_id in [0,1]\"\n)\n```\n```ruby\n# Inserts new records into the database or updates existing ones.\nclient.entities.upsert()\n```\n```ruby\n# Get specific entities by their IDs\nclient.entities.get()\n```\n\n### Indexes\n```ruby\n# Create an index\nindex_params = [\n  {\n    metricType: \"L2\",\n    fieldName: \"vector\",\n    indexName: \"vector_idx\",\n    indexConfig: {\n      index_type: \"AUTOINDEX\"\n    }\n  }\n]\n\nclient.indexes.create(\n  collection_name: \"example_collection\",\n  index_params: index_params\n)\n```\n```ruby\n# Describe an index\nclient.indexes.describe(\n  collection_name: \"example_collection\",\n  index_name: \"example_index\"\n)\n```\n```ruby\n# List indexes\nclient.indexes.list(\n  collection_name: \"example_collection\"\n)\n```\n```ruby\n# Drop an index\nclient.indexes.drop(\n  collection_name: \"example_collection\",\n  index_name: \"example_index\"\n)\n```\n\n### Search, Querying \u0026 Hybrid Search\n```ruby\nclient.entities.search(\n  collection_name: \"example_collection\",\n  anns_field: \"vectors\",\n  data: [embedding],\n  # filter: \"id in [450847466900987454]\",\n  search_params: {\n    # Other accepted values: \"COSINE\" or \"IP\"\n    # NOTE: metric_type must be the same as metric type used when index was created\n    metric_type: \"L2\",\n    params: {\n      radius: 0.1, range_filter: 0.8\n    }\n  },\n)\n```\n```ruby\nclient.entities.query(\n  collection_name: \"example_collection\",\n  filter: \"id in [450847466900987455, 450847466900987454]\"\n)\n```\n```ruby\nclient.entities.hybrid_search(\n  collection_name: \"example_collection\",\n  search: [{\n    filter: \"id in [450847466900987455]\",\n    data: [embedding],\n    annsField: \"vectors\",\n    limit: 10,\n    outputFields: [\"content\", \"id\"]\n  }],\n  rerank: {\n    \"strategy\": \"rrf\",\n    \"params\": {\n      \"k\": 10\n    }\n  },\n  limit: 10,\n  output_fields: [\"content\", \"id\"]\n)\n```\n\n### Partitions\n```ruby\n# List partitions\nclient.partitions.list(\n  collection_name: \"example_collection\"\n)\n```\n```ruby\n# Create a partition\nclient.partitions.create(\n  collection_name: \"example_collection\",\n  partition_name: \"example_partition\"\n)\n```\n```ruby\n# Check if a partition exists\nclient.partitions.has(\n  collection_name: \"example_collection\",\n  partition_name: \"example_partition\"\n)\n```\n```ruby\n# Load partition data into memory\nclient.partitions.load(\n  collection_name: \"example_collection\",\n  partition_names: [\"example_partition\"]\n)\n```\n```ruby\n# Release partition data from memory\nclient.partitions.release(\n  collection_name: \"example_collection\",\n  partition_names: [\"example_partition\"]\n)\n```\n```ruby\n# Get statistics of a partition\nclient.partitions.get_stats(\n  collection_name: \"example_collection\",\n  partition_name: \"example_partition\"\n)\n```\n```ruby\n# Drop a partition\nclient.partitions.drop(\n  collection_name: \"example_collection\",\n  partition_name: \"example_partition\"\n)\n```\n\n### Roles\n```ruby\n# List roles available on the server\nclient.roles.list\n```\n```ruby\n# Describe the role\nclient.roles.describe(role_name: 'public')\n```\n\n### Users\n```ruby\n# Create new user\nclient.users.create(user_name: 'user_name', password: 'password')\n```\n```ruby\n# List of roles assigned to the user\nclient.users.describe(user_name: 'user_name')\n```\n```ruby\n# List all users in the specified database.\nclient.users.list\n```\n```ruby\n# Drop existing user\nclient.users.drop(user_name: 'user_name')\n```\n```ruby\n# Update password for the user\nclient.users.update_password(user_name: 'user_name', password: 'old_password', new_password: 'new_password')\n```\n```ruby\n# Grant role to the user\nclient.users.grant_role(user_name: 'user_name', role_name: 'admin')\n```\n```ruby\n# Revoke role from the user \nclient.users.revoke_role(user_name: 'user_name', role_name: 'admin')\n```\n### Aliases\n```ruby\n# Lists all existing collection aliases in the specified database\nclient.aliases.list\n```\n```ruby\n# Describes the details of a specific alias\nclient.aliases.describe\n```\n```ruby\n# Reassigns the alias of one collection to another.\nclient.aliases.alter\n```\n```ruby\n# Drops a specified alias\nclient.aliases.drop\n```\n```ruby\n# Creates an alias for an existing collection\nclient.aliases.create\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Development with Docker\n\nRun `docker compose run --rm ruby_app bash` and install required gems (`bundle install`). It will give you a fully working development environment with Milvus services and gem's code.\n\nFor example inside docker container run `bin/console` and inside the ruby console:\n```ruby\nclient = Milvus::Client.new(url: ENV[\"MILVUS_URL\"])\nclient.collections.list\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/patterns-ai-core/milvus.\n\n## License\n\n`milvus` is licensed under the Apache License, Version 2.0. View a copy of the License file.\n\n","funding_links":[],"categories":["Open Source","Ruby"],"sub_categories":["API Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatterns-ai-core%2Fmilvus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatterns-ai-core%2Fmilvus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatterns-ai-core%2Fmilvus/lists"}