algoliasearch 1.6.0 → 1.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 511e4c42adb37f4b590e19d4db50e168207206cf
4
- data.tar.gz: 26b545014c375f33eb5cb5ecee8b1f2c9a2dfa8e
3
+ metadata.gz: ef471816ed6c3a24ae2e7234eeb60170759f7da4
4
+ data.tar.gz: 5f01f60e53337d61d8e0706df21bb1b1214d32b0
5
5
  SHA512:
6
- metadata.gz: bd5b41f2dd31727913a7cf6d043aa6d95d7736258a6996a3ebdb16efbef6176b0c24f554b1406258c933c6a62abb8b45a8c8db1ed5a78c69e74e2dc3bf92da43
7
- data.tar.gz: 185d83cf55c8a9778a15e17d1e5dece6ad317c973f7b1e912d4dcc22dbcead51e510d7045add8b2f6bb69ccefd72412965472fe4acc15c72defff99f415b076d
6
+ metadata.gz: 010fdf10d52c1079b0dee5992fe5c34eadd854d65195af1b1737da6dcacc77bdb99c47525a35bcddbaf6bc996dd66fc2bae2d1bc3f562e6168b9621dad7c54d2
7
+ data.tar.gz: 1e76b4c1fb64212de61999489c107d398fb47578a3bb13b6289b89d38cee086144f7881b49a9ab53f9a67ab137d20f0da21fa1eb4a6b15a07e4e552f7e5b6ddc
data/ChangeLog CHANGED
@@ -1,5 +1,8 @@
1
1
  CHANGELOG
2
2
 
3
+ 2015-08-01 1.6.1
4
+ * Search queries are now using POST requests
5
+
3
6
  2015-07-19 1.6.0
4
7
  * Ability to instantiate multiple API clients in the same process (was using a class variable before).
5
8
 
@@ -137,7 +137,8 @@ module Algolia
137
137
  # one is kept and others are removed.
138
138
  def search(query, params = {})
139
139
  encoded_params = Hash[params.map { |k,v| [k.to_s, v.is_a?(Array) ? v.to_json : v] }]
140
- client.get(Protocol.search_uri(name, query, encoded_params), :search)
140
+ encoded_params[:query] = query
141
+ client.post(Protocol.search_post_uri(name), { :params => Protocol.to_query(encoded_params) }.to_json, :search)
141
142
  end
142
143
 
143
144
  class IndexBrowser
@@ -189,9 +190,9 @@ module Algolia
189
190
  end
190
191
  IndexBrowser.new(client, name, params).browse(&block)
191
192
  else
192
- page ||= 0
193
+ pageOrQueryParameters ||= 0
193
194
  hitsPerPage ||= 1000
194
- client.get(Protocol.browse_uri(name, {:page => page, :hitsPerPage => hitsPerPage}), :read)
195
+ client.get(Protocol.browse_uri(name, {:page => pageOrQueryParameters, :hitsPerPage => hitsPerPage}), :read)
195
196
  end
196
197
  end
197
198
 
@@ -74,6 +74,10 @@ module Algolia
74
74
  "#{index_uri(index)}?query=#{CGI.escape(query)}&#{params}"
75
75
  end
76
76
 
77
+ def Protocol.search_post_uri(index)
78
+ "#{index_uri(index)}/query"
79
+ end
80
+
77
81
  def Protocol.browse_uri(index, params = {})
78
82
  params = params.nil? || params.size == 0 ? "" : "?#{to_query(params)}"
79
83
  "#{index_uri(index)}/browse#{params}"
@@ -1,3 +1,3 @@
1
1
  module Algolia
2
- VERSION = "1.6.0"
2
+ VERSION = "1.6.1"
3
3
  end
@@ -9,7 +9,6 @@ end
9
9
  WebMock.stub_request(:get, /.*\.algolia\.(io|net)\/1\/indexes/).to_return(:body => '{ "items": [] }')
10
10
  # query index
11
11
  WebMock.stub_request(:get, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+/).to_return(:body => '{ "hits": [ { "objectID": 42 } ], "page": 1, "hitsPerPage": 1 }')
12
- WebMock.stub_request(:post, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/query/).to_return(:body => '{}')
13
12
  # delete index
14
13
  WebMock.stub_request(:delete, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+/).to_return(:body => '{ "taskID": 42 }')
