elastic_record 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/elastic_record.gemspec +1 -1
- data/lib/elastic_record/relation.rb +1 -0
- data/lib/elastic_record/relation/none.rb +21 -0
- data/lib/elastic_record/relation/search_methods.rb +4 -4
- data/test/elastic_record/relation/none_test.rb +16 -0
- data/test/elastic_record/relation/search_methods_test.rb +4 -18
- data/test/elastic_record/relation_test.rb +1 -0
- metadata +3 -1
data/elastic_record.gemspec
CHANGED
@@ -3,6 +3,7 @@ require 'elastic_record/relation/batches'
|
|
3
3
|
require 'elastic_record/relation/delegation'
|
4
4
|
require 'elastic_record/relation/finder_methods'
|
5
5
|
require 'elastic_record/relation/merging'
|
6
|
+
require 'elastic_record/relation/none'
|
6
7
|
require 'elastic_record/relation/search_methods'
|
7
8
|
|
8
9
|
module ElasticRecord
|
@@ -43,10 +43,6 @@ 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
|
-
|
50
46
|
def limit!(value)
|
51
47
|
self.limit_value = value
|
52
48
|
self
|
@@ -114,6 +110,10 @@ module ElasticRecord
|
|
114
110
|
clone.extending!(*modules, &block)
|
115
111
|
end
|
116
112
|
|
113
|
+
def none
|
114
|
+
extending(None)
|
115
|
+
end
|
116
|
+
|
117
117
|
def as_elastic
|
118
118
|
build_search.as_elastic
|
119
119
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class ElasticRecord::Relation::NoneTest < MiniTest::Spec
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
Widget.elastic_index.reset
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_none
|
10
|
+
none = Widget.elastic_relation.none
|
11
|
+
|
12
|
+
assert_equal 0, none.size
|
13
|
+
assert_equal 0, none.count
|
14
|
+
assert_equal [], none.to_a
|
15
|
+
end
|
16
|
+
end
|
@@ -57,24 +57,6 @@ 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
|
-
|
78
60
|
def test_query_with_only_query
|
79
61
|
relation.query!('foo')
|
80
62
|
|
@@ -210,6 +192,10 @@ class ElasticRecord::Relation::SearchMethodsTest < MiniTest::Spec
|
|
210
192
|
assert_equal 'bar', relation.bar
|
211
193
|
end
|
212
194
|
|
195
|
+
def test_none
|
196
|
+
assert_kind_of ElasticRecord::Relation::None, relation.none
|
197
|
+
end
|
198
|
+
|
213
199
|
private
|
214
200
|
def relation
|
215
201
|
@relation ||= Widget.elastic_relation
|
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.8.
|
4
|
+
version: 0.8.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/elastic_record/relation/delegation.rb
|
77
77
|
- lib/elastic_record/relation/finder_methods.rb
|
78
78
|
- lib/elastic_record/relation/merging.rb
|
79
|
+
- lib/elastic_record/relation/none.rb
|
79
80
|
- lib/elastic_record/relation/search_methods.rb
|
80
81
|
- lib/elastic_record/relation/value_methods.rb
|
81
82
|
- lib/elastic_record/searching.rb
|
@@ -95,6 +96,7 @@ files:
|
|
95
96
|
- test/elastic_record/relation/delegation_test.rb
|
96
97
|
- test/elastic_record/relation/finder_methods_test.rb
|
97
98
|
- test/elastic_record/relation/merging_test.rb
|
99
|
+
- test/elastic_record/relation/none_test.rb
|
98
100
|
- test/elastic_record/relation/search_methods_test.rb
|
99
101
|
- test/elastic_record/relation_test.rb
|
100
102
|
- test/elastic_record/searching_test.rb
|