milvus 0.10.0 β†’ 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4333b7321ee1e40f8f390692f6e25ce991837cd6b51bf6dfb4eef48fcfc826e9
4
- data.tar.gz: c84d6a7f8be503c0009676a0d659d43bc5e443442f49a9bc6d96824da5904579
3
+ metadata.gz: 0a4dd23dd2d85a1a231214808ee57ece287c47fde46084f726831dc47e7aaed7
4
+ data.tar.gz: 52bca3e02f864a52c5c85c9f1aa725a16641fedaafb4b5ed8a7c6964664b9fe8
5
5
  SHA512:
6
- metadata.gz: 2fffcbee8f0596ab3b65d12992a6323518a1a9ee1cb5c6c5d8437bbabcfa123acc8c777a189932fdc1be1b9b283c14f449e29dab27dc6b23d5c0dc7f333c3a42
7
- data.tar.gz: a6d589ffa1c4e2b1e95eb74d1a089727a51adfdd265e852db52bf0558baeceb3f8e78b3fd53133efffce212c683bc38a5dc54bb5b0cc6662e32c74180ca7b4db
6
+ metadata.gz: 3c60bf9de09afaebc7cf0382529b07440680f50ed5f94c8ededb416f8cf29ddbaa7183527235c5daa12ce37412ca9b2b822e0b871d70fb67101ab291eb62c305
7
+ data.tar.gz: 7b5b2b34f19ee53b33e025f6e9c170584fcf4b86c647e79c6acf519b0a3560e3b68f02fbcc60bdaafd27e41165704cf07dfdc1f4a52ddee198327ca7f8cd0278
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.10.1] - 2024-07-04 πŸ‡ΊπŸ‡Έ
4
+ - Fixes and improvements to the gem.
5
+
3
6
  ## [0.10.0] - 2024-07-04 πŸ‡ΊπŸ‡Έ
4
7
  - BREAKING: Switched the gem to use newer V2 API with different endpoints and corresponding endpoints.
