waistband 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -136,11 +136,12 @@ module Waistband
136
136
  def search(body_hash)
137
137
  page, page_size = get_page_info body_hash
138
138
  body_hash = parse_search_body(body_hash)
139
+ search_hash = {index: config_name, body: body_hash}
139
140
 
140
- search_hash = client.search(
141
- index: config_name,
142
- body: body_hash
143
- )
141
+ search_hash[:from] = body_hash[:from] if body_hash[:from]
142
+ search_hash[:size] = body_hash[:size] if body_hash[:size]
143
+
144
+ search_hash = client.search(search_hash)
144
145
 
145
146
  ::Waistband::SearchResults.new(search_hash, page: page, page_size: page_size)
146
147
  end
@@ -1,3 +1,3 @@
1
1
  module Waistband
2
- VERSION = "0.11.0"
2
+ VERSION = "0.11.1"
3
3
  end
@@ -112,6 +112,41 @@ describe Waistband::Index do
112
112
  expect(results.instance_variable_get('@page_size')).to eql 999
113
113
  end
114
114
 
115
+ describe 'with results' do
116
+
117
+ before do
118
+ index.delete
119
+ index.create
120
+ index.refresh
121
+
122
+ index.save('__test_write1', {'data' => 'index_1'})
123
+ index.save('__test_write2', {'data' => 'index_2'})
124
+ index.save('__test_write3', {'data' => 'index_3'})
125
+ index.save('__test_write4', {'data' => 'index_4'})
126
+ index.refresh
127
+ end
128
+
129
+ it "respects paginating when fetching hits" do
130
+ query = index.search(page: 1, page_size: 10)
131
+ expect(query.hits.size).to eql 4
132
+
133
+ query = index.search(page: 2, page_size: 10)
134
+ expect(query.hits.size).to eql 0
135
+
136
+ query = index.search(page: 1, page_size: 2)
137
+ expect(query.hits.size).to eql 2
138
+ end
139
+
140
+ it "paginates when not passing in a page number" do
141
+ query = index.search(page_size: 10)
142
+ expect(query.hits.size).to eql 4
143
+
144
+ query = index.search(page_size: 2)
145
+ expect(query.hits.size).to eql 2
146
+ end
147
+
148
+ end
149
+
115
150
  end
116
151
 
117
152
  describe 'subindexes' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waistband
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: