Commit 2a6ea1cda9a6b9aefb1406d8a097db6e5c8a65ce
1 parent
b9f5e2ca
Exists in
master
and in
19 other branches
Added scope_results option
Showing
4 changed files
with
15 additions
and
2 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/query.rb
... | ... | @@ -19,7 +19,7 @@ module Searchkick |
19 | 19 | :boost_by, :boost_by_distance, :boost_where, :conversions, :conversions_term, :debug, :emoji, :exclude, :execute, :explain, |
20 | 20 | :fields, :highlight, :includes, :index_name, :indices_boost, :limit, :load, |
21 | 21 | :match, :misspellings, :model_includes, :offset, :operator, :order, :padding, :page, :per_page, :profile, |
22 | - :request_params, :routing, :select, :similar, :smart_aggs, :suggest, :track, :type, :where] | |
22 | + :request_params, :routing, :scope_results, :select, :similar, :smart_aggs, :suggest, :track, :type, :where] | |
23 | 23 | raise ArgumentError, "unknown keywords: #{unknown_keywords.join(", ")}" if unknown_keywords.any? |
24 | 24 | |
25 | 25 | term = term.to_s |
... | ... | @@ -113,7 +113,8 @@ module Searchkick |
113 | 113 | match_suffix: @match_suffix, |
114 | 114 | highlighted_fields: @highlighted_fields || [], |
115 | 115 | misspellings: @misspellings, |
116 | - term: term | |
116 | + term: term, | |
117 | + scope_results: options[:scope_results] | |
117 | 118 | } |
118 | 119 | |
119 | 120 | if options[:debug] | ... | ... |
lib/searchkick/results.rb
test/sql_test.rb
... | ... | @@ -211,4 +211,11 @@ class SqlTest < Minitest::Test |
211 | 211 | assert records.first.association(associations[klass].first).loaded? |
212 | 212 | end |
213 | 213 | end |
214 | + | |
215 | + def test_scope_results | |
216 | + skip unless defined?(ActiveRecord) | |
217 | + | |
218 | + store_names ["Product A", "Product B"] | |
219 | + assert_search "product", ["Product A"], scope_results: ->(r) { r.where(name: "Product A") } | |
220 | + end | |
214 | 221 | end | ... | ... |