algoliasearch 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +3 -0
- data/lib/algolia/index.rb +4 -3
- data/lib/algolia/protocol.rb +4 -0
- data/lib/algolia/version.rb +1 -1
- data/lib/algolia/webmock.rb +2 -1
- data/spec/stub_spec.rb +3 -3
- 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: ef471816ed6c3a24ae2e7234eeb60170759f7da4
|
4
|
+
data.tar.gz: 5f01f60e53337d61d8e0706df21bb1b1214d32b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 010fdf10d52c1079b0dee5992fe5c34eadd854d65195af1b1737da6dcacc77bdb99c47525a35bcddbaf6bc996dd66fc2bae2d1bc3f562e6168b9621dad7c54d2
|
7
|
+
data.tar.gz: 1e76b4c1fb64212de61999489c107d398fb47578a3bb13b6289b89d38cee086144f7881b49a9ab53f9a67ab137d20f0da21fa1eb4a6b15a07e4e552f7e5b6ddc
|
data/ChangeLog
CHANGED
data/lib/algolia/index.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
193
|
+
pageOrQueryParameters ||= 0
|
193
194
|
hitsPerPage ||= 1000
|
194
|
-
client.get(Protocol.browse_uri(name, {:page =>
|
195
|
+
client.get(Protocol.browse_uri(name, {:page => pageOrQueryParameters, :hitsPerPage => hitsPerPage}), :read)
|
195
196
|
end
|
196
197
|
end
|
197
198
|
|
data/lib/algolia/protocol.rb
CHANGED
@@ -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}"
|
data/lib/algolia/version.rb
CHANGED
data/lib/algolia/webmock.rb
CHANGED
@@ -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 }')
|
data/spec/stub_spec.rb
CHANGED
@@ -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(:
|
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(:
|
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(:
|
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.
|
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-
|
11
|
+
date: 2015-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|