algoliasearch 1.2.10 → 1.2.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -6
- data/algoliasearch.gemspec +1 -1
- data/lib/algolia/client.rb +29 -0
- data/lib/algolia/index.rb +19 -0
- data/lib/algolia/version.rb +1 -1
- data/spec/client_spec.rb +8 -0
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 128d59909c267e976baa312097edd9519eb92a6f
|
4
|
+
data.tar.gz: e770982f18181545c66310809c06998401f61ac7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df02e9a483a05a462ee68994d8dfb90021540e85da394805906481126730c3b402b3fb409c4dbcf973b05def05ed8c363208d5838a2cc3ae8535982903f31528
|
7
|
+
data.tar.gz: 76d1f9897e16c3c919e8db4cf508eaff64f92b04bba77f87cd974d7d544c7aff6eef2c3d8b3acfdd6e5a4fe287466ab6d840368b00b363ec8bed6e2e169dc1fb
|
data/README.md
CHANGED
@@ -256,13 +256,14 @@ You can use the following optional arguments:
|
|
256
256
|
* **prefixLast**: only the last word is interpreted as a prefix (default behavior),
|
257
257
|
* **prefixNone**: no query word is interpreted as a prefix. This option is not recommended.
|
258
258
|
* **removeWordsIfNoResult**: This option to select a strategy to avoid having an empty result page. There is three different option:
|
259
|
-
* **LastWords**: when a query does not return any result, the
|
260
|
-
* **FirstWords**: when a query does not return any result, the first word will be
|
259
|
+
* **LastWords**: when a query does not return any result, the last word will be added as optional (the process is repeated with n-1 word, n-2 word, ... until there is results),
|
260
|
+
* **FirstWords**: when a query does not return any result, the first word will be added as optional (the process is repeated with second word, third word, ... until there is results),
|
261
261
|
* **None**: No specific processing is done when a query does not return any result (default behavior).
|
262
262
|
* **typoTolerance**: if set to false, disable the typo-tolerance. Defaults to true.
|
263
|
-
* **minWordSizefor1Typo**: the minimum number of characters in a query word to accept one typo in this word.<br/>Defaults to
|
264
|
-
* **minWordSizefor2Typos**: the minimum number of characters in a query word to accept two typos in this word.<br/>Defaults to
|
263
|
+
* **minWordSizefor1Typo**: the minimum number of characters in a query word to accept one typo in this word.<br/>Defaults to 4.
|
264
|
+
* **minWordSizefor2Typos**: the minimum number of characters in a query word to accept two typos in this word.<br/>Defaults to 8.
|
265
265
|
* **allowTyposOnNumericTokens**: if set to false, disable typo-tolerance on numeric tokens (numbers). Default to true.
|
266
|
+
* **ignorePlural**: If set to true, plural won't be considered as a typo (for example car/cars will be considered as equals). Default to false.
|
266
267
|
* **restrictSearchableAttributes** List of attributes you want to use for textual search (must be a subset of the `attributesToIndex` index setting). Attributes are separated with a comma (for example `"name,address"`), you can also use a JSON string array encoding (for example encodeURIComponent("[\"name\",\"address\"]")). By default, all attributes specified in `attributesToIndex` settings are used to search.
|
267
268
|
* **advancedSyntax**: Enable the advanced query syntax. Defaults to 0 (false).
|
268
269
|
* **Phrase query**: a phrase query defines a particular sequence of terms. A phrase query is build by Algolia's query parser for words surrounded by `"`. For example, `"search engine"` will retrieve records having `search` next to `engine` only. Typo-tolerance is _disabled_ on phrase queries.
|
@@ -455,6 +456,8 @@ For example `"customRanking" => ["desc(population)", "asc(name)"]`
|
|
455
456
|
* **prefixLast**: only the last word is interpreted as a prefix (default behavior),
|
456
457
|
* **prefixNone**: no query word is interpreted as a prefix. This option is not recommended.
|
457
458
|
* **slaves**: The list of indices on which you want to replicate all write operations. In order to get response times in milliseconds, we pre-compute part of the ranking during indexing. If you want to use different ranking configurations depending of the use-case, you need to create one index per ranking configuration. This option enables you to perform write operations only on this index, and to automatically update slave indices with the same operations.
|
459
|
+
* **unretrievableAttributes**: The list of attributes that cannot be retrieved at query time. This feature allow to have an attribute that is used for indexing and/or ranking but cannot be retrieved. Default to null.
|
460
|
+
* **allowCompressionOfIntegerArray**: Allows compression of big integer arrays. We recommended to store the list of user ID or rights as an integer array and enable this setting. When enabled the integer array are reordered to reach a better compression ratio. Default to false.
|
458
461
|
|
459
462
|
#### Query expansion
|
460
463
|
* **synonyms**: (array of array of words considered as equals). For example, you may want to retrieve your **black ipad** record when your users are searching for **dark ipad**, even if the **dark** word is not part of the record: so you need to configure **black** as a synonym of **dark**. For example `"synomyms": [ [ "black", "dark" ], [ "small", "little", "mini" ], ... ]`.
|
@@ -470,8 +473,8 @@ For example `"customRanking" => ["desc(population)", "asc(name)"]`
|
|
470
473
|
For example `"altCorrections": [ { "word" : "foot", "correction": "feet", "nbTypos": 1}, { "word": "feet", "correction": "foot", "nbTypos": 1}].`
|
471
474
|
|
472
475
|
#### Default query parameters (can be overwrite by query)
|
473
|
-
* **minWordSizefor1Typo**: (integer) the minimum number of characters to accept one typo (default =
|
474
|
-
* **minWordSizefor2Typos**: (integer) the minimum number of characters to accept two typos (default =
|
476
|
+
* **minWordSizefor1Typo**: (integer) the minimum number of characters to accept one typo (default = 4).
|
477
|
+
* **minWordSizefor2Typos**: (integer) the minimum number of characters to accept two typos (default = 8).
|
475
478
|
* **hitsPerPage**: (integer) the number of hits per page (default = 10).
|
476
479
|
* **attributesToRetrieve**: (array of strings) default list of attributes to retrieve in objects. If set to null, all attributes are retrieved.
|
477
480
|
* **attributesToHighlight**: (array of strings) default list of attributes to highlight. If set to null, all indexed attributes are highlighted.
|
@@ -631,6 +634,19 @@ res = index.add_user_key(["search"], 300, 100, 20, ['my_index1', 'my_index2'])
|
|
631
634
|
puts res['key']
|
632
635
|
```
|
633
636
|
|
637
|
+
Update the rights of an existing key:
|
638
|
+
```ruby
|
639
|
+
# Update an existing global API key that is valid for 300 seconds
|
640
|
+
res = Algolia.update_user_key("myAPIKey", ["search"], 300)
|
641
|
+
puts res['key']
|
642
|
+
# Update an existing index specific API key:
|
643
|
+
# - valid for 300 seconds
|
644
|
+
# - rate limit of 100 calls per hour per IP
|
645
|
+
# - maximum of 20 hits
|
646
|
+
# - valid on 'my_index1' and 'my_index2'
|
647
|
+
res = index.update_user_key("myAPIKey", ["search"], 300, 100, 20, ['my_index1', 'my_index2'])
|
648
|
+
puts res['key']
|
649
|
+
```
|
634
650
|
Get the rights of a given key:
|
635
651
|
```ruby
|
636
652
|
# Gets the rights of a global key
|
data/algoliasearch.gemspec
CHANGED
data/lib/algolia/client.rb
CHANGED
@@ -311,6 +311,35 @@ module Algolia
|
|
311
311
|
Algolia.client.post(Protocol.keys_uri, params.to_json)
|
312
312
|
end
|
313
313
|
|
314
|
+
#
|
315
|
+
# Update a user key
|
316
|
+
#
|
317
|
+
# @param acls the list of ACL for this key. Defined by an array of strings that
|
318
|
+
# can contains the following values:
|
319
|
+
# - search: allow to search (https and http)
|
320
|
+
# - addObject: allows to add a new object in the index (https only)
|
321
|
+
# - updateObject : allows to change content of an existing object (https only)
|
322
|
+
# - deleteObject : allows to delete an existing object (https only)
|
323
|
+
# - deleteIndex : allows to delete index content (https only)
|
324
|
+
# - settings : allows to get index settings (https only)
|
325
|
+
# - editSettings : allows to change index settings (https only)
|
326
|
+
# @param validity the number of seconds after which the key will be automatically removed (0 means no time limit for this key)
|
327
|
+
# @param maxQueriesPerIPPerHour the maximum number of API calls allowed from an IP address per hour (0 means unlimited)
|
328
|
+
# @param maxHitsPerQuery the maximum number of hits this API key can retrieve in one call (0 means unlimited)
|
329
|
+
# @param indexes the optional list of targeted indexes
|
330
|
+
#
|
331
|
+
def Algolia.update_user_key(key, acls, validity = 0, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, indexes = nil)
|
332
|
+
params = {
|
333
|
+
:acl => acls,
|
334
|
+
:validity => validity.to_i,
|
335
|
+
:maxQueriesPerIPPerHour => maxQueriesPerIPPerHour.to_i,
|
336
|
+
:maxHitsPerQuery => maxHitsPerQuery.to_i
|
337
|
+
}
|
338
|
+
params[:indexes] = indexes if indexes
|
339
|
+
Algolia.client.put(Protocol.key_uri(key), params.to_json)
|
340
|
+
end
|
341
|
+
|
342
|
+
|
314
343
|
# Delete an existing user key
|
315
344
|
def Algolia.delete_user_key(key)
|
316
345
|
Algolia.client.delete(Protocol.key_uri(key))
|
data/lib/algolia/index.rb
CHANGED
@@ -438,6 +438,25 @@ module Algolia
|
|
438
438
|
def add_user_key(acls, validity = 0, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0)
|
439
439
|
Algolia.client.post(Protocol.index_keys_uri(name), {:acl => acls, :validity => validity, :maxQueriesPerIPPerHour => maxQueriesPerIPPerHour.to_i, :maxHitsPerQuery => maxHitsPerQuery.to_i}.to_json)
|
440
440
|
end
|
441
|
+
|
442
|
+
#
|
443
|
+
# Update a user key
|
444
|
+
#
|
445
|
+
# @param acls the list of ACL for this key. Defined by an array of strings that
|
446
|
+
# can contains the following values:
|
447
|
+
# - search: allow to search (https and http)
|
448
|
+
# - addObject: allows to add a new object in the index (https only)
|
449
|
+
# - updateObject : allows to change content of an existing object (https only)
|
450
|
+
# - deleteObject : allows to delete an existing object (https only)
|
451
|
+
# - deleteIndex : allows to delete index content (https only)
|
452
|
+
# - settings : allows to get index settings (https only)
|
453
|
+
# - editSettings : allows to change index settings (https only)
|
454
|
+
# @param validity the number of seconds after which the key will be automatically removed (0 means no time limit for this key)
|
455
|
+
#
|
456
|
+
def update_user_key(key, acls, validity = 0, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0)
|
457
|
+
Algolia.client.put(Protocol.index_key_uri(name, key), {:acl => acls, :validity => validity, :maxQueriesPerIPPerHour => maxQueriesPerIPPerHour.to_i, :maxHitsPerQuery => maxHitsPerQuery.to_i}.to_json)
|
458
|
+
end
|
459
|
+
|
441
460
|
|
442
461
|
# Delete an existing user key
|
443
462
|
def delete_user_key(key)
|
data/lib/algolia/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -333,6 +333,10 @@ describe 'Client' do
|
|
333
333
|
is_include(resIndexAfter['keys'], 'value', newIndexKey['key']).should eq(true)
|
334
334
|
indexKey = @index.get_user_key(newIndexKey['key'])
|
335
335
|
indexKey['acl'][0].should eq('search')
|
336
|
+
@index.update_user_key(newIndexKey['key'], ['addObject'])
|
337
|
+
sleep 2 # no task ID here
|
338
|
+
indexKey = @index.get_user_key(newIndexKey['key'])
|
339
|
+
indexKey['acl'][0].should eq('addObject')
|
336
340
|
@index.delete_user_key(newIndexKey['key'])
|
337
341
|
sleep 2 # no task ID here
|
338
342
|
resIndexEnd = @index.list_user_keys
|
@@ -348,6 +352,10 @@ describe 'Client' do
|
|
348
352
|
is_include(resAfter['keys'], 'value', newKey['key']).should eq(true)
|
349
353
|
key = Algolia.get_user_key(newKey['key'])
|
350
354
|
key['acl'][0].should eq('search')
|
355
|
+
Algolia.update_user_key(newKey['key'], ['addObject'])
|
356
|
+
sleep 2 # no task ID here
|
357
|
+
key = Algolia.get_user_key(newKey['key'])
|
358
|
+
key['acl'][0].should eq('addObject')
|
351
359
|
Algolia.delete_user_key(newKey['key'])
|
352
360
|
sleep 2 # no task ID here
|
353
361
|
resEnd = Algolia.list_user_keys
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
@@ -14,70 +14,70 @@ dependencies:
|
|
14
14
|
name: httpclient
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.5.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.5.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: travis
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rdoc
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: A simple Ruby client for the algolia.com REST API
|
@@ -89,8 +89,8 @@ extra_rdoc_files:
|
|
89
89
|
- LICENSE.txt
|
90
90
|
- README.md
|
91
91
|
files:
|
92
|
-
-
|
93
|
-
-
|
92
|
+
- .rspec
|
93
|
+
- .travis.yml
|
94
94
|
- ChangeLog
|
95
95
|
- Gemfile
|
96
96
|
- Gemfile.lock
|
@@ -121,17 +121,17 @@ require_paths:
|
|
121
121
|
- lib
|
122
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
|
-
- -
|
124
|
+
- - '>='
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0'
|
127
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - '>='
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
134
|
+
rubygems_version: 2.4.1
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: A simple Ruby client for the algolia.com REST API
|