elastic_record 0.6.9 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -58,6 +58,11 @@ An Arelastic object can also be passed in, working similarily to Arel:
58
58
 
59
59
  Helpful Arel builders can be found at https://github.com/matthuhiggins/arelastic/blob/master/lib/arelastic/builders/filter.rb.
60
60
 
61
+ Lastly, negation is made easy with negate:
62
+
63
+ # Status is not active
64
+ search.negate(status: 'active')
65
+
61
66
  === Querying
62
67
 
63
68
  To create a query string, pass a string to search.query:
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'elastic_record'
5
- s.version = '0.6.9'
5
+ s.version = '0.7.0'
6
6
  s.summary = 'Use Elastic Search with your objects'
7
7
  s.description = 'Find your records with elastic search'
8
8
 
@@ -43,6 +43,10 @@ module ElasticRecord
43
43
  clone.filter!(*args)
44
44
  end
45
45
 
46
+ def negate(*args)
47
+ filter args.map { |arg| arelastic.filter.not arg }
48
+ end
49
+
46
50
  def limit!(value)
47
51
  self.limit_value = value
48
52
  self
@@ -57,6 +57,24 @@ class ElasticRecord::Relation::SearchMethodsTest < MiniTest::Spec
57
57
  assert_equal expected, relation.as_elastic['query']
58
58
  end
59
59
 
60
+ def test_negate
61
+ search = relation.negate("prefix" => {"name" => "Jo"})
62
+
63
+ expected = {
64
+ "constant_score" => {
65
+ "filter" => {
66
+ "not" => {
67
+ "prefix" => {
68
+ "name" => "Jo"
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+
75
+ assert_equal expected, search.as_elastic['query']
76
+ end
77
+
60
78
  def test_query_with_only_query
61
79
  relation.query!('foo')
62
80
 
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.6.9
4
+ version: 0.7.0
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-09-27 00:00:00.000000000 Z
12
+ date: 2012-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: arelastic