Commit 7c2a7e6531ccb787369d98b3c627991f233efbb5
1 parent
3868a25e
Exists in
master
and in
21 other branches
Do not limit results
Showing
2 changed files
with
9 additions
and
3 deletions
Show diff stats
lib/searchkick/search.rb
... | ... | @@ -26,8 +26,8 @@ module Searchkick |
26 | 26 | |
27 | 27 | # pagination |
28 | 28 | page = options.has_key?(:page) ? [options[:page].to_i, 1].max : nil |
29 | - per_page = options[:limit] || options[:per_page] | |
30 | - offset = options[:offset] || (page && per_page && (page - 1) * per_page) | |
29 | + per_page = options[:limit] || options[:per_page] || 100000 | |
30 | + offset = options[:offset] || (page && (page - 1) * per_page) | |
31 | 31 | index_name = options[:index_name] || index.name |
32 | 32 | |
33 | 33 | # TODO lose Tire DSL for more flexibility |
... | ... | @@ -85,7 +85,7 @@ module Searchkick |
85 | 85 | score_mode "total" |
86 | 86 | end |
87 | 87 | end |
88 | - size per_page if per_page | |
88 | + size per_page | |
89 | 89 | from offset if offset |
90 | 90 | explain options[:explain] if options[:explain] |
91 | 91 | ... | ... |
test/sql_test.rb
... | ... | @@ -7,6 +7,12 @@ class TestSql < Minitest::Unit::TestCase |
7 | 7 | assert_order "product", ["Product A", "Product B"], order: {name: :asc}, limit: 2 |
8 | 8 | end |
9 | 9 | |
10 | + def test_no_limit | |
11 | + names = 20.times.map{|i| "Product #{i}" } | |
12 | + store_names names | |
13 | + assert_search "product", names | |
14 | + end | |
15 | + | |
10 | 16 | def test_offset |
11 | 17 | store_names ["Product A", "Product B", "Product C", "Product D"] |
12 | 18 | assert_order "product", ["Product C", "Product D"], order: {name: :asc}, offset: 2 | ... | ... |