Class: Milvus::Collections
Constant Summary collapse
- PATH =
"collections"
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#create(collection_name:, auto_id:, fields:) ⇒ Hash
Create a Collection.
-
#describe(collection_name:) ⇒ Hash
Describes the details of a collection.
-
#drop(collection_name:) ⇒ Hash
This operation drops the current collection and all data within the collection.
-
#get_load_state(collection_name:) ⇒ Hash
This operation returns the load status of a specific collection.
-
#get_stats(collection_name:) ⇒ Hash
This operation gets the number of entities in a collection.
-
#has(collection_name:) ⇒ Hash
This operation checks whether a collection exists.
-
#list ⇒ Hash
This operation lists all collections in the specified database.
-
#load(collection_name:) ⇒ Hash
Load the collection to memory before a search or a query.
-
#release(collection_name:) ⇒ Hash
Release a collection from memory after a search or a query to reduce memory usage.
-
#rename(collection_name:, new_collection_name:) ⇒ Hash
This operation renames an existing collection and optionally moves the collection to a new database.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Milvus::Base
Instance Method Details
#create(collection_name:, auto_id:, fields:) ⇒ Hash
Create a Collection
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/milvus/collections.rb', line 55 def create( collection_name:, auto_id:, fields: ) response = client.connection.post("#{PATH}/create") do |req| req.body = { collectionName: collection_name, schema: { autoId: auto_id, fields: fields, name: collection_name # This duplicated field is kept for historical reasons. } } end response.body.empty? ? true : response.body end |
#describe(collection_name:) ⇒ Hash
Describes the details of a collection.
77 78 79 80 81 82 83 84 |
# File 'lib/milvus/collections.rb', line 77 def describe(collection_name:) response = client.connection.post("#{PATH}/describe") do |req| req.body = { collectionName: collection_name } end response.body end |
#drop(collection_name:) ⇒ Hash
This operation drops the current collection and all data within the collection.
100 101 102 103 104 105 106 107 |
# File 'lib/milvus/collections.rb', line 100 def drop(collection_name:) response = client.connection.post("#{PATH}/drop") do |req| req.body = { collectionName: collection_name } end response.body.empty? ? true : response.body end |
#get_load_state(collection_name:) ⇒ Hash
This operation returns the load status of a specific collection.
126 127 128 129 130 131 132 133 |
# File 'lib/milvus/collections.rb', line 126 def get_load_state(collection_name:) response = client.connection.post("#{PATH}/get_load_state") do |req| req.body = { collectionName: collection_name } end response.body end |
#get_stats(collection_name:) ⇒ Hash
This operation gets the number of entities in a collection.
39 40 41 42 43 44 45 46 |
# File 'lib/milvus/collections.rb', line 39 def get_stats(collection_name:) response = client.connection.post("#{PATH}/get_stats") do |req| req.body = { collectionName: collection_name } end response.body end |
#has(collection_name:) ⇒ Hash
This operation checks whether a collection exists.
11 12 13 14 15 16 17 18 |
# File 'lib/milvus/collections.rb', line 11 def has(collection_name:) response = client.connection.post("#{PATH}/has") do |req| req.body = { collectionName: collection_name } end response.body end |
#list ⇒ Hash
This operation lists all collections in the specified database.
89 90 91 92 93 94 |
# File 'lib/milvus/collections.rb', line 89 def list response = client.connection.post("#{PATH}/list") do |req| req.body = {} end response.body end |
#load(collection_name:) ⇒ Hash
Load the collection to memory before a search or a query
113 114 115 116 117 118 119 120 |
# File 'lib/milvus/collections.rb', line 113 def load(collection_name:) response = client.connection.post("#{PATH}/load") do |req| req.body = { collectionName: collection_name } end response.body.empty? ? true : response.body end |
#release(collection_name:) ⇒ Hash
Release a collection from memory after a search or a query to reduce memory usage
139 140 141 142 143 144 145 146 |
# File 'lib/milvus/collections.rb', line 139 def release(collection_name:) response = client.connection.post("#{PATH}/release") do |req| req.body = { collectionName: collection_name } end response.body.empty? ? true : response.body end |
#rename(collection_name:, new_collection_name:) ⇒ Hash
This operation renames an existing collection and optionally moves the collection to a new database.
25 26 27 28 29 30 31 32 33 |
# File 'lib/milvus/collections.rb', line 25 def rename(collection_name:, new_collection_name:) response = client.connection.post("#{PATH}/rename") do |req| req.body = { collectionName: collection_name, newCollectionName: new_collection_name } end response.body.empty? ? true : response.body end |