diff --git a/lib/searchkick/relation.rb b/lib/searchkick/relation.rb index 2d241b7..f2b9e88 100644 --- a/lib/searchkick/relation.rb +++ b/lib/searchkick/relation.rb @@ -87,6 +87,15 @@ module Searchkick self end + def none + spawn.none! + end + + def none! + options[:limit] = 0 # TODO use where? + self + end + def select(*fields, &block) if block_given? # TODO better error message diff --git a/test/relation_test.rb b/test/relation_test.rb index 9407a0f..359b42f 100644 --- a/test/relation_test.rb +++ b/test/relation_test.rb @@ -17,6 +17,11 @@ class RelationTest < Minitest::Test assert_search_relation [], Product.search("*").where(name: "Product A").where(name: "Product B") end + def test_none + store_names ["Product A", "Product B"] + assert_search_relation [], Product.search("*").none + end + def test_parameters skip unless defined?(ActiveRecord) require "action_controller" -- libgit2 0.21.0