Commit c55f5fbd5ef186c76beffc987064e4e4b7e578b6

Authored by Andrew
1 parent a876251e

More flexibility with _not [skip ci]

Showing 2 changed files with 6 additions and 1 deletions   Show diff stats
lib/searchkick/query.rb
... ... @@ -852,7 +852,7 @@ module Searchkick
852 852 }
853 853 when :regexp # support for regexp queries without using a regexp ruby object
854 854 filters << {regexp: {field => {value: op_value}}}
855   - when :not # not equal
  855 + when :not, :_not # not equal
856 856 filters << {bool: {must_not: term_filters(field, op_value)}}
857 857 when :all
858 858 op_value.each do |val|
... ...
test/where_test.rb
... ... @@ -31,7 +31,9 @@ class WhereTest &lt; Minitest::Test
31 31 assert_search "product", ["Product A"], where: {store_id: 1...2}
32 32 assert_search "product", ["Product A", "Product B"], where: {store_id: [1, 2]}
33 33 assert_search "product", ["Product B", "Product C", "Product D"], where: {store_id: {not: 1}}
  34 + assert_search "product", ["Product B", "Product C", "Product D"], where: {store_id: {_not: 1}}
34 35 assert_search "product", ["Product C", "Product D"], where: {store_id: {not: [1, 2]}}
  36 + assert_search "product", ["Product C", "Product D"], where: {store_id: {_not: [1, 2]}}
35 37 assert_search "product", ["Product A"], where: {user_ids: {lte: 2, gte: 2}}
36 38  
37 39 # or
... ... @@ -56,12 +58,15 @@ class WhereTest &lt; Minitest::Test
56 58  
57 59 # any / nested terms
58 60 assert_search "product", ["Product B", "Product C"], where: {user_ids: {not: [2], in: [1, 3]}}
  61 + assert_search "product", ["Product B", "Product C"], where: {user_ids: {_not: [2], in: [1, 3]}}
59 62  
60 63 # not / exists
61 64 assert_search "product", ["Product D"], where: {user_ids: nil}
62 65 assert_search "product", ["Product A", "Product B", "Product C"], where: {user_ids: {not: nil}}
  66 + assert_search "product", ["Product A", "Product B", "Product C"], where: {user_ids: {_not: nil}}
63 67 assert_search "product", ["Product A", "Product C", "Product D"], where: {user_ids: [3, nil]}
64 68 assert_search "product", ["Product B"], where: {user_ids: {not: [3, nil]}}
  69 + assert_search "product", ["Product B"], where: {user_ids: {_not: [3, nil]}}
65 70 end
66 71  
67 72 def test_regexp
... ...