weaviate-ruby 0.4.0 → 0.5.0
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/Gemfile.lock +1 -1
- data/README.md +50 -2
- data/lib/weaviate/backups.rb +54 -0
- data/lib/weaviate/classifications.rb +35 -0
- data/lib/weaviate/client.rb +8 -0
- data/lib/weaviate/objects.rb +24 -0
- data/lib/weaviate/version.rb +1 -1
- data/lib/weaviate.rb +2 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7188f7ab1cb378b6ffecf86e173bcfd2d6f513cd004559d18cfa011d8c2f9407
|
4
|
+
data.tar.gz: fd07382e798c763a27adbce3543d224bfed059a2035625569a5247e83d11f598
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cb63f9f341edb1acdc580f3fab0e27190221400183c9191590d4ed7e2d08f3d48ce01167381885e3cbdda894cd0cb32c1c418a2827e2625a2a16d26306395ee
|
7
|
+
data.tar.gz: 17aa43b9a7f42b063a3e5f148a697481ea3b73bfc6dc62c7b6ab101cc24d30d8d78e4e501b3e414e6bf6ef6f73d94914df211f0025aac0f1c8d5b0fe599a1a6e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -134,6 +134,16 @@ response = client.objects.batch_create(objects: [
|
|
134
134
|
}
|
135
135
|
])
|
136
136
|
response.data
|
137
|
+
|
138
|
+
# Batch delete objects
|
139
|
+
client.objects.batch_delete(
|
140
|
+
class_name: "Question",
|
141
|
+
where: {
|
142
|
+
valueString: "1",
|
143
|
+
operator: "Equal",
|
144
|
+
path: ["id"]
|
145
|
+
}
|
146
|
+
)
|
137
147
|
```
|
138
148
|
|
139
149
|
### Querying
|
@@ -187,12 +197,50 @@ client.query.aggs(
|
|
187
197
|
)
|
188
198
|
```
|
189
199
|
|
190
|
-
|
200
|
+
### Classification
|
201
|
+
```ruby
|
202
|
+
client.classifications.create(
|
203
|
+
type: "zeroshot",
|
204
|
+
class_name: "Posts",
|
205
|
+
classify_properties: ["hasColor"],
|
206
|
+
based_on_properties: ["text"]
|
207
|
+
)
|
208
|
+
|
209
|
+
client.classifications.get(
|
210
|
+
id: ""
|
211
|
+
)
|
212
|
+
```
|
213
|
+
|
214
|
+
### Backups
|
215
|
+
```ruby
|
216
|
+
client.backups.create(
|
217
|
+
backend: "filesystem",
|
218
|
+
id: "my-first-backup",
|
219
|
+
include: ["Question"]
|
220
|
+
)
|
221
|
+
|
222
|
+
client.backups.get(
|
223
|
+
backend: "filesystem",
|
224
|
+
id: "my-first-backup"
|
225
|
+
)
|
226
|
+
|
227
|
+
client.backups.restore(
|
228
|
+
backend: "filesystem",
|
229
|
+
id: "my-first-backup"
|
230
|
+
)
|
231
|
+
|
232
|
+
client.backups.restore_status(
|
233
|
+
backend: "filesystem",
|
234
|
+
id: "my-first-backup"
|
235
|
+
)
|
236
|
+
```
|
237
|
+
|
238
|
+
### Nodes
|
191
239
|
```ruby
|
192
240
|
client.nodes
|
193
241
|
```
|
194
242
|
|
195
|
-
|
243
|
+
### Health
|
196
244
|
```ruby
|
197
245
|
client.live?
|
198
246
|
client.ready?
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Weaviate
|
4
|
+
class Backups < Base
|
5
|
+
PATH = "backups"
|
6
|
+
|
7
|
+
def create(
|
8
|
+
backend:,
|
9
|
+
id:,
|
10
|
+
include: nil,
|
11
|
+
exclude: nil
|
12
|
+
)
|
13
|
+
response = client.connection.post("#{PATH}/#{backend}") do |req|
|
14
|
+
req.body = {}
|
15
|
+
req.body["id"] = id
|
16
|
+
req.body["include"] = include if include
|
17
|
+
req.body["exclude"] = exclude if exclude
|
18
|
+
end
|
19
|
+
|
20
|
+
response.body
|
21
|
+
end
|
22
|
+
|
23
|
+
def get(
|
24
|
+
backend:,
|
25
|
+
id:
|
26
|
+
)
|
27
|
+
response = client.connection.get("#{PATH}/#{backend}/#{id}")
|
28
|
+
response.body
|
29
|
+
end
|
30
|
+
|
31
|
+
def restore(
|
32
|
+
backend:,
|
33
|
+
id:,
|
34
|
+
include: nil,
|
35
|
+
exclude: nil
|
36
|
+
)
|
37
|
+
response = client.connection.post("#{PATH}/#{backend}/#{id}/restore") do |req|
|
38
|
+
req.body = {}
|
39
|
+
req.body["include"] = include if include
|
40
|
+
req.body["exclude"] = exclude if exclude
|
41
|
+
end
|
42
|
+
|
43
|
+
response.body
|
44
|
+
end
|
45
|
+
|
46
|
+
def restore_status(
|
47
|
+
backend:,
|
48
|
+
id:
|
49
|
+
)
|
50
|
+
response = client.connection.get("#{PATH}/#{backend}/#{id}/restore")
|
51
|
+
response.body
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Weaviate
|
4
|
+
class Classifications < Base
|
5
|
+
PATH = "classifications"
|
6
|
+
|
7
|
+
def get(id:)
|
8
|
+
response = client.connection.get("#{PATH}/#{id}")
|
9
|
+
response.body
|
10
|
+
end
|
11
|
+
|
12
|
+
def create(
|
13
|
+
class_name:,
|
14
|
+
type:,
|
15
|
+
classify_properties: nil,
|
16
|
+
based_on_properties: nil,
|
17
|
+
settings: nil,
|
18
|
+
filters: nil
|
19
|
+
)
|
20
|
+
response = client.connection.post(PATH) do |req|
|
21
|
+
req.body = {}
|
22
|
+
req.body["class"] = class_name
|
23
|
+
req.body["type"] = type
|
24
|
+
req.body["classifyProperties"] = classify_properties if classify_properties
|
25
|
+
req.body["basedOnProperties"] = based_on_properties if based_on_properties
|
26
|
+
req.body["settings"] = settings if settings
|
27
|
+
req.body["filters"] = filters if filters
|
28
|
+
end
|
29
|
+
|
30
|
+
if response.success?
|
31
|
+
response.body
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/weaviate/client.rb
CHANGED
@@ -59,6 +59,14 @@ module Weaviate
|
|
59
59
|
@health.ready?
|
60
60
|
end
|
61
61
|
|
62
|
+
def backups
|
63
|
+
@backups ||= Weaviate::Backups.new(client: self)
|
64
|
+
end
|
65
|
+
|
66
|
+
def classifications
|
67
|
+
@classifications ||= Weaviate::Classifications.new(client: self)
|
68
|
+
end
|
69
|
+
|
62
70
|
def objects
|
63
71
|
@objects ||= Weaviate::Objects.new(client: self)
|
64
72
|
end
|
data/lib/weaviate/objects.rb
CHANGED
@@ -108,6 +108,30 @@ module Weaviate
|
|
108
108
|
response.success? && response.body.empty?
|
109
109
|
end
|
110
110
|
|
111
|
+
def batch_delete(
|
112
|
+
class_name:,
|
113
|
+
where:,
|
114
|
+
consistency_level: nil,
|
115
|
+
output: nil,
|
116
|
+
dry_run: nil
|
117
|
+
)
|
118
|
+
path = "batch/#{PATH}"
|
119
|
+
path << "?consistency_level=#{consistency_level}" unless consistency_level.nil?
|
120
|
+
|
121
|
+
response = client.connection.delete(path) do |req|
|
122
|
+
req.body = {
|
123
|
+
match: {
|
124
|
+
class: class_name,
|
125
|
+
where: where
|
126
|
+
}
|
127
|
+
}
|
128
|
+
req.body["output"] = output unless output.nil?
|
129
|
+
req.body["dryRun"] = dry_run unless dry_run.nil?
|
130
|
+
end
|
131
|
+
|
132
|
+
response.body
|
133
|
+
end
|
134
|
+
|
111
135
|
# Validate a data object
|
112
136
|
# def validate
|
113
137
|
# end
|
data/lib/weaviate/version.rb
CHANGED
data/lib/weaviate.rb
CHANGED
@@ -13,6 +13,8 @@ module Weaviate
|
|
13
13
|
autoload :Query, "weaviate/query"
|
14
14
|
autoload :Nodes, "weaviate/nodes"
|
15
15
|
autoload :Health, "weaviate/health"
|
16
|
+
autoload :Classifications, "weaviate/classifications"
|
17
|
+
autoload :Backups, "weaviate/backups"
|
16
18
|
|
17
19
|
module Response
|
18
20
|
autoload :Base, "weaviate/response/base"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weaviate-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Bondarev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -68,7 +68,9 @@ files:
|
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
70
|
- lib/weaviate.rb
|
71
|
+
- lib/weaviate/backups.rb
|
71
72
|
- lib/weaviate/base.rb
|
73
|
+
- lib/weaviate/classifications.rb
|
72
74
|
- lib/weaviate/client.rb
|
73
75
|
- lib/weaviate/error.rb
|
74
76
|
- lib/weaviate/health.rb
|
@@ -84,13 +86,13 @@ files:
|
|
84
86
|
- lib/weaviate/schema.rb
|
85
87
|
- lib/weaviate/version.rb
|
86
88
|
- sig/weaviate.rbs
|
87
|
-
homepage: https://github.com/andreibondarev/weaviate
|
89
|
+
homepage: https://github.com/andreibondarev/weaviate-ruby
|
88
90
|
licenses:
|
89
91
|
- MIT
|
90
92
|
metadata:
|
91
|
-
homepage_uri: https://github.com/andreibondarev/weaviate
|
92
|
-
source_code_uri: https://github.com/andreibondarev/weaviate
|
93
|
-
changelog_uri: https://github.com/andreibondarev/weaviate/CHANGELOG.md
|
93
|
+
homepage_uri: https://github.com/andreibondarev/weaviate-ruby
|
94
|
+
source_code_uri: https://github.com/andreibondarev/weaviate-ruby
|
95
|
+
changelog_uri: https://github.com/andreibondarev/weaviate-ruby/CHANGELOG.md
|
94
96
|
post_install_message:
|
95
97
|
rdoc_options: []
|
96
98
|
require_paths:
|