15
14
  # clear index
@@ -43,3 +42,5 @@ WebMock.stub_request(:post, /.*\.algolia\.(io|net)\/1\/keys/).to_return(:body =>
43
42
  WebMock.stub_request(:get, /.*\.algolia\.(io|net)\/1\/keys/).to_return(:body => '{ "keys": [] }')
44
43
  WebMock.stub_request(:get, /.*\.algolia\.(io|net)\/1\/keys\/[^\/]+/).to_return(:body => '{ }')
45
44
  WebMock.stub_request(:delete, /.*\.algolia\.(io|net)\/1\/keys\/[^\/]+/).to_return(:body => '{ }')
45
+ # query POST
46
+ WebMock.stub_request(:post, /.*\.algolia\.(io|net)\/1\/indexes\/[^\/]+\/query/).to_return(:body => '{ "hits": [ { "objectID": 42 } ], "page": 1, "hitsPerPage": 1 }')
@@ -10,7 +10,7 @@ describe 'With a rate limited client' do
10
10
  end
11
11
 
12
12
  it "should pass the right headers" do
13
- WebMock.stub_request(:get, %r{https://.*\.algolia\.(io|net)/1/indexes/friends\?query=.*}).
13
+ WebMock.stub_request(:post, %r{https://.*\.algolia\.(io|net)/1/indexes/friends/query}).
14
14
  with(:headers => {'Content-Type'=>'application/json; charset=utf-8', 'User-Agent'=>"Algolia for Ruby #{Algolia::VERSION}", 'X-Algolia-Api-Key'=>ENV['ALGOLIA_API_KEY'], 'X-Algolia-Application-Id'=>ENV['ALGOLIA_APPLICATION_ID'], 'X-Forwarded-Api-Key'=>'ratelimitapikey', 'X-Forwarded-For'=>'1.2.3.4'}).
15
15
  to_return(:status => 200, :body => "{ \"hits\": [], \"fakeAttribute\": 1 }", :headers => {})
16
16
  Algolia.enable_rate_limit_forward ENV['ALGOLIA_API_KEY'], "1.2.3.4", "ratelimitapikey"
@@ -20,7 +20,7 @@ describe 'With a rate limited client' do
20
20
  end
21
21
 
22
22
  it "should use original headers" do
23
- WebMock.stub_request(:get, %r{https://.*\.algolia\.(io|net)/1/indexes/friends\?query=.*}).
23
+ WebMock.stub_request(:post, %r{https://.*\.algolia\.(io|net)/1/indexes/friends/query}).
24
24
  with(:headers => {'Content-Type'=>'application/json; charset=utf-8', 'User-Agent'=>"Algolia for Ruby #{Algolia::VERSION}", 'X-Algolia-Api-Key'=>ENV['ALGOLIA_API_KEY'], 'X-Algolia-Application-Id'=>ENV['ALGOLIA_APPLICATION_ID'] }).
25
25
  to_return(:status => 200, :body => "{ \"hits\": [], \"fakeAttribute\": 2 }", :headers => {})
26
26
  Algolia.disable_rate_limit_forward
@@ -29,7 +29,7 @@ describe 'With a rate limited client' do
29
29
  end
30
30
 
31
31
  it "should pass the right headers in the scope" do
32
- WebMock.stub_request(:get, %r{https://.*\.algolia\.(io|net)/1/indexes/friends\?query=.*}).
32
+ WebMock.stub_request(:post, %r{https://.*\.algolia\.(io|net)/1/indexes/friends/query}).
33
33
  with(:headers => {'Content-Type'=>'application/json; charset=utf-8', 'User-Agent'=>"Algolia for Ruby #{Algolia::VERSION}", 'X-Algolia-Api-Key'=>ENV['ALGOLIA_API_KEY'], 'X-Algolia-Application-Id'=>ENV['ALGOLIA_APPLICATION_ID'], 'X-Forwarded-Api-Key'=>'ratelimitapikey', 'X-Forwarded-For'=>'1.2.3.4'}).
34
34
  to_return(:status => 200, :body => "{ \"hits\": [], \"fakeAttribute\": 1 }", :headers => {})
35
35
  Algolia.with_rate_limits "1.2.3.4", "ratelimitapikey" do
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.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-19 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient