milvus 0.10.2 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c38f7235b815b1f48dd2d61e445b99ca675f974d1dddeba02796bf02e353fdd1
4
- data.tar.gz: 4af6a551675f63cb17ee6f2c80a8ca000ea98ff028eeefa71f9593061ac04969
3
+ metadata.gz: 3a102d183738bf441d38553fc3943694001a7ecb982eb901f29ee79c4469c2ee
4
+ data.tar.gz: cb74c717b5a8e3139008898f49564a1310d31dd769f6a7d46df1d0ffa2319c2e
5
5
  SHA512:
6
- metadata.gz: 37d2666740b3e9df096e5f8b024a72fff37b60c53810f8dcbd5f0b14c4a008060d5cad78109664b74d7e2e76d21c8559cbb6c079b046032acd09491c5a3c3109
7
- data.tar.gz: 7c10d887561876c02e6f869807b01c339b2412137e3cefb584ce5451da815eafec06f5c4ea83bbd231862b9742aad08d711566a2660193016b9eb809eca7798b
6
+ metadata.gz: a7a999cfca2e7e1b4b07409d3d84cca940feb6a7a18d1648f780414c5d9f5d1c9cdf9fd199c93daddae7986b923cfafc0add8e7ca325dc69c94310115de19bc4
7
+ data.tar.gz: 97cb86b1f045c9cb19cad3a42d827bd1eafff9e7036970c2b6ce3cc6e457fba519afbb1ba68bf4c7f40b90d4e64c0a41e0bd75a8954dd87dd59603f5cad33c89
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.10.4] - 2024-11-14
4
+ - `client.entities.search()` now accepts `search_params: {}`
5
+
6
+ ## [0.10.3] - 2024-10-01
7
+ - Milvus::Client constructor accepts customer logger: to be passed in
8
+ - Added Alias management
9
+
3
10
  ## [0.10.2] - 2024-07-28
4
11
  - Added Roles management
