Commit 41eacc6691baf301334d43db4d62e16c87a71d90
1 parent
72fe2ae4
Exists in
relation
and in
1 other branch
Added exclude [skip ci]
Showing
2 changed files
with
10 additions
and
0 deletions
Show diff stats
lib/searchkick/relation.rb
... | ... | @@ -327,6 +327,15 @@ module Searchkick |
327 | 327 | self |
328 | 328 | end |
329 | 329 | |
330 | + def exclude(*args) | |
331 | + spawn.exclude!(*args) | |
332 | + end | |
333 | + | |
334 | + def exclude!(*args) | |
335 | + options[:exclude] = Array(options[:exclude]) + args | |
336 | + self | |
337 | + end | |
338 | + | |
330 | 339 | # same as Active Record |
331 | 340 | def inspect |
332 | 341 | entries = results.first(11).map!(&:inspect) | ... | ... |
test/match_test.rb
... | ... | @@ -175,6 +175,7 @@ class MatchTest < Minitest::Test |
175 | 175 | def test_exclude_butter |
176 | 176 | store_names ["Butter Tub", "Peanut Butter Tub"] |
177 | 177 | assert_search "butter", ["Butter Tub"], exclude: ["peanut butter"] |
178 | + assert_search_relation ["Butter Tub"], Product.search("butter", relation: true).exclude("peanut butter") | |
178 | 179 | end |
179 | 180 | |
180 | 181 | def test_exclude_butter_word_start | ... | ... |