milvus 0.10.0 β 0.10.1
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +49 -65
- data/lib/milvus/collections.rb +6 -8
- data/lib/milvus/constants.rb +17 -18
- data/lib/milvus/entities.rb +1 -3
- data/lib/milvus/indexes.rb +4 -4
- data/lib/milvus/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a4dd23dd2d85a1a231214808ee57ece287c47fde46084f726831dc47e7aaed7
|
4
|
+
data.tar.gz: 52bca3e02f864a52c5c85c9f1aa725a16641fedaafb4b5ed8a7c6964664b9fe8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c60bf9de09afaebc7cf0382529b07440680f50ed5f94c8ededb416f8cf29ddbaa7183527235c5daa12ce37412ca9b2b822e0b871d70fb67101ab291eb62c305
|
7
|
+
data.tar.gz: 7b5b2b34f19ee53b33e025f6e9c170584fcf4b86c647e79c6acf519b0a3560e3b68f02fbcc60bdaafd27e41165704cf07dfdc1f4a52ddee198327ca7f8cd0278
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
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: "
|
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: "
|
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: "
|
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: "
|
69
|
-
|
70
|
-
auto_id: false,
|
66
|
+
collection_name: "example_collection",
|
67
|
+
auto_id: true,
|
71
68
|
fields: [
|
72
69
|
{
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
"
|
77
|
-
"dataType": "Int64"
|
70
|
+
fieldName: "book_id",
|
71
|
+
isPrimary: true,
|
72
|
+
autoID: false,
|
73
|
+
dataType: "Int64"
|
78
74
|
},
|
79
75
|
{
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
76
|
+
fieldName: "content",
|
77
|
+
dataType: "VarChar",
|
78
|
+
elementTypeParams: {
|
79
|
+
max_length: "512"
|
80
|
+
}
|
84
81
|
},
|
85
82
|
{
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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: "
|
94
|
+
client.collections.describe(collection_name: "example_collection")
|
100
95
|
```
|
101
96
|
```ruby
|
102
97
|
# Drop the collection
|
103
|
-
client.collections.drop(collection_name: "
|
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: "
|
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: "
|
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: "
|
122
|
-
|
123
|
-
|
124
|
-
{
|
125
|
-
|
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: "
|
131
|
+
collection_name: "example_collection",
|
146
132
|
expression: "book_id in [0,1]"
|
147
133
|
)
|
148
134
|
```
|
149
135
|
```ruby
|
150
|
-
#
|
151
|
-
client.entities.
|
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
|
-
#
|
158
|
-
client.entities.
|
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
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
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: "
|
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: "
|
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: "
|
201
|
+
collection_name: "example_collection",
|
218
202
|
search: [{
|
219
203
|
filter: "id in [450847466900987455]",
|
220
204
|
data: [embedding],
|
data/lib/milvus/collections.rb
CHANGED
@@ -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
|
-
}
|
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
|
-
}
|
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
|
-
}
|
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
|
-
}
|
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
|
-
}
|
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
|
-
}
|
143
|
+
}
|
146
144
|
end
|
147
145
|
response.body.empty? ? true : response.body
|
148
146
|
end
|
data/lib/milvus/constants.rb
CHANGED
@@ -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
|
-
"
|
7
|
-
"
|
8
|
-
"
|
9
|
-
"
|
10
|
-
"
|
11
|
-
"
|
12
|
-
"
|
13
|
-
"
|
14
|
-
"
|
15
|
-
"
|
16
|
-
"
|
17
|
-
"
|
18
|
-
"
|
19
|
-
"
|
20
|
-
"
|
21
|
-
|
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
|
data/lib/milvus/entities.rb
CHANGED
@@ -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
|
-
}
|
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
|
data/lib/milvus/indexes.rb
CHANGED
@@ -17,7 +17,7 @@ module Milvus
|
|
17
17
|
req.body = {
|
18
18
|
collectionName: collection_name,
|
19
19
|
indexParams: index_params
|
20
|
-
}
|
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
|
-
}
|
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
|
-
}
|
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
|
-
}
|
71
|
+
}
|
72
72
|
end
|
73
73
|
response.body.empty? ? true : response.body
|
74
74
|
end
|
data/lib/milvus/version.rb
CHANGED