algoliasearch 1.2.3 → 1.2.4
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 +4 -0
- data/README.md +13 -1
- data/algoliasearch.gemspec +2 -2
- data/lib/algolia/index.rb +24 -3
- data/spec/client_spec.rb +11 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f84365c51f1592ac0bd372b32ef668eae0831ec
|
4
|
+
data.tar.gz: 315a6fbb785510696b8a9d1717de2cf09e208fd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e4bf583e3651c8b02c76e8bc6a50c038c54ab40766bc14ad1ca8ad6f8608e90984827aa4f8a5474d956af1ac4ebf9e5ff48e93696132fd12bb229769ad193e3
|
7
|
+
data.tar.gz: 6adcdf51f0a2702b5a7adbdebae0387a6d05a2c6957a44cdb388e37c0650aba41df48223ab110dccbaf13b7b53f39f16a5b211b5bbcc991e9d57e1303b7fb49d
|
data/ChangeLog
CHANGED
data/README.md
CHANGED
@@ -19,6 +19,7 @@ Algolia’s Search API makes it easy to deliver a great search experience in you
|
|
19
19
|
|
20
20
|
This Ruby client let you easily use the Algolia Search API from your backend. It wraps [Algolia's REST API](http://www.algolia.com/doc/rest_api).
|
21
21
|
|
22
|
+
|
22
23
|
[](https://travis-ci.org/algolia/algoliasearch-client-ruby) [](http://badge.fury.io/rb/algoliasearch) [](https://codeclimate.com/github/algolia/algoliasearch-client-ruby) [](https://coveralls.io/r/algolia/algoliasearch-client-ruby)
|
23
24
|
|
24
25
|
|
@@ -192,6 +193,8 @@ index.partial_update_object({"city" => "San Francisco",
|
|
192
193
|
"objectID" => "myID"})
|
193
194
|
```
|
194
195
|
|
196
|
+
|
197
|
+
|
195
198
|
Search
|
196
199
|
-------------
|
197
200
|
**Opening note:** If you are building a web application, you may be more interested in using our [javascript client](https://github.com/algolia/algoliasearch-client-js) to send queries. It brings two benefits: (i) your users get a better response time by avoiding to go through your servers, and (ii) it will offload your servers of unnecessary tasks.
|
@@ -220,7 +223,7 @@ You can use the following optional arguments:
|
|
220
223
|
|
221
224
|
#### Geo-search parameters
|
222
225
|
|
223
|
-
* **aroundLatLng**: search for entries around a given latitude/longitude (specified as two floats separated by a comma).<br/>For example `aroundLatLng=47.316669,5.016670`).<br/>You can specify the maximum distance in meters with the **aroundRadius** parameter (in meters) and the precision for ranking with **aroundPrecision** (for example if you set aroundPrecision=100, two objects that are distant of less than 100m will be considered as identical for "geo" ranking parameter).<br/>At indexing, you should specify geoloc of an object with the _geoloc attribute (in the form `{"_geoloc":{"lat":48.853409, "lng":2.348800}}`)
|
226
|
+
* **aroundLatLng**: search for entries around a given latitude/longitude (specified as two floats separated by a comma).<br/>For example `aroundLatLng=47.316669,5.016670`).<br/>You can specify the maximum distance in meters with the **aroundRadius** parameter (in meters) and the precision for ranking with **aroundPrecision** (for example if you set aroundPrecision=100, two objects that are distant of less than 100m will be considered as identical for "geo" ranking parameter).<br/>At indexing, you should specify geoloc of an object with the `_geoloc` attribute (in the form `{"_geoloc":{"lat":48.853409, "lng":2.348800}}`)
|
224
227
|
* **insideBoundingBox**: search entries inside a given area defined by the two extreme points of a rectangle (defined by 4 floats: p1Lat,p1Lng,p2Lat,p2Lng).<br/>For example `insideBoundingBox=47.3165,4.9665,47.3424,5.0201`).<br/>At indexing, you should specify geoloc of an object with the _geoloc attribute (in the form `{"_geoloc":{"lat":48.853409, "lng":2.348800}}`)
|
225
228
|
|
226
229
|
#### Parameters to control results content
|
@@ -244,6 +247,7 @@ You can use the following optional arguments:
|
|
244
247
|
#### Faceting parameters
|
245
248
|
* **facetFilters**: filter the query by a list of facets. Facets are separated by commas and each facet is encoded as `attributeName:value`. To OR facets, you must add parentheses. For example: `facetFilters=(category:Book,category:Movie),author:John%20Doe`. You can also use a string array encoding (for example `[["category:Book","category:Movie"],"author:John%20Doe"]`).
|
246
249
|
* **facets**: List of object attributes that you want to use for faceting. <br/>Attributes are separated with a comma (for example `"category,author"` ). You can also use a JSON string array encoding (for example `["category","author"]` ). Only attributes that have been added in **attributesForFaceting** index setting can be used in this parameter. You can also use `*` to perform faceting on all attributes specified in **attributesForFaceting**.
|
250
|
+
* **maxValuesPerFacet**: Limit the number of facet values returned for each facet. For example: `maxValuesPerFacet=10` will retrieve max 10 values per facet.
|
247
251
|
|
248
252
|
#### Distinct parameter
|
249
253
|
* **distinct**: If set to 1, enable the distinct feature (disabled by default) if the `attributeForDistinct` index setting is set. This feature is similar to the SQL "distinct" keyword: when enabled in a query with the `distinct=1` parameter, all hits containing a duplicate value for the attributeForDistinct attribute are removed from results. For example, if the chosen attribute is `show_name` and several hits have the same value for `show_name`, then only the best one is kept and others are removed.
|
@@ -289,6 +293,8 @@ The server response will look like:
|
|
289
293
|
}
|
290
294
|
```
|
291
295
|
|
296
|
+
|
297
|
+
|
292
298
|
Get an object
|
293
299
|
-------------
|
294
300
|
|
@@ -409,6 +415,7 @@ You may want to perform multiple operations with one API call to reduce latency.
|
|
409
415
|
We expose three methods to perform batch:
|
410
416
|
* `add_objects`: add an array of object using automatic `objectID` assignement
|
411
417
|
* `save_objects`: add or update an array of object that contains an `objectID` attribute
|
418
|
+
* `delete_objects`: delete an array of objectIDs
|
412
419
|
* `partial_update_objects`: partially update an array of objects that contain an `objectID` attribute (only specified attributes will be updated, other will remain unchanged)
|
413
420
|
|
414
421
|
Example using automatic `objectID` assignement:
|
@@ -429,6 +436,11 @@ res = index.save_objects([{"firstname" => "Jimmie",
|
|
429
436
|
"objectID" => "myID2"}])
|
430
437
|
```
|
431
438
|
|
439
|
+
Example that delete a set of records:
|
440
|
+
```ruby
|
441
|
+
res = index.delete_objects(["myID1", "myID2"])
|
442
|
+
```
|
443
|
+
|
432
444
|
Example that update only the `firstname` attribute:
|
433
445
|
```ruby
|
434
446
|
res = index.partial_update_objects([{"firstname" => "Jimmie",
|
data/algoliasearch.gemspec
CHANGED
@@ -6,12 +6,12 @@
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "algoliasearch"
|
9
|
-
s.version = "1.2.
|
9
|
+
s.version = "1.2.4"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Algolia"]
|
14
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-02-21"
|
15
15
|
s.description = "A simple Ruby client for the algolia.com REST API"
|
16
16
|
s.email = "contact@algolia.com"
|
17
17
|
s.extra_rdoc_files = [
|
data/lib/algolia/index.rb
CHANGED
@@ -179,7 +179,7 @@ module Algolia
|
|
179
179
|
Algolia.client.put(Protocol.object_uri(name, get_objectID(obj, objectID)), obj.to_json)
|
180
180
|
end
|
181
181
|
|
182
|
-
# Override the content of object and wait indexing
|
182
|
+
# Override the content of object and wait end of indexing
|
183
183
|
#
|
184
184
|
# @param obj the object to save
|
185
185
|
# @param objectID the associated objectID, if nil 'obj' must contain an 'objectID' key
|
@@ -198,7 +198,7 @@ module Algolia
|
|
198
198
|
batch build_batch('updateObject', objs, true)
|
199
199
|
end
|
200
200
|
|
201
|
-
# Override the content of several objects and wait indexing
|
201
|
+
# Override the content of several objects and wait end of indexing
|
202
202
|
#
|
203
203
|
# @param objs the array of objects to save, each object must contain an objectID attribute
|
204
204
|
#
|
@@ -228,7 +228,7 @@ module Algolia
|
|
228
228
|
end
|
229
229
|
|
230
230
|
#
|
231
|
-
# Partially Override the content of several objects
|
231
|
+
# Partially Override the content of several objects and wait end of indexing
|
232
232
|
#
|
233
233
|
# @param objs an array of objects to update (each object must contains a objectID attribute)
|
234
234
|
#
|
@@ -270,6 +270,27 @@ module Algolia
|
|
270
270
|
return res
|
271
271
|
end
|
272
272
|
|
273
|
+
#
|
274
|
+
# Delete several objects
|
275
|
+
#
|
276
|
+
# @param objs an array of objectIDs
|
277
|
+
#
|
278
|
+
def delete_objects(objs)
|
279
|
+
check_array objs
|
280
|
+
batch build_batch('deleteObject', objs.map { |objectID| { objectID: objectID } }, false)
|
281
|
+
end
|
282
|
+
|
283
|
+
#
|
284
|
+
# Delete several objects and wait end of indexing
|
285
|
+
#
|
286
|
+
# @param objs an array of objectIDs
|
287
|
+
#
|
288
|
+
def delete_objects!(objs)
|
289
|
+
res = delete_objects(objs)
|
290
|
+
wait_task(res["taskID"])
|
291
|
+
return res
|
292
|
+
end
|
293
|
+
|
273
294
|
#
|
274
295
|
# Delete the index content
|
275
296
|
#
|
data/spec/client_spec.rb
CHANGED
@@ -152,7 +152,17 @@ describe 'Client' do
|
|
152
152
|
@index.add_object!({:firstname => "Robert"})
|
153
153
|
res = @index.search('')
|
154
154
|
@index.search('')['nbHits'].should eq(1)
|
155
|
-
|
155
|
+
@index.delete_object!(res['hits'][0]['objectID'])
|
156
|
+
@index.search('')['nbHits'].should eq(0)
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should delete several objects" do
|
160
|
+
@index.clear
|
161
|
+
@index.add_object!({:firstname => "Robert1"})
|
162
|
+
@index.add_object!({:firstname => "Robert2"})
|
163
|
+
res = @index.search('')
|
164
|
+
@index.search('')['nbHits'].should eq(2)
|
165
|
+
@index.delete_objects!(res['hits'].map { |h| h['objectID'] })
|
156
166
|
@index.search('')['nbHits'].should eq(0)
|
157
167
|
end
|
158
168
|
|
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.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|