Commit 92894b882e26eb422e6b9616ac3c320124164dd4

Authored by Andrew Kane
1 parent 95857699

Renamed operator to all

CHANGELOG.md
1 1 ## 0.3.5 [unreleased]
2 2  
3 3 - Added facet ranges
  4 +- Add all operator
4 5  
5 6 ## 0.3.4
6 7  
... ...
README.md
... ... @@ -85,9 +85,9 @@ where: {
85 85 expires_at: {gt: Time.now}, # lt, gte, lte also available
86 86 orders_count: 1..10, # equivalent to {gte: 1, lte: 10}
87 87 aisle_id: [25, 30], # in
88   - aisle_id: {and: [1,3]} # and
89 88 store_id: {not: 2}, # not
90 89 aisle_id: {not: [25, 30]}, # not in
  90 + user_ids: {all: [1, 3]}, # all elements in array
91 91 or: [
92 92 [{in_stock: true}, {backordered: true}]
93 93 ]
... ...
lib/searchkick/search.rb
... ... @@ -201,8 +201,8 @@ module Searchkick
201 201 else
202 202 filters << {not: {term: {field => op_value}}}
203 203 end
204   - elsif op == :and
205   - filters << {terms: {field => op_value, execution: 'and'}}
  204 + elsif op == :all
  205 + filters << {terms: {field => op_value, execution: "and"}}
206 206 else
207 207 range_query =
208 208 case op
... ...
test/sql_test.rb
... ... @@ -64,10 +64,9 @@ class TestSql &lt; Minitest::Unit::TestCase
64 64 assert_search "product", ["Product A", "Product B", "Product C"], where: {or: [[{in_stock: true}, {store_id: 3}]]}
65 65 assert_search "product", ["Product A", "Product B", "Product C"], where: {or: [[{orders_count: [2, 4]}, {store_id: [1, 2]}]]}
66 66 assert_search "product", ["Product A", "Product D"], where: {or: [[{orders_count: 1}, {created_at: {gte: now - 1}, backordered: true}]]}
67   - # array
68   - assert_search "product", ["Product A"], where: {user_ids: { and: [1,3]}}
69   - assert_search "product", [], where: { where_ids: { and: [1,2,3,4] } }
70   - assert_search "product", ["Product A"], where: {user_ids: 2}
  67 + # all
  68 + assert_search "product", ["Product A"], where: {user_ids: {all: [1, 3]}}
  69 + assert_search "product", [], where: {user_ids: {all: [1, 2, 3, 4]}}
71 70 end
72 71  
73 72 def test_where_string
... ...