File tree Expand file tree Collapse file tree 6 files changed +74
-8
lines changed Expand file tree Collapse file tree 6 files changed +74
-8
lines changed Original file line number Diff line number Diff line change 11## [ Unreleased]
22
3+ ## [ 0.9.0] - 2024-07-08
4+
5+ - Add object.replace method which uses PUT which performs a complete object replacement
6+
7+ ### Breaking
8+ - Change the object.update method to use PATCH which only performs a partial update(previously performed a replacement)
9+
310## [ 0.8.11] - 2024-07-02
11+ - Allow the user to specify any options they want for multi-tenancy when creating a schema using their own hash
12+ - Allow Ollama vectorizer
413
514## [ 0.8.10] - 2024-01-25
615
Original file line number Diff line number Diff line change 11PATH
22 remote: .
33 specs:
4- weaviate-ruby (0.8.11 )
4+ weaviate-ruby (0.9.0 )
55 faraday (>= 2.0.1 , < 3.0 )
66 graphlient (~> 0.7.0 )
77
Original file line number Diff line number Diff line change @@ -168,14 +168,17 @@ client.objects.exists?(
168168 id: " uuid"
169169)
170170
171- # Delete a single data object from Weaviate .
172- client.objects.delete (
171+ # Perform a partial update on an object based on its uuid .
172+ client.objects.update (
173173 class_name: " Question" ,
174- id: " uuid"
174+ id: " uuid" ,
175+ properties: {
176+ category: " simple-math"
177+ }
175178)
176179
177- # Update a single data object based on its uuid.
178- client.objects.update (
180+ # Replace an object based on its uuid.
181+ client.objects.replace (
179182 class_name: " Question" ,
180183 id: " uuid" ,
181184 properties: {
@@ -185,6 +188,12 @@ client.objects.update(
185188 }
186189)
187190
191+ # Delete a single data object from Weaviate.
192+ client.objects.delete(
193+ class_name: " Question" ,
194+ id: " uuid"
195+ )
196+
188197# Batch create objects
189198client.objects.batch_create(objects: [
190199 {
Original file line number Diff line number Diff line change @@ -122,6 +122,31 @@ def update(
122122 )
123123 validate_consistency_level! ( consistency_level ) unless consistency_level . nil?
124124
125+ response = client . connection . patch ( "#{ PATH } /#{ class_name } /#{ id } " ) do |req |
126+ req . params [ "consistency_level" ] = consistency_level . to_s . upcase unless consistency_level . nil?
127+
128+ req . body = { }
129+ req . body [ "id" ] = id
130+ req . body [ "class" ] = class_name
131+ req . body [ "properties" ] = properties
132+ req . body [ "vector" ] = vector unless vector . nil?
133+ req . body [ "tenant" ] = tenant unless tenant . nil?
134+ end
135+
136+ response . body
137+ end
138+
139+ # Replace an individual data object based on its uuid.
140+ def replace (
141+ class_name :,
142+ id :,
143+ properties :,
144+ vector : nil ,
145+ tenant : nil ,
146+ consistency_level : nil
147+ )
148+ validate_consistency_level! ( consistency_level ) unless consistency_level . nil?
149+
125150 response = client . connection . put ( "#{ PATH } /#{ class_name } /#{ id } " ) do |req |
126151 req . params [ "consistency_level" ] = consistency_level . to_s . upcase unless consistency_level . nil?
127152
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33module Weaviate
4- VERSION = "0.8.11 "
4+ VERSION = "0.9.0 "
55end
Original file line number Diff line number Diff line change 132132 let ( :response ) { OpenStruct . new ( success? : true , body : object_fixture ) }
133133
134134 before do
135- allow_any_instance_of ( Faraday ::Connection ) . to receive ( :put )
135+ allow_any_instance_of ( Faraday ::Connection ) . to receive ( :patch )
136136 . with ( "objects/Question/123" )
137137 . and_return ( response )
138138 end
151151 end
152152 end
153153
154+ describe "#replace" do
155+ let ( :response ) { OpenStruct . new ( success? : true , body : object_fixture ) }
156+
157+ before do
158+ allow_any_instance_of ( Faraday ::Connection ) . to receive ( :put )
159+ . with ( "objects/Question/123" )
160+ . and_return ( response )
161+ end
162+
163+ it "returns the schema" do
164+ response = objects . replace (
165+ class_name : "Question" ,
166+ id : "123" ,
167+ properties : {
168+ question : "What does 6 times 7 equal to?" ,
169+ category : "math" ,
170+ answer : "42"
171+ }
172+ )
173+ expect ( response . dig ( "class" ) ) . to eq ( "Question" )
174+ end
175+ end
176+
154177 describe "#batch_create" do
155178 let ( :response ) { OpenStruct . new ( success? : true , body : objects_fixture ) }
156179
You can’t perform that action at this time.
0 commit comments