Class: Milvus::Entities
Constant Summary collapse
- PATH =
"entities"
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#delete(collection_name:, filter:) ⇒ Hash
This operation deletes entities by their IDs or with a boolean expression.
-
#get(collection_name:, id:, output_fields: nil) ⇒ Hash
This operation gets specific entities by their IDs.
-
#hybrid_search(collection_name:, search:, rerank:, limit: nil, output_fields: []) ⇒ Hash
Executes a hybrid search.
-
#insert(collection_name:, data:, partition_name: nil) ⇒ Hash
This operation inserts data into a specific collection.
-
#query(collection_name:, filter:, output_fields: [], limit: nil) ⇒ Object
This operation conducts a filtering on the scalar field with a specified boolean expression.
-
#search(collection_name:, data:, anns_field:, filter: nil, limit: nil, offset: nil, grouping_field: nil, output_fields: [], search_params: {}, partition_names: []) ⇒ Hash
This operation conducts a vector similarity search with an optional scalar filtering expression.
-
#upsert(collection_name:, data:, partition_name: nil) ⇒ Hash
This operation inserts new records into the database or updates existing ones.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Milvus::Base
Instance Method Details
#delete(collection_name:, filter:) ⇒ Hash
This operation deletes entities by their IDs or with a boolean expression.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/milvus/entities.rb', line 34 def delete( collection_name:, filter: ) response = client.connection.post("#{PATH}/delete") do |req| req.body = { collectionName: collection_name, filter: filter } end response.body.empty? ? true : response.body end |
#get(collection_name:, id:, output_fields: nil) ⇒ Hash
This operation gets specific entities by their IDs
97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/milvus/entities.rb', line 97 def get( collection_name:, id:, output_fields: nil ) response = client.connection.post("#{PATH}/get") do |req| req.body = { collectionName: collection_name, id: id } req.body[:outputFields] = output_fields if output_fields end response.body.empty? ? true : response.body end |
#hybrid_search(collection_name:, search:, rerank:, limit: nil, output_fields: []) ⇒ Hash
Executes a hybrid search.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/milvus/entities.rb', line 161 def hybrid_search( collection_name:, search:, rerank:, limit: nil, output_fields: [] ) response = client.connection.post("#{PATH}/hybrid_search") do |req| params = { collectionName: collection_name, search: search, rerank: rerank } params[:limit] = limit if limit params[:outputFields] = output_fields if output_fields.any? req.body = params end response.body.empty? ? true : response.body end |
#insert(collection_name:, data:, partition_name: nil) ⇒ Hash
This operation inserts data into a specific collection.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/milvus/entities.rb', line 14 def insert( collection_name:, data:, partition_name: nil ) response = client.connection.post("#{PATH}/insert") do |req| req.body = { collectionName: collection_name, data: data } req.body[:partitionName] = partition_name if partition_name end response.body.empty? ? true : response.body end |
#query(collection_name:, filter:, output_fields: [], limit: nil) ⇒ Object
This operation conducts a filtering on the scalar field with a specified boolean expression.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/milvus/entities.rb', line 53 def query( collection_name:, filter:, output_fields: [], limit: nil ) response = client.connection.post("#{PATH}/query") do |req| req.body = { collectionName: collection_name, filter: filter } req.body[:outputFields] = output_fields if output_fields req.body[:limit] = limit if limit end response.body.empty? ? true : response.body end |
#search(collection_name:, data:, anns_field:, filter: nil, limit: nil, offset: nil, grouping_field: nil, output_fields: [], search_params: {}, partition_names: []) ⇒ Hash
This operation conducts a vector similarity search with an optional scalar filtering expression.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/milvus/entities.rb', line 122 def search( collection_name:, data:, anns_field:, filter: nil, limit: nil, offset: nil, grouping_field: nil, output_fields: [], search_params: {}, partition_names: [] ) response = client.connection.post("#{PATH}/search") do |req| params = { collectionName: collection_name, data: data, annsField: anns_field } params[:limit] = limit if limit params[:outputFields] = output_fields if output_fields.any? params[:offset] = offset if offset params[:filter] = filter if filter params[:searchParams] = search_params if search_params.any? params[:partitionNames] = partition_names if partition_names.any? params[:groupingField] = groupingField if grouping_field req.body = params end response.body.empty? ? true : response.body end |
#upsert(collection_name:, data:, partition_name: nil) ⇒ Hash
This operation inserts new records into the database or updates existing ones.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/milvus/entities.rb', line 76 def upsert( collection_name:, data:, partition_name: nil ) response = client.connection.post("#{PATH}/upsert") do |req| req.body = { collectionName: collection_name, data: data } req.body[:partitionName] = partition_name if partition_name end response.body.empty? ? true : response.body end |