algoliasearch 1.1.7 → 1.1.8
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/README.md +11 -2
- data/algoliasearch.gemspec +2 -2
- data/lib/algolia/client.rb +6 -5
- data/lib/algolia/index.rb +28 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e5c089266fdf23e0ad55f0e3abb8dd3df34c43c
|
4
|
+
data.tar.gz: 65779ff387f443477c45e4c816e52eca744873aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 640ba343d66fe502329d83e2e3d2c14503553f55e752af61d96997c84e0ffa8890709a2b8e3cc3df5bca303c2b2e2eb9ed9cfc99efcdf04422ff2f085362d8d1
|
7
|
+
data.tar.gz: 789b36b476cad2407a5a0ae8ac2ba38533d59d08d3edb1e3ce23d5197ed60d05954401b9d12b109bddd58b2c9a2933a5d1643b54af9d5b5006e1fb0aeb046d2b
|
data/README.md
CHANGED
@@ -328,8 +328,9 @@ Batch writes
|
|
328
328
|
|
329
329
|
You may want to perform multiple operations with one API call to reduce latency.
|
330
330
|
We expose two methods to perform batch:
|
331
|
-
* `
|
332
|
-
* `
|
331
|
+
* `add_objects`: add an array of object using automatic `objectID` assignement
|
332
|
+
* `save_objects`: add or update an array of object that contains an `objectID` attribute
|
333
|
+
* `partial_update_objects`: partially update an array of objects that contain an `objectID` attribute (only specified attributes will be updated, other will remain unchanged)
|
333
334
|
|
334
335
|
Example using automatic `objectID` assignement:
|
335
336
|
```ruby
|
@@ -349,6 +350,14 @@ res = index.save_objects([{"firstname" => "Jimmie",
|
|
349
350
|
"objectID" => "myID2"}])
|
350
351
|
```
|
351
352
|
|
353
|
+
Example that update only the `firstname` attribute:
|
354
|
+
```ruby
|
355
|
+
res = index.partial_update_objects([{"firstname" => "Jimmie",
|
356
|
+
"objectID" => "SFO"},
|
357
|
+
{"firstname" => "Warren",
|
358
|
+
"objectID" => "myID2"}]);
|
359
|
+
```
|
360
|
+
|
352
361
|
Security / User API Keys
|
353
362
|
-------------
|
354
363
|
|
data/algoliasearch.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "algoliasearch"
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Algolia"]
|
12
|
-
s.date = "2013-11-
|
12
|
+
s.date = "2013-11-26"
|
13
13
|
s.description = "A simple Ruby client for the algolia.com REST API"
|
14
14
|
s.email = "contact@algolia.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/algolia/client.rb
CHANGED
@@ -26,6 +26,7 @@ module Algolia
|
|
26
26
|
# AlgoliaProtocolError if the response has an error status code,
|
27
27
|
# and will return the parsed JSON body on success, if there is one.
|
28
28
|
def request(uri, method, data = nil)
|
29
|
+
exceptions = []
|
29
30
|
thread_local_hosts.each do |host|
|
30
31
|
begin
|
31
32
|
session = host["session"]
|
@@ -42,17 +43,17 @@ module Algolia
|
|
42
43
|
session.http_delete
|
43
44
|
end
|
44
45
|
if session.response_code >= 400 || session.response_code < 200
|
45
|
-
raise AlgoliaProtocolError.new(session.response_code, "#{method} #{session.url}: #{session.body_str}")
|
46
|
+
raise AlgoliaProtocolError.new(session.response_code, "Cannot #{method} to #{session.url}: #{session.body_str} (#{session.response_code})")
|
46
47
|
end
|
47
48
|
return JSON.parse(session.body_str)
|
48
49
|
rescue AlgoliaProtocolError => e
|
49
|
-
if e.code != Protocol::ERROR_TIMEOUT and e.code != Protocol::ERROR_UNAVAILABLE
|
50
|
-
|
51
|
-
end
|
50
|
+
raise if e.code != Protocol::ERROR_TIMEOUT and e.code != Protocol::ERROR_UNAVAILABLE
|
51
|
+
exceptions << e
|
52
52
|
rescue Curl::Err::CurlError => e
|
53
|
+
exceptions << e
|
53
54
|
end
|
54
55
|
end
|
55
|
-
raise AlgoliaProtocolError.new(0, "Cannot reach any
|
56
|
+
raise AlgoliaProtocolError.new(0, "Cannot reach any host: #{exceptions.map { |e| e.to_s }.join(', ')}")
|
56
57
|
end
|
57
58
|
|
58
59
|
def get(uri)
|
data/lib/algolia/index.rb
CHANGED
@@ -197,7 +197,7 @@ module Algolia
|
|
197
197
|
|
198
198
|
# Override the content of several objects and wait indexing
|
199
199
|
#
|
200
|
-
# @param object contains the
|
200
|
+
# @param object contains the object to save, the object must contains an objectID attribute
|
201
201
|
#
|
202
202
|
def save_objects!(objs)
|
203
203
|
res = save_objects(objs)
|
@@ -208,17 +208,42 @@ module Algolia
|
|
208
208
|
#
|
209
209
|
# Update partially an object (only update attributes passed in argument)
|
210
210
|
#
|
211
|
-
# @param obj contains the
|
211
|
+
# @param obj contains the object attributes to override, the
|
212
212
|
# object must contains an objectID attribute
|
213
213
|
#
|
214
214
|
def partial_update_object(obj)
|
215
215
|
Algolia.client.post(Protocol.partial_object_uri(name, obj["objectID"]), obj.to_json)
|
216
216
|
end
|
217
217
|
|
218
|
+
#
|
219
|
+
# Partially Override the content of several objects
|
220
|
+
#
|
221
|
+
# @param objs contains an array of objects to update (each object must contains a objectID attribute)
|
222
|
+
#
|
223
|
+
def partial_update_objects(objs)
|
224
|
+
requests = []
|
225
|
+
objs.each do |obj|
|
226
|
+
requests.push({"action" => "partialUpdateObject", "objectID" => obj["objectID"], "body" => obj})
|
227
|
+
end
|
228
|
+
request = {"requests" => requests};
|
229
|
+
Algolia.client.post(Protocol.batch_uri(name), request.to_json)
|
230
|
+
end
|
231
|
+
|
232
|
+
#
|
233
|
+
# Partially Override the content of several objects
|
234
|
+
#
|
235
|
+
# @param objs contains an array of objects to update (each object must contains a objectID attribute)
|
236
|
+
#
|
237
|
+
def partial_update_objects!(objs)
|
238
|
+
res = partial_update_objects(obj)
|
239
|
+
wait_task(res["taskID"])
|
240
|
+
return res
|
241
|
+
end
|
242
|
+
|
218
243
|
#
|
219
244
|
# Update partially an object (only update attributes passed in argument) and wait indexing
|
220
245
|
#
|
221
|
-
# @param obj contains the
|
246
|
+
# @param obj contains the attributes to override, the
|
222
247
|
# object must contains an objectID attribute
|
223
248
|
#
|
224
249
|
def partial_update_object!(obj)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algoliasearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curb
|
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
version: '0'
|
114
114
|
requirements: []
|
115
115
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.0.
|
116
|
+
rubygems_version: 2.0.3
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: A simple Ruby client for the algolia.com REST API
|