elastic_record 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -161,6 +161,8 @@ module ElasticRecord
161
161
  case terms
162
162
  when Array, Range
163
163
  nodes << arelastic[field].in(terms)
164
+ when Hash
165
+ nodes << {field => terms}
164
166
  else
165
167
  nodes << arelastic[field].eq(terms)
166
168
  end
@@ -25,7 +25,7 @@ class ElasticRecord::Relation::SearchMethodsTest < MiniTest::Spec
25
25
  assert_equal expected, relation.as_elastic['query']
26
26
  end
27
27
 
28
- def test_query_with_range_filter
28
+ def test_filter_with_arelastic
29
29
  relation.filter!(Widget.arelastic['faz'].in 3..5)
30
30
 
31
31
  expected = {
@@ -41,6 +41,22 @@ class ElasticRecord::Relation::SearchMethodsTest < MiniTest::Spec
41
41
  assert_equal expected, relation.as_elastic['query']
42
42
  end
43
43
 
44
+ def test_filter_with_hash
45
+ relation.filter!("prefix" => {"name" => "Jo"})
46
+
47
+ expected = {
48
+ "constant_score" => {
49
+ "filter" => {
50
+ "prefix" => {
51
+ "name" => "Jo"
52
+ }
53
+ }
54
+ }
55
+ }
56
+
57
+ assert_equal expected, relation.as_elastic['query']
58
+ end
59
+
44
60
  def test_query_with_only_query
45
61
  relation.query!('foo')
46
62
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-13 00:00:00.000000000 Z
12
+ date: 2012-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: arelastic