5
12
  - Added Users management
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- milvus (0.10.2)
4
+ milvus (0.10.4)
5
5
  faraday (>= 2.0.1, < 3)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -22,11 +22,6 @@ Available for paid consulting engagements! [Email me](mailto:andrei@sourcelabs.i
22
22
  ## API Docs
23
23
  https://docs.zilliz.com/reference/restful/data-plane-v2
24
24
 
25
- ## TODOs
26
- - [X] Support for [User endpoints](https://docs.zilliz.com/reference/restful/user-operations-v2)
27
- - [X] Support for [Role endpoints](https://docs.zilliz.com/reference/restful/role-operations-v2)
28
- - [ ] Support for [Alias endpoints](https://docs.zilliz.com/reference/restful/alias-operations-v2)
29
-
30
25
  ## Installation
31
26
 
32
27
  Install the gem and add to the application's Gemfile by executing:
@@ -134,7 +129,7 @@ client.entities.insert(
134
129
  # Delete the entities with the boolean expression you created
135
130
  client.entities.delete(
136
131
  collection_name: "example_collection",
137
- expression: "book_id in [0,1]"
132
+ filter: "book_id in [0,1]"
138
133
  )
139
134
  ```
140
135
  ```ruby
@@ -192,7 +187,15 @@ client.entities.search(
192
187
  collection_name: "example_collection",
193
188
  anns_field: "vectors",
194
189
  data: [embedding],
195
- filter: "id in [450847466900987454]"
190
+ # filter: "id in [450847466900987454]",
191
+ search_params: {
192
+ # Other accepted values: "COSINE" or "IP"
193
+ # NOTE: metric_type must be the same as metric type used when index was created
194
+ metric_type: "L2",
195
+ params: {
196
+ radius: 0.1, range_filter: 0.8
197
+ }
198
+ },
196
199
  )
197
200
  ```
198
201
  ```ruby
@@ -311,6 +314,27 @@ client.users.grant_role(user_name: 'user_name', role_name: 'admin')
311
314
  # Revoke role from the user
312
315
  client.users.revoke_role(user_name: 'user_name', role_name: 'admin')
313
316
  ```
317
+ ### Aliases
318
+ ```ruby
319
+ # Lists all existing collection aliases in the specified database
320
+ client.aliases.list
321
+ ```
322
+ ```ruby
323
+ # Describes the details of a specific alias
324
+ client.aliases.describe
325
+ ```
326
+ ```ruby
327
+ # Reassigns the alias of one collection to another.
328
+ client.aliases.alter
329
+ ```
330
+ ```ruby
331
+ # Drops a specified alias
332
+ client.aliases.drop
333
+ ```
334
+ ```ruby
335
+ # Creates an alias for an existing collection
336
+ client.aliases.create
337
+ ```
314
338
 
315
339
  ## Development
316
340
 
@@ -320,7 +344,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
320
344
 
321
345
  ## Development with Docker
322
346
 
323
- Run `docker compose run --rm ruby_app bash` and install required gems (`bundle install`). It will give you a fully working development environment with Milvius services and gem's code.
347
+ Run `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.
324
348
 
325
349
  For example inside docker container run `bin/console` and inside the ruby console:
326
350
  ```ruby
@@ -0,0 +1,78 @@
1
+ # https://docs.zilliz.com/reference/restful/alias-operations-v2
2
+
3
+ module Milvus
4
+ class Aliases < Base
5
+ PATH = "aliases"
6
+
7
+ # Lists available roles on the server
8
+ #
9
+ # @return [Hash] The response from the server
10
+ def list
11
+ response = client.connection.post("#{PATH}/list") do |req|
12
+ req.body = {}
13
+ end
14
+
15
+ response.body
16
+ end
17
+
18
+ # Describes the details of a specific alias
19
+ #
20
+ # @param alias_name [String] The name of the alias to describe
21
+ # @return [Hash] The response from the server
22
+ def describe(alias_name:)
23
+ response = client.connection.post("#{PATH}/describe") do |req|
24
+ req.body = {
25
+ aliasName: alias_name
26
+ }
27
+ end
28
+
29
+ response.body
30
+ end
31
+
32
+ # Reassigns the alias of one collection to another
33
+ #
34
+ # @param alias_name [String] The alias of the collection
35
+ # @param collection_name [String] The name of the target collection to reassign an alias to
36
+ # @return [Hash] The response from the server
37
+ def alter(alias_name:, collection_name:)
38
+ response = client.connection.post("#{PATH}/alter") do |req|
39
+ req.body = {
40
+ aliasName: alias_name,
41
+ collectionName: collection_name
42
+ }
43
+ end
44
+
45
+ response.body
46
+ end
47
+
48
+ # This operation drops a specified alias
49
+ #
50
+ # @param alias_name [String] The alias to drop
51
+ # @return [Hash] The response from the server
52
+ def drop(alias_name:)
53
+ response = client.connection.post("#{PATH}/drop") do |req|
54
+ req.body = {
55
+ aliasName: alias_name
56
+ }
57
+ end
58
+
59
+ response.body
60
+ end
61
+
62
+ # This operation creates an alias for an existing collection. A collection can have multiple aliases, while an alias can be associated with only one collection.
63
+ #
64
+ # @param alias_name [String] The alias of the collection
65
+ # @param collection_name [String] The name of the target collection to reassign an alias to
66
+ # @return [Hash] The response from the server
67
+ def create(alias_name:, collection_name:)
68
+ response = client.connection.post("#{PATH}/create") do |req|
69
+ req.body = {
70
+ aliasName: alias_name,
71
+ collectionName: collection_name
72
+ }
73
+ end
74
+
75
+ response.body
76
+ end
77
+ end
78
+ end
data/lib/milvus/client.rb CHANGED
@@ -4,13 +4,22 @@ require "faraday"
4
4
 
5
5
  module Milvus
6
6
  class Client
7
- attr_reader :url, :api_key
7
+ attr_reader :url, :api_key, :adapter, :raise_error, :logger
8
8
 
9
9
  API_VERSION = "v2/vectordb"
10
10
 
11
- def initialize(url:, api_key: nil)
11
+ def initialize(
12
+ url:,
13
+ api_key: nil,
14
+ adapter: Faraday.default_adapter,
15
+ raise_error: false,
16
+ logger: nil
17
+ )
12
18
  @url = url
13
19
  @api_key = api_key
20
+ @adapter = adapter
21
+ @raise_error = raise_error
22
+ @logger = logger || Logger.new($stdout)
14
23
  end
15
24
 
16
25
  def collections
@@ -37,14 +46,20 @@ module Milvus
37
46
  @users ||= Milvus::Users.new(client: self)
38
47
  end
39
48
 
49
+ def aliases
50
+ @aliases ||= Milvus::Aliases.new(client: self)
51
+ end
52
+
40
53
  def connection
41
54
  @connection ||= Faraday.new(url: "#{url}/#{API_VERSION}/") do |faraday|
42
55
  if api_key
43
56
  faraday.request :authorization, :Bearer, api_key
44
57
  end
45
58
  faraday.request :json
59
+ faraday.response :logger, logger, {headers: true, bodies: true, errors: true}
60
+ faraday.response :raise_error if raise_error
46
61
  faraday.response :json, content_type: /\bjson$/
47
- faraday.adapter Faraday.default_adapter
62
+ faraday.adapter adapter
48
63
  end
49
64
  end
50
65
  end
@@ -123,10 +123,13 @@ module Milvus
123
123
  collection_name:,
124
124
  data:,
125
125
  anns_field:,
126
+ filter: nil,
126
127
  limit: nil,
127
- output_fields: [],
128
128
  offset: nil,
129
- filter: nil
129
+ grouping_field: nil,
130
+ output_fields: [],
131
+ search_params: {},
132
+ partition_names: []
130
133
  )
131
134
  response = client.connection.post("#{PATH}/search") do |req|
132
135
  params = {
@@ -138,6 +141,10 @@ module Milvus
138
141
  params[:outputFields] = output_fields if output_fields.any?
139
142
  params[:offset] = offset if offset
140
143
  params[:filter] = filter if filter
144
+ params[:searchParams] = search_params if search_params.any?
145
+ params[:partitionNames] = partition_names if partition_names.any?
146
+ params[:groupingField] = groupingField if grouping_field
147
+
141
148
  req.body = params
142
149
  end
143
150
  response.body.empty? ? true : response.body
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Milvus
4
- VERSION = "0.10.2"
4
+ VERSION = "0.10.4"
5
5
  end
data/lib/milvus.rb CHANGED
@@ -13,4 +13,5 @@ module Milvus
13
13
  autoload :Partitions, "milvus/partitions"
14
14
  autoload :Roles, "milvus/roles"
15
15
  autoload :Users, "milvus/users"
16
+ autoload :Aliases, "milvus/aliases"
16
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: milvus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.10.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Bondarev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-28 00:00:00.000000000 Z
11
+ date: 2024-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry-byebug
@@ -62,6 +62,7 @@ files:
62
62
  - Rakefile
63
63
  - docker-compose.yml
64
64
  - lib/milvus.rb
65
+ - lib/milvus/aliases.rb
65
66
  - lib/milvus/base.rb
66
67
  - lib/milvus/client.rb
67
68
  - lib/milvus/collections.rb
@@ -96,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
97
  - !ruby/object:Gem::Version
97
98
  version: '0'
98
99
  requirements: []
99
- rubygems_version: 3.5.14
100
+ rubygems_version: 3.5.20
100
101
  signing_key:
101
102
  specification_version: 4
102
103
  summary: Ruby wrapper for the Milvus vector search database API