algoliasearch 1.1.5 → 1.1.6

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: dccd32ef275f4ebd7fd41df137127f959dfc82f1
4
- data.tar.gz: 67b06daa971904e9528f3211b651f8f9d07d2578
3
+ metadata.gz: 41cdb9e15fe44adcea0c9c9d2fd06b42284ee323
4
+ data.tar.gz: c744385715e62c575ca066f3e01c9ac9d9fffa61
5
5
  SHA512:
6
- metadata.gz: 73a1ac9d5f6a11d35b8bce3275982d01691bd2a38f65a3e48ade5c8bfc4ee4e48e729b946557b76a0cc2aa0a17414786a48d54b15ae2927880871e75c8ccb652
7
- data.tar.gz: 763ab359f9c29009c182872c21616ad4403854caa4fa8cca3610a34f14524a86b7585023035020bdcad8b1c95987a7c000d7d0e9f44794d86b07144e5e226c8d
6
+ metadata.gz: 49577f70778667287e47dd77691a247c475fd85448562a65d6bb5d457a31bf0966c82a8e48d67cfe2cb8af465b8a3c4089e928aaab58088f37ca66cf83be766b
7
+ data.tar.gz: 934a7181e7815c046c362bf44f38f37a30d1c12a2a729e2555e62f37f17e64c6d453fe9581989d7db5e213c8ff6f9c0b55349e86f775b963a36faec1ed49a81d
data/ChangeLog CHANGED
@@ -1,5 +1,10 @@
1
1
  CHANGELOG
2
2
 
3
+ 2013-11-07 1.1.6
4
+
5
+ * Index: clear and clear! methods can now be used the delete the whole content of an index
6
+ * User keys: plug new maxQueriesPerIPPerHour and maxHitsPerQuery parameters
7
+
3
8
  2013-10-17 1.1.5
4
9
 
5
10
  * Version is now part of the user-agent
data/README.md CHANGED
@@ -405,15 +405,20 @@ Copy or rename an index
405
405
  You can easily copy or rename an existing index using the `copy` and `move` commands.
406
406
  **Note**: Move and copy commands overwrite destination index.
407
407
 
408
+ ```ruby
409
+ # Rename MyIndex in MyIndexNewName
410
+ puts Algolia.move_index("MyIndex", "MyIndexNewName")
411
+ # Copy MyIndex in MyIndexCopy
412
+ puts Algolia.copy_index("MyIndex", "MyIndexCopy")
413
+ ```
414
+
408
415
  The move command is particularly useful is you want to update a big index atomically from one version to another. For example, if you recreate your index `MyIndex` each night from a database by batch, you just have to:
409
416
  1. Import your database in a new index using [batches](#batch-writes). Let's call this new index `MyNewIndex`.
410
417
  1. Rename `MyNewIndex` in `MyIndex` using the move command. This will automatically override the old index and new queries will be served on the new one.
411
418
 
412
419
  ```ruby
413
- # Rename MyNewIndex in MyIndex
420
+ # Rename MyNewIndex in MyIndex (and overwrite it)
414
421
  puts Algolia.move_index("MyNewIndex", "MyIndex")
415
- # Copy MyNewIndex in MyIndex
416
- puts Algolia.copy_index("MyNewIndex", "MyIndex")
417
422
  ```
418
423
 
419
424
  Logs
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
  require 'rake'
13
13
 
14
- require File.join(__FILE__, '..', 'lib', 'algolia', 'version')
14
+ require File.expand_path('../lib/algolia/version', __FILE__)
15
15
 
16
16
  require 'jeweler'
17
17
  Jeweler::Tasks.new do |gem|
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "algoliasearch"
8
- s.version = "1.1.5"
8
+ s.version = "1.1.6"
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-10-17"
12
+ s.date = "2013-11-07"
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 = [
@@ -40,7 +40,7 @@ Gem::Specification.new do |s|
40
40
  s.homepage = "http://github.com/algolia/algoliasearch-client-ruby"
41
41
  s.licenses = ["MIT"]
42
42
  s.require_paths = ["lib"]
43
- s.rubygems_version = "2.0.3"
43
+ s.rubygems_version = "2.0.12"
44
44
  s.summary = "A simple Ruby client for the algolia.com REST API"
45
45
 
46
46
  if s.respond_to? :specification_version then
@@ -175,9 +175,11 @@ module Algolia
175
175
  # - settings : allows to get index settings (https only)
176
176
  # - editSettings : allows to change index settings (https only)
177
177
  # @param validity the number of seconds after which the key will be automatically removed (0 means no time limit for this key)
178
+ # @param maxQueriesPerIPPerHour the maximum number of API calls allowed from an IP address per hour (0 means unlimited)
179
+ # @param maxHitsPerQuery the maximum number of hits this API key can retrieve in one call (0 means unlimited)
178
180
  #
179
- def Algolia.add_user_key(acls, validity = 0)
180
- Algolia.client.post(Protocol.keys_uri, {"acl" => acls, "validity" => validity}.to_json)
181
+ def Algolia.add_user_key(acls, validity = 0, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0)
182
+ Algolia.client.post(Protocol.keys_uri, {"acl" => acls, "validity" => validity.to_i, "maxQueriesPerIPPerHour" => maxQueriesPerIPPerHour.to_i, "maxHitsPerQuery" => maxHitsPerQuery.to_i}.to_json)
181
183
  end
182
184
 
183
185
  # Delete an existing user key
@@ -231,6 +231,23 @@ module Algolia
231
231
  wait_task(res["taskID"])
232
232
  return res
233
233
  end
234
+
235
+ #
236
+ # Delete the index content
237
+ #
238
+ #
239
+ def clear
240
+ Algolia.client.post(Protocol.clear_uri(name), nil)
241
+ end
242
+
243
+ #
244
+ # Delete the index content and wait end of indexing
245
+ #
246
+ def clear!
247
+ res = clear
248
+ wait_task(res["taskID"])
249
+ return res
250
+ end
234
251
 
235
252
  #
236
253
  # Set settings for this index
@@ -69,6 +69,10 @@ module Algolia
69
69
  "#{index_uri(index)}/settings"
70
70
  end
71
71
 
72
+ def Protocol.clear_uri(index)
73
+ "#{index_uri(index)}/clear"
74
+ end
75
+
72
76
  def Protocol.logs(offset, length)
73
77
  "/#{VERSION}/logs?offset=#{offset}&length=#{length}"
74
78
  end
@@ -1,3 +1,3 @@
1
1
  module Algolia
2
- VERSION = "1.1.5"
2
+ VERSION = "1.1.6"
3
3
  end
@@ -40,4 +40,9 @@ describe 'Client' do
40
40
  threads.each { |t| t.join }
41
41
  end
42
42
 
43
+ it "should clear the index" do
44
+ @index.clear!
45
+ @index.search("")["hits"].length.should eq(0)
46
+ end
47
+
43
48
  end
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.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-17 00:00:00.000000000 Z
11
+ date: 2013-11-07 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.3
116
+ rubygems_version: 2.0.12
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: A simple Ruby client for the algolia.com REST API