waistband 0.11.0 → 0.11.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.
- data/lib/waistband/index.rb +5 -4
- data/lib/waistband/version.rb +1 -1
- data/spec/lib/index_spec.rb +35 -0
- metadata +1 -1
data/lib/waistband/index.rb
CHANGED
|
@@ -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 =
|
|
141
|
-
|
|
142
|
-
|
|
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
|
data/lib/waistband/version.rb
CHANGED
data/spec/lib/index_spec.rb
CHANGED
|
@@ -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
|