5
8
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- milvus (0.10.0)
4
+ milvus (0.10.1)
5
5
  faraday (>= 2.0.1, < 3)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -47,17 +47,15 @@ client = Milvus::Client.new(
47
47
  ### Using the Collections endpoints
48
48
  ```ruby
49
49
  # Check if the collection exists.
50
- client.collections.has(collection_name: "book")
50
+ client.collections.has(collection_name: "example_collection")
51
51
  ```
52
-
53
52
  ```ruby
54
53
  # Rename a collection.
55
- client.collections.rename(collection_name: "book", new_collection_name: "note")
54
+ client.collections.rename(collection_name: "example_collection", new_collection_name: "example_collection")
56
55
  ```
57
-
58
56
  ```ruby
59
57
  # Get collection stats
60
- client.collections.get_stats(collection_name: "book")
58
+ client.collections.get_stats(collection_name: "example_collection")
61
59
  ```
62
60
 
63
61
  ```ruby
@@ -65,30 +63,27 @@ client.collections.get_stats(collection_name: "book")
65
63
 
66
64
  # Creating a new collection schema
67
65
  client.collections.create(
68
- collection_name: "book",
69
- description: "Test book search",
70
- auto_id: false,
66
+ collection_name: "example_collection",
67
+ auto_id: true,
71
68
  fields: [
72
69
  {
73
- "fieldName": "book_id",
74
- "description": "book id",
75
- "isPrimary": true,
76
- "autoID": false,
77
- "dataType": "Int64"
70
+ fieldName: "book_id",
71
+ isPrimary: true,
72
+ autoID: false,
73
+ dataType: "Int64"
78
74
  },
79
75
  {
80
- "fieldName": "word_count",
81
- "description": "count of words",
82
- "isPrimary": false,
83
- "dataType": "Int64"
76
+ fieldName: "content",
77
+ dataType: "VarChar",
78
+ elementTypeParams: {
79
+ max_length: "512"
80
+ }
84
81
  },
85
82
  {
86
- "fieldName": "book_intro",
87
- "description": "embedded vector of book introduction",
88
- "dataType": "FloatVector",
89
- "isPrimary": false,
90
- "elementTypeParams": {
91
- "dim": "2"
83
+ fieldName: "vector",
84
+ dataType: "FloatVector",
85
+ elementTypeParams: {
86
+ dim: 1536
92
87
  }
93
88
  }
94
89
  ]
@@ -96,15 +91,19 @@ client.collections.create(
96
91
  ```
97
92
  ```ruby
98
93
  # Descrbie the collection
99
- client.collections.describe(collection_name: "book")
94
+ client.collections.describe(collection_name: "example_collection")
100
95
  ```
101
96
  ```ruby
102
97
  # Drop the collection
103
- client.collections.drop(collection_name: "book")
98
+ client.collections.drop(collection_name: "example_collection")
104
99
  ```
105
100
  ```ruby
106
101
  # Load the collection to memory before a search or a query
107
- client.collections.load(collection_name: "book")
102
+ client.collections.load(collection_name: "example_collection")
103
+ ```
104
+ ```ruby
105
+ # Load status of a specific collection.
106
+ client.collections.get_load_state(collection_name: "example_collection")
108
107
  ```
109
108
  ```ruby
110
109
  # List all collections in the specified database.
@@ -112,64 +111,49 @@ client.collections.list
112
111
  ```
113
112
  ```ruby
114
113
  # Release a collection from memory after a search or a query to reduce memory usage
115
- client.collections.release(collection_name: "book")
114
+ client.collections.release(collection_name: "example_collection")
116
115
  ```
117
116
 
118
117
  ### Inserting Data
119
118
  ```ruby
120
119
  client.entities.insert(
121
- collection_name: "book",
122
- num_rows: 5, # Number of rows to be inserted. The number should be the same as the length of each field array.
123
- fields_data: [
124
- {
125
- "field_name": "book_id",
126
- "type": Milvus::DATA_TYPES["int64"],
127
- "field": [1,2,3,4,5]
128
- },
129
- {
130
- "field_name": "word_count",
131
- "type": Milvus::DATA_TYPES["int64"],
132
- "field": [1000,2000,3000,4000,5000]
133
- },
134
- {
135
- "field_name": "book_intro",
136
- "type": 101,
137
- "field": [ [1,1],[2,1],[3,1],[4,1],[5,1] ]
138
- }
120
+ collection_name: "example_collection",
121
+ data: [
122
+ { id: 1, content: "The quick brown fox jumps over the lazy dog", vector: ([0.1]*1536) },
123
+ { id: 2, content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit", vector: ([0.2]*1536) },
124
+ { id: 3, content: "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua", vector: ([0.3]*1536) }
139
125
  ]
140
126
  )
141
127
  ```
142
128
  ```ruby
143
129
  # Delete the entities with the boolean expression you created
144
130
  client.entities.delete(
145
- collection_name: "book",
131
+ collection_name: "example_collection",
146
132
  expression: "book_id in [0,1]"
147
133
  )
148
134
  ```
149
135
  ```ruby
150
- # Compact data manually
151
- client.entities.compact!(
152
- collection_id: "book"
153
- )
154
- # => {"status"=>{}, "compactionID"=>440928616022809499}
136
+ # Inserts new records into the database or updates existing ones.
137
+ client.entities.upsert()
155
138
  ```
156
139
  ```ruby
157
- # Check compaction status
158
- client.entities.compact_status(
159
- compaction_id: 440928616022809499
160
- )
161
- # => {"status"=>{}, "state"=>2}
140
+ # Get specific entities by their IDs
141
+ client.entities.get()
162
142
  ```
163
143
 
164
144
  ### Indexes
165
145
  ```ruby
166
146
  # Create an index
167
- index_params = {
168
- fieldName: "example_field",
169
- indexType: "IVF_FLAT",
170
- metricType: "L2",
171
- params: { nlist: 100 }
172
- }
147
+ index_params = [
148
+ {
149
+ metricType: "L2",
150
+ fieldName: "vector",
151
+ indexName: "vector_idx",
152
+ indexConfig: {
153
+ index_type: "AUTOINDEX"
154
+ }
155
+ }
156
+ ]
173
157
 
174
158
  client.indexes.create(
175
159
  collection_name: "example_collection",
@@ -200,7 +184,7 @@ client.indexes.drop(
200
184
  ### Search, Querying & Hybrid Search
201
185
  ```ruby
202
186
  client.entities.search(
203
- collection_name: "recipes",
187
+ collection_name: "example_collection",
204
188
  anns_field: "vectors",
205
189
  data: [embedding],
206
190
  filter: "id in [450847466900987454]"
@@ -208,13 +192,13 @@ client.entities.search(
208
192
  ```
209
193
  ```ruby
210
194
  client.entities.query(
211
- collection_name: "recipes",
195
+ collection_name: "example_collection",
212
196
  filter: "id in [450847466900987455, 450847466900987454]"
213
197
  )
214
198
  ```
215
199
  ```ruby
216
200
  client.entities.hybrid_search(
217
- collection_name: "recipes",
201
+ collection_name: "example_collection",
218
202
  search: [{
219
203
  filter: "id in [450847466900987455]",
220
204
  data: [embedding],
@@ -12,7 +12,7 @@ module Milvus
12
12
  response = client.connection.post("#{PATH}/has") do |req|
13
13
  req.body = {
14
14
  collectionName: collection_name
15
- }.to_json
15
+ }
16
16
  end
17
17
  response.body
18
18
  end
@@ -40,7 +40,7 @@ module Milvus
40
40
  response = client.connection.post("#{PATH}/get_stats") do |req|
41
41
  req.body = {
42
42
  collectionName: collection_name
43
- }.to_json
43
+ }
44
44
  end
45
45
  response.body
46
46
  end
@@ -55,7 +55,6 @@ module Milvus
55
55
  def create(
56
56
  collection_name:,
57
57
  auto_id:,
58
- description:,
59
58
  fields:
60
59
  )
61
60
  response = client.connection.post("#{PATH}/create") do |req|
@@ -63,11 +62,10 @@ module Milvus
63
62
  collectionName: collection_name,
64
63
  schema: {
65
64
  autoId: auto_id,
66
- description: description,
67
65
  fields: fields,
68
66
  name: collection_name # This duplicated field is kept for historical reasons.
69
67
  }
70
- }.to_json
68
+ }
71
69
  end
72
70
  response.body.empty? ? true : response.body
73
71
  end
@@ -80,7 +78,7 @@ module Milvus
80
78
  response = client.connection.post("#{PATH}/describe") do |req|
81
79
  req.body = {
82
80
  collectionName: collection_name
83
- }.to_json
81
+ }
84
82
  end
85
83
  response.body
86
84
  end
@@ -103,7 +101,7 @@ module Milvus
103
101
  response = client.connection.post("#{PATH}/drop") do |req|
104
102
  req.body = {
105
103
  collectionName: collection_name
106
- }.to_json
104
+ }
107
105
  end
108
106
  response.body.empty? ? true : response.body
109
107
  end
@@ -142,7 +140,7 @@ module Milvus
142
140
  response = client.connection.post("#{PATH}/release") do |req|
143
141
  req.body = {
144
142
  collectionName: collection_name
145
- }.to_json
143
+ }
146
144
  end
147
145
  response.body.empty? ? true : response.body
148
146
  end
@@ -2,22 +2,21 @@
2
2
 
3
3
  module Milvus
4
4
  # https://milvus.io/api-reference/pymilvus/v2.4.x/MilvusClient/Collections/DataType.md
5
- DATA_TYPES = {
6
- "boolean" => 1,
7
- "int8" => 2,
8
- "int16" => 3,
9
- "int32" => 4,
10
- "int64" => 5,
11
- "float" => 10,
12
- "double" => 11,
13
- "string" => 20,
14
- "varchar" => 21,
15
- "array" => 22,
16
- "json" => 23,
17
- "binary_vector" => 100,
18
- "float_vector" => 101,
19
- "float16_vector" => 102,
20
- "bfloat16_vector" => 103,
21
- "sparse_float_vector" => 104
22
- }.freeze
5
+ DATA_TYPES = [
6
+ "Boolean",
7
+ "Int8",
8
+ "Int16",
9
+ "Int32",
10
+ "Int64",
11
+ "Float",
12
+ "Double",
13
+ "VarChar",
14
+ "Array",
15
+ "Json",
16
+ "BinaryVector",
17
+ "FloatVector",
18
+ "Float16Vector",
19
+ "BFloat16Vector",
20
+ "SparseFloatVector"
21
+ ].freeze
23
22
  end
@@ -21,7 +21,6 @@ module Milvus
21
21
  collectionName: collection_name,
22
22
  data: data
23
23
  }
24
-
25
24
  req.body[:partitionName] = partition_name if partition_name
26
25
  end
27
26
  response.body.empty? ? true : response.body
@@ -40,7 +39,7 @@ module Milvus
40
39
  req.body = {
41
40
  collectionName: collection_name,
42
41
  filter: filter
43
- }.to_json
42
+ }
44
43
  end
45
44
  response.body.empty? ? true : response.body
46
45
  end
@@ -84,7 +83,6 @@ module Milvus
84
83
  collectionName: collection_name,
85
84
  data: data
86
85
  }
87
-
88
86
  req.body[:partitionName] = partition_name if partition_name
89
87
  end
90
88
  response.body.empty? ? true : response.body
@@ -17,7 +17,7 @@ module Milvus
17
17
  req.body = {
18
18
  collectionName: collection_name,
19
19
  indexParams: index_params
20
- }.to_json
20
+ }
21
21
  end
22
22
  response.body.empty? ? true : response.body
23
23
  end
@@ -35,7 +35,7 @@ module Milvus
35
35
  req.body = {
36
36
  collectionName: collection_name,
37
37
  indexName: index_name
38
- }.to_json
38
+ }
39
39
  end
40
40
  response.body.empty? ? true : response.body
41
41
  end
@@ -53,7 +53,7 @@ module Milvus
53
53
  req.body = {
54
54
  collectionName: collection_name,
55
55
  indexName: index_name
56
- }.to_json
56
+ }
57
57
  end
58
58
  response.body.empty? ? true : response.body
59
59
  end
@@ -68,7 +68,7 @@ module Milvus
68
68
  response = client.connection.post("#{PATH}/list") do |req|
69
69
  req.body = {
70
70
  collectionName: collection_name
71
- }.to_json
71
+ }
72
72
  end
73
73
  response.body.empty? ? true : response.body
74
74
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Milvus
4
- VERSION = "0.10.0"
4
+ VERSION = "0.10.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: milvus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Bondarev