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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df5a732fe0627231c87d9015404183714d411ca8
4
- data.tar.gz: 3c90c3e9c12cafa3cb37d254acf723c3a210f48b
3
+ metadata.gz: 128d59909c267e976baa312097edd9519eb92a6f
4
+ data.tar.gz: e770982f18181545c66310809c06998401f61ac7
5
5
  SHA512:
6
- metadata.gz: c3a164a8ca1699b0f34801431985fd475a1440ca04de278cf81fe7640b5bebd44a5ee86b92a0e60a967f0e777f51e06afac3a689381581a9aa71d0cd5f101f50
7
- data.tar.gz: e51c1cd7aef502ee8ea4d6eecff24e22be7ef957590d008df148225590857eb797ec27de59b8c4741798adcd0fe90897c5535c0c870836ad0e705616f64195c7
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 final word will be removed until there is results,
260
- * **FirstWords**: when a query does not return any result, the first word will be removed until there is results,
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 3.
264
- * **minWordSizefor2Typos**: the minimum number of characters in a query word to accept two typos in this word.<br/>Defaults to 7.
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 = 3).
474
- * **minWordSizefor2Typos**: (integer) the minimum number of characters to accept two typos (default = 7).
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
@@ -6,7 +6,7 @@
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "algoliasearch"
9
- s.version = "1.2.10"
9
+ s.version = "1.2.11"
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"]
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Algolia
2
- VERSION = "1.2.10"
2
+ VERSION = "1.2.11"
3
3
  end
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.10
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
- - ".rspec"
93
- - ".travis.yml"
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.2.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