algolia 2.0.0.pre.beta.1 → 2.0.0.pre.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/algolia/config/base_config.rb +1 -1
- data/lib/algolia/error.rb +1 -2
- data/lib/algolia/iterators/object_iterator.rb +5 -4
- data/lib/algolia/iterators/paginator_iterator.rb +5 -3
- data/lib/algolia/search_index.rb +1 -1
- data/lib/algolia/version.rb +1 -1
- data/test/algolia/unit/algolia_config_test.rb +1 -1
- data/upgrade_guide.md +8 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4645e42bf97d367a91ac73d59c440bc8f07d34c969df2d16ca3d6fac652f14f9
|
4
|
+
data.tar.gz: 2188142202397e4e56dbe7b77d635b439794ebf6401472e83907ab078e593a45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edb4691eaa9e505a1e014e58232edffb0c6fdb62686f52b90c597b037392e81c1af98c7e339f017ad5b1ecab916d07336cf31c734832838d7648fcab82e2fe82
|
7
|
+
data.tar.gz: c9d8da55b0599118d3153ca84e1bf34f909cf128c101b5480ffff64213253e45685daef451ee48e15410737319efd6dea5f75768b3e2c0af0947160b1304473e
|
@@ -33,7 +33,7 @@ module Algolia
|
|
33
33
|
@write_timeout = opts[:write_timeout] || Defaults::WRITE_TIMEOUT
|
34
34
|
@connect_timeout = opts[:connect_timeout] || Defaults::CONNECT_TIMEOUT
|
35
35
|
@compression_type = opts[:compression_type] || Defaults::NONE_ENCODING
|
36
|
-
@symbolize_keys = opts[:symbolize_keys]
|
36
|
+
@symbolize_keys = opts.has_key?(:symbolize_keys) ? opts[:symbolize_keys] : true
|
37
37
|
end
|
38
38
|
|
39
39
|
def set_extra_header(key, value)
|
data/lib/algolia/error.rb
CHANGED
@@ -7,16 +7,17 @@ module Algolia
|
|
7
7
|
data = {}
|
8
8
|
|
9
9
|
if @response
|
10
|
-
|
11
|
-
|
10
|
+
parsed_response = symbolize_hash(@response)
|
11
|
+
if parsed_response[:hits].length
|
12
|
+
parsed_response[:hits].each do |hit|
|
12
13
|
yield hit
|
13
14
|
end
|
14
15
|
|
15
|
-
if
|
16
|
+
if parsed_response[:cursor].nil?
|
16
17
|
@response = nil
|
17
18
|
raise StopIteration
|
18
19
|
else
|
19
|
-
data[:cursor] =
|
20
|
+
data[:cursor] = parsed_response[:cursor]
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
@@ -16,13 +16,15 @@ module Algolia
|
|
16
16
|
def each
|
17
17
|
loop do
|
18
18
|
if @response
|
19
|
-
|
20
|
-
|
19
|
+
parsed_response = symbolize_hash(@response)
|
20
|
+
parsed_data = symbolize_hash(@data)
|
21
|
+
if parsed_response[:hits].length
|
22
|
+
parsed_response[:hits].each do |hit|
|
21
23
|
hit.delete(:_highlightResult)
|
22
24
|
yield hit
|
23
25
|
end
|
24
26
|
|
25
|
-
if
|
27
|
+
if parsed_response[:nbHits] < parsed_data[:hitsPerPage]
|
26
28
|
@response = nil
|
27
29
|
@data = {
|
28
30
|
hitsPerPage: 1000,
|
data/lib/algolia/search_index.rb
CHANGED
@@ -115,7 +115,7 @@ module Algolia
|
|
115
115
|
has_next_page = true
|
116
116
|
while has_next_page
|
117
117
|
request_options[:page] = page
|
118
|
-
res = search(query, request_options)
|
118
|
+
res = symbolize_hash(search(query, request_options))
|
119
119
|
|
120
120
|
res[:hits].each_with_index do |hit, i|
|
121
121
|
if callback.call(hit)
|
data/lib/algolia/version.rb
CHANGED
@@ -4,7 +4,7 @@ require 'test_helper'
|
|
4
4
|
class AlgoliaConfigTest
|
5
5
|
describe 'set an extra header' do
|
6
6
|
def before_all
|
7
|
-
@config = Algolia::
|
7
|
+
@config = Algolia::BaseConfig.new(application_id: 'app_id', api_key: 'api_key')
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_set_extra_header
|
data/upgrade_guide.md
CHANGED
@@ -43,6 +43,12 @@ client = Algolia::Search::Client.create_with_config(search_config)
|
|
43
43
|
index = client.init_index('index_name')
|
44
44
|
```
|
45
45
|
|
46
|
+
By default the keys of the response hashes are symbols. If you wish to change that for strings, use the following configuration
|
47
|
+
```ruby
|
48
|
+
search_config = Algolia::Search::Config.new(application_id: app_id, api_key: api_key, symbolize_keys: false)
|
49
|
+
client = Algolia::Search::Client.create_with_config(search_config)
|
50
|
+
```
|
51
|
+
|
46
52
|
## Search parameters and request options
|
47
53
|
The search parameters and request options are still optional, but they are combined into a single hash instead of two.
|
48
54
|
For example:
|
@@ -66,13 +72,13 @@ index.search('query', opts)
|
|
66
72
|
### `Client`
|
67
73
|
|
68
74
|
#### `set_extra_header`
|
69
|
-
The `set_extra_header` method has been moved from the Client to the `Algolia::
|
75
|
+
The `set_extra_header` method has been moved from the Client to the `Algolia::BaseConfig` class. You have to define your extra headers on Client instantiation.
|
70
76
|
```ruby
|
71
77
|
# Before
|
72
78
|
client.set_extra_header('admin', 'admin-key')
|
73
79
|
|
74
80
|
# After
|
75
|
-
# `Algolia::Search::Config` inherits from `Algolia::
|
81
|
+
# `Algolia::Search::Config` inherits from `Algolia::BaseConfig`
|
76
82
|
config = Algolia::Search::Config.new(app_id: 'APP_ID', api_key: 'API_KEY')
|
77
83
|
config.set_extra_header('admin', 'admin-key')
|
78
84
|
|