chewy 0.1.0 → 0.2.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.
Files changed (55) hide show
  1. checksums.yaml +5 -13
  2. data/.travis.yml +3 -2
  3. data/CHANGELOG.md +28 -2
  4. data/README.md +156 -7
  5. data/filters +6 -4
  6. data/lib/chewy/index.rb +114 -18
  7. data/lib/chewy/index/actions.rb +117 -14
  8. data/lib/chewy/index/aliases.rb +21 -0
  9. data/lib/chewy/query.rb +5 -5
  10. data/lib/chewy/query/compose.rb +59 -0
  11. data/lib/chewy/query/criteria.rb +8 -55
  12. data/lib/chewy/query/{context.rb → filters.rb} +60 -7
  13. data/lib/chewy/query/loading.rb +1 -1
  14. data/lib/chewy/query/nodes/has_child.rb +14 -0
  15. data/lib/chewy/query/nodes/has_parent.rb +14 -0
  16. data/lib/chewy/query/nodes/has_relation.rb +61 -0
  17. data/lib/chewy/query/nodes/match_all.rb +11 -0
  18. data/lib/chewy/railtie.rb +2 -2
  19. data/lib/chewy/rspec/update_index.rb +1 -0
  20. data/lib/chewy/type.rb +1 -1
  21. data/lib/chewy/type/adapter/active_record.rb +28 -12
  22. data/lib/chewy/type/adapter/object.rb +12 -2
  23. data/lib/chewy/type/import.rb +60 -20
  24. data/lib/chewy/type/wrapper.rb +1 -1
  25. data/lib/chewy/version.rb +1 -1
  26. data/lib/tasks/chewy.rake +41 -8
  27. data/spec/chewy/index/actions_spec.rb +282 -2
  28. data/spec/chewy/index/aliases_spec.rb +50 -0
  29. data/spec/chewy/index_spec.rb +64 -0
  30. data/spec/chewy/query/criteria_spec.rb +11 -11
  31. data/spec/chewy/query/{context_spec.rb → filters_spec.rb} +2 -2
  32. data/spec/chewy/query/loading_spec.rb +5 -3
  33. data/spec/chewy/query/nodes/and_spec.rb +1 -1
  34. data/spec/chewy/query/nodes/bool_spec.rb +1 -1
  35. data/spec/chewy/query/nodes/equal_spec.rb +1 -1
  36. data/spec/chewy/query/nodes/exists_spec.rb +1 -1
  37. data/spec/chewy/query/nodes/has_child_spec.rb +40 -0
  38. data/spec/chewy/query/nodes/has_parent_spec.rb +40 -0
  39. data/spec/chewy/query/nodes/match_all_spec.rb +11 -0
  40. data/spec/chewy/query/nodes/missing_spec.rb +1 -1
  41. data/spec/chewy/query/nodes/not_spec.rb +1 -1
  42. data/spec/chewy/query/nodes/or_spec.rb +1 -1
  43. data/spec/chewy/query/nodes/prefix_spec.rb +1 -1
  44. data/spec/chewy/query/nodes/query_spec.rb +1 -1
  45. data/spec/chewy/query/nodes/range_spec.rb +1 -1
  46. data/spec/chewy/query/nodes/raw_spec.rb +1 -1
  47. data/spec/chewy/query/nodes/regexp_spec.rb +1 -1
  48. data/spec/chewy/query/nodes/script_spec.rb +1 -1
  49. data/spec/chewy/query/pagination_spec.rb +7 -7
  50. data/spec/chewy/query_spec.rb +60 -0
  51. data/spec/chewy/type/adapter/active_record_spec.rb +68 -9
  52. data/spec/chewy/type/adapter/object_spec.rb +18 -0
  53. data/spec/chewy/type/import_spec.rb +87 -2
  54. data/spec/spec_helper.rb +1 -0
  55. metadata +47 -33
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chewy::Index::Aliases do
4
+ include ClassHelpers
5
+ before { Chewy::Index.client.indices.delete }
6
+
7
+ before { stub_index :dummies }
8
+
9
+ describe '.indexes' do
10
+ specify { DummiesIndex.indexes.should == [] }
11
+
12
+ context do
13
+ before { DummiesIndex.create! }
14
+ specify { DummiesIndex.indexes.should == [] }
15
+ end
16
+
17
+ context do
18
+ before { DummiesIndex.create! }
19
+ before { Chewy.client.indices.put_alias index: 'dummies', name: 'dummies_2013' }
20
+ specify { DummiesIndex.indexes.should == [] }
21
+ end
22
+
23
+ context do
24
+ before { DummiesIndex.create! '2013' }
25
+ before { DummiesIndex.create! '2014' }
26
+ specify { DummiesIndex.indexes.should =~ ['dummies_2013', 'dummies_2014'] }
27
+ end
28
+ end
29
+
30
+ describe '.aliases' do
31
+ specify { DummiesIndex.aliases.should == [] }
32
+
33
+ context do
34
+ before { DummiesIndex.create! }
35
+ specify { DummiesIndex.aliases.should == [] }
36
+ end
37
+
38
+ context do
39
+ before { DummiesIndex.create! }
40
+ before { Chewy.client.indices.put_alias index: 'dummies', name: 'dummies_2013' }
41
+ before { Chewy.client.indices.put_alias index: 'dummies', name: 'dummies_2014' }
42
+ specify { DummiesIndex.aliases.should =~ ['dummies_2013', 'dummies_2014'] }
43
+ end
44
+
45
+ context do
46
+ before { DummiesIndex.create! '2013' }
47
+ specify { DummiesIndex.aliases.should == [] }
48
+ end
49
+ end
50
+ end
@@ -22,6 +22,21 @@ describe Chewy::Index do
22
22
  end
23
23
  end
24
24
 
25
+ describe '.define_type' do
26
+ specify { DummiesIndex.type_hash['dummy'].should == DummiesIndex::Dummy }
27
+
28
+ context do
29
+ before { stub_index(:dummies) { define_type :dummy, name: :borogoves } }
30
+ specify { DummiesIndex.type_hash['borogoves'].should == DummiesIndex::Borogoves }
31
+ end
32
+
33
+ context do
34
+ before { stub_model(:city) }
35
+ before { stub_index(:dummies) { define_type City, name: :country } }
36
+ specify { DummiesIndex.type_hash['country'].should == DummiesIndex::Country }
37
+ end
38
+ end
39
+
25
40
  describe '.type_hash' do
26
41
  specify { DummiesIndex.type_hash['dummy'].should == DummiesIndex::Dummy }
27
42
  specify { DummiesIndex.type_hash.should have_key 'dummy' }
@@ -42,6 +57,20 @@ describe Chewy::Index do
42
57
  specify { Class.new(Chewy::Index) { index_name :myindex }.index_name.should == 'myindex' }
43
58
  specify { stub_const('DeveloperIndex', Class.new(Chewy::Index)).index_name.should == 'developer' }
44
59
  specify { stub_const('DevelopersIndex', Class.new(Chewy::Index)).index_name.should == 'developers' }
60
+
61
+ context do
62
+ before { Chewy.stub(client_options: {prefix: 'testing'}) }
63
+ specify { DummiesIndex.index_name.should == 'testing_dummies' }
64
+ specify { stub_index(:dummies) { index_name :users }.index_name.should == 'testing_users' }
65
+ end
66
+ end
67
+
68
+ describe '.build_index_name' do
69
+ specify { stub_const('DevelopersIndex', Class.new(Chewy::Index)).build_index_name(suffix: '').should == 'developers' }
70
+ specify { stub_const('DevelopersIndex', Class.new(Chewy::Index)).build_index_name(suffix: '2013').should == 'developers_2013' }
71
+ specify { stub_const('DevelopersIndex', Class.new(Chewy::Index)).build_index_name(prefix: '').should == 'developers' }
72
+ specify { stub_const('DevelopersIndex', Class.new(Chewy::Index)).build_index_name(prefix: 'test').should == 'test_developers' }
73
+ specify { stub_const('DevelopersIndex', Class.new(Chewy::Index)).build_index_name(:users, prefix: 'test', suffix: '2013').should == 'test_users_2013' }
45
74
  end
46
75
 
47
76
  describe '.index_params' do
@@ -82,4 +111,39 @@ describe Chewy::Index do
82
111
  end
83
112
  end.mappings_hash[:mappings].keys.should =~ [:document, :document2] }
84
113
  end
114
+
115
+ describe '.import' do
116
+ before do
117
+ stub_model(:city)
118
+ stub_model(:country)
119
+
120
+ stub_index(:places) do
121
+ define_type City
122
+ define_type Country
123
+ end
124
+ end
125
+
126
+ let!(:cities) { 2.times.map { City.create! } }
127
+ let!(:countries) { 2.times.map { Country.create! } }
128
+
129
+ specify do
130
+ expect { PlacesIndex.import }.to update_index(PlacesIndex::City).and_reindex(cities)
131
+ expect { PlacesIndex.import }.to update_index(PlacesIndex::Country).and_reindex(countries)
132
+ end
133
+
134
+ specify do
135
+ expect { PlacesIndex.import city: cities.first }.to update_index(PlacesIndex::City).and_reindex(cities.first).only
136
+ expect { PlacesIndex.import city: cities.first }.to update_index(PlacesIndex::Country).and_reindex(countries)
137
+ end
138
+
139
+ specify do
140
+ expect { PlacesIndex.import city: cities.first, country: countries.last }.to update_index(PlacesIndex::City).and_reindex(cities.first).only
141
+ expect { PlacesIndex.import city: cities.first, country: countries.last }.to update_index(PlacesIndex::Country).and_reindex(countries.last).only
142
+ end
143
+
144
+ specify do
145
+ expect(PlacesIndex.client).to receive(:bulk).with(hash_including(refresh: false)).twice
146
+ PlacesIndex.import city: cities.first, refresh: false
147
+ end
148
+ end
85
149
  end
@@ -146,30 +146,30 @@ describe Chewy::Query::Criteria do
146
146
  }.should == {body: {query: :query, from: 10, sort: [:field], fields: ['field']}} }
147
147
  end
148
148
 
149
- describe '#_request_query' do
150
- def _request_query &block
149
+ describe '#_composed_query' do
150
+ def _composed_query &block
151
151
  subject.instance_exec(&block) if block
152
- subject.send(:_request_query)
152
+ subject.send(:_composed_query, subject.send(:_request_query), subject.send(:_request_filter))
153
153
  end
154
154
 
155
- specify { _request_query.should be_nil }
156
- specify { _request_query { update_queries(:query) }.should == {query: :query} }
157
- specify { _request_query { update_queries([:query1, :query2]) }
155
+ specify { _composed_query.should be_nil }
156
+ specify { _composed_query { update_queries(:query) }.should == {query: :query} }
157
+ specify { _composed_query { update_queries([:query1, :query2]) }
158
158
  .should == {query: {bool: {must: [:query1, :query2]}}} }
159
- specify { _request_query { update_options(query_mode: :should); update_queries([:query1, :query2]) }
159
+ specify { _composed_query { update_options(query_mode: :should); update_queries([:query1, :query2]) }
160
160
  .should == {query: {bool: {should: [:query1, :query2]}}} }
161
- specify { _request_query { update_options(query_mode: :dis_max); update_queries([:query1, :query2]) }
161
+ specify { _composed_query { update_options(query_mode: :dis_max); update_queries([:query1, :query2]) }
162
162
  .should == {query: {dis_max: {queries: [:query1, :query2]}}} }
163
163
 
164
- specify { _request_query { update_filters([:filter1, :filter2]) }
164
+ specify { _composed_query { update_filters([:filter1, :filter2]) }
165
165
  .should == {query: {filtered: {query: {match_all: {}}, filter: {and: [:filter1, :filter2]}}}} }
166
- specify { _request_query { update_filters([:filter1, :filter2]); update_queries([:query1, :query2]) }
166
+ specify { _composed_query { update_filters([:filter1, :filter2]); update_queries([:query1, :query2]) }
167
167
  .should == {query: {filtered: {
168
168
  query: {bool: {must: [:query1, :query2]}},
169
169
  filter: {and: [:filter1, :filter2]}
170
170
  }}}
171
171
  }
172
- specify { _request_query {
172
+ specify { _composed_query {
173
173
  update_options(query_mode: :should); update_options(filter_mode: :or);
174
174
  update_filters([:filter1, :filter2]); update_queries([:query1, :query2])
175
175
  }.should == {query: {filtered: {
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Chewy::Query::Context do
3
+ describe Chewy::Query::Filters do
4
4
  def Bool options
5
5
  Chewy::Query::Nodes::Bool.new.tap do |bool|
6
6
  bool.must(*options[:must]) if options[:must].present?
@@ -16,7 +16,7 @@ describe Chewy::Query::Context do
16
16
  end
17
17
 
18
18
  def query &block
19
- Chewy::Query::Context.new(&block).__result__
19
+ Chewy::Query::Filters.new(&block).__result__
20
20
  end
21
21
 
22
22
  context 'outer scope' do
@@ -25,14 +25,16 @@ describe Chewy::Query::Loading do
25
25
  end
26
26
 
27
27
  before do
28
- PlacesIndex.city.import(cities)
29
- PlacesIndex.country.import(countries)
28
+ PlacesIndex::City.import(cities)
29
+ PlacesIndex::Country.import(countries)
30
30
  end
31
31
 
32
32
  specify { PlacesIndex.order(:rating).limit(6).load.total_count.should == 12 }
33
33
  specify { PlacesIndex.order(:rating).limit(6).load.should =~ cities.first(3) + countries.first(3) }
34
- specify { PlacesIndex.order(:rating).limit(6).load(city: { scope: ->(i) { where('rating < 2') } })
34
+ specify { PlacesIndex.order(:rating).limit(6).load(city: { scope: ->{ where('rating < 2') } })
35
35
  .should =~ cities.first(2) + countries.first(3) + [nil] }
36
+ specify { PlacesIndex.order(:rating).limit(6).load(scope: ->{ where('rating < 2') })
37
+ .should =~ cities.first(2) + countries.first(2) + [nil, nil] }
36
38
  specify { PlacesIndex.order(:rating).limit(6).load(city: { scope: City.where('rating < 2') })
37
39
  .should =~ cities.first(2) + countries.first(3) + [nil] }
38
40
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Chewy::Query::Nodes::And do
4
4
  describe '#__render__' do
5
5
  def render &block
6
- Chewy::Query::Context.new(&block).__render__
6
+ Chewy::Query::Filters.new(&block).__render__
7
7
  end
8
8
 
9
9
  specify { render { name? & (email == 'email') }.should == {
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Chewy::Query::Nodes::Bool do
4
4
  describe '#__render__' do
5
5
  def render &block
6
- Chewy::Query::Context.new(&block).__render__
6
+ Chewy::Query::Filters.new(&block).__render__
7
7
  end
8
8
 
9
9
  specify { render { must(name == 'name', email == 'email') }.should == {
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Chewy::Query::Nodes::Equal do
4
4
  describe '#__render__' do
5
5
  def render &block
6
- Chewy::Query::Context.new(&block).__render__
6
+ Chewy::Query::Filters.new(&block).__render__
7
7
  end
8
8
 
9
9
  specify { render { name == 'name' }.should == {term: {'name' => 'name'}} }
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Chewy::Query::Nodes::Exists do
4
4
  describe '#__render__' do
5
5
  def render &block
6
- Chewy::Query::Context.new(&block).__render__
6
+ Chewy::Query::Filters.new(&block).__render__
7
7
  end
8
8
 
9
9
  specify { render { name? }.should == {exists: {term: 'name'}} }
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chewy::Query::Nodes::HasChild do
4
+ describe '#__render__' do
5
+ def render &block
6
+ Chewy::Query::Filters.new(&block).__render__
7
+ end
8
+
9
+ specify { render { has_child('child') }.should == {has_child: {type: 'child'}} }
10
+
11
+
12
+ specify { render { has_child('child').filter(term: {name: 'name'}) }
13
+ .should == {has_child: {type: 'child', filter: {term: {name: 'name'}}}} }
14
+ specify { render { has_child('child').filter{ name == 'name' } }
15
+ .should == {has_child: {type: 'child', filter: {term: {'name' => 'name'}}}} }
16
+ specify { render { has_child('child').filter(term: {name: 'name'}).filter{ age < 42 } }
17
+ .should == {has_child: {type: 'child', filter: {and: [{term: {name: 'name'}}, range: {'age' => {lt: 42}}]}}} }
18
+ specify { render { has_child('child').filter(term: {name: 'name'}).filter{ age < 42 }.filter_mode(:or) }
19
+ .should == {has_child: {type: 'child', filter: {or: [{term: {name: 'name'}}, range: {'age' => {lt: 42}}]}}} }
20
+
21
+ specify { render { has_child('child').query(match: {name: 'name'}) }
22
+ .should == {has_child: {type: 'child', query: {match: {name: 'name'}}}} }
23
+ specify { render { has_child('child').query(match: {name: 'name'}).query(match: {surname: 'surname'}) }
24
+ .should == {has_child: {type: 'child', query: {bool: {must: [{match: {name: 'name'}}, {match: {surname: 'surname'}}]}}}} }
25
+ specify { render { has_child('child').query(match: {name: 'name'}).query(match: {surname: 'surname'}).query_mode(:should) }
26
+ .should == {has_child: {type: 'child', query: {bool: {should: [{match: {name: 'name'}}, {match: {surname: 'surname'}}]}}}} }
27
+
28
+ specify { render { has_child('child').filter{ name == 'name' }.query(match: {name: 'name'}) }
29
+ .should == {has_child: {type: 'child', query: {filtered: {query: {match: {name: 'name'}}, filter: {term: {'name' => 'name'}}}}}} }
30
+ specify { render { has_child('child').filter{ name == 'name' }.query(match: {name: 'name'}).filter{ age < 42 } }
31
+ .should == {has_child: {type: 'child', query: {filtered: {query: {match: {name: 'name'}}, filter: {and: [{term: {'name' => 'name'}}, range: {'age' => {lt: 42}}]}}}}} }
32
+
33
+ context do
34
+ let(:name) { 'Name' }
35
+
36
+ specify { render { has_child('child').filter{ name == o{name} } }
37
+ .should == {has_child: {type: 'child', filter: {term: {'name' => 'Name'}}}} }
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chewy::Query::Nodes::HasParent do
4
+ describe '#__render__' do
5
+ def render &block
6
+ Chewy::Query::Filters.new(&block).__render__
7
+ end
8
+
9
+ specify { render { has_parent('child') }.should == {has_parent: {type: 'child'}} }
10
+
11
+
12
+ specify { render { has_parent('child').filter(term: {name: 'name'}) }
13
+ .should == {has_parent: {type: 'child', filter: {term: {name: 'name'}}}} }
14
+ specify { render { has_parent('child').filter{ name == 'name' } }
15
+ .should == {has_parent: {type: 'child', filter: {term: {'name' => 'name'}}}} }
16
+ specify { render { has_parent('child').filter(term: {name: 'name'}).filter{ age < 42 } }
17
+ .should == {has_parent: {type: 'child', filter: {and: [{term: {name: 'name'}}, range: {'age' => {lt: 42}}]}}} }
18
+ specify { render { has_parent('child').filter(term: {name: 'name'}).filter{ age < 42 }.filter_mode(:or) }
19
+ .should == {has_parent: {type: 'child', filter: {or: [{term: {name: 'name'}}, range: {'age' => {lt: 42}}]}}} }
20
+
21
+ specify { render { has_parent('child').query(match: {name: 'name'}) }
22
+ .should == {has_parent: {type: 'child', query: {match: {name: 'name'}}}} }
23
+ specify { render { has_parent('child').query(match: {name: 'name'}).query(match: {surname: 'surname'}) }
24
+ .should == {has_parent: {type: 'child', query: {bool: {must: [{match: {name: 'name'}}, {match: {surname: 'surname'}}]}}}} }
25
+ specify { render { has_parent('child').query(match: {name: 'name'}).query(match: {surname: 'surname'}).query_mode(:should) }
26
+ .should == {has_parent: {type: 'child', query: {bool: {should: [{match: {name: 'name'}}, {match: {surname: 'surname'}}]}}}} }
27
+
28
+ specify { render { has_parent('child').filter{ name == 'name' }.query(match: {name: 'name'}) }
29
+ .should == {has_parent: {type: 'child', query: {filtered: {query: {match: {name: 'name'}}, filter: {term: {'name' => 'name'}}}}}} }
30
+ specify { render { has_parent('child').filter{ name == 'name' }.query(match: {name: 'name'}).filter{ age < 42 } }
31
+ .should == {has_parent: {type: 'child', query: {filtered: {query: {match: {name: 'name'}}, filter: {and: [{term: {'name' => 'name'}}, range: {'age' => {lt: 42}}]}}}}} }
32
+
33
+ context do
34
+ let(:name) { 'Name' }
35
+
36
+ specify { render { has_parent('child').filter{ name == o{name} } }
37
+ .should == {has_parent: {type: 'child', filter: {term: {'name' => 'Name'}}}} }
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chewy::Query::Nodes::MatchAll do
4
+ describe '#__render__' do
5
+ def render &block
6
+ Chewy::Query::Filters.new(&block).__render__
7
+ end
8
+
9
+ specify { render { match_all }.should == {match_all: {}} }
10
+ end
11
+ end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Chewy::Query::Nodes::Missing do
4
4
  describe '#__render__' do
5
5
  def render &block
6
- Chewy::Query::Context.new(&block).__render__
6
+ Chewy::Query::Filters.new(&block).__render__
7
7
  end
8
8
 
9
9
  specify { render { !name }.should == {missing: {term: 'name', existence: true, null_value: false}} }
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Chewy::Query::Nodes::Not do
4
4
  describe '#__render__' do
5
5
  def render &block
6
- Chewy::Query::Context.new(&block).__render__
6
+ Chewy::Query::Filters.new(&block).__render__
7
7
  end
8
8
 
9
9
  specify { render { !(email == 'email') }.should == {
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Chewy::Query::Nodes::Or do
4
4
  describe '#__render__' do
5
5
  def render &block
6
- Chewy::Query::Context.new(&block).__render__
6
+ Chewy::Query::Filters.new(&block).__render__
7
7
  end
8
8
 
9
9
  specify { render { name? | (email == 'email') }.should == {
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Chewy::Query::Nodes::Prefix do
4
4
  describe '#__render__' do
5
5
  def render &block
6
- Chewy::Query::Context.new(&block).__render__
6
+ Chewy::Query::Filters.new(&block).__render__
7
7
  end
8
8
 
9
9
  specify { render { name =~ 'nam' }.should == {prefix: {'name' => 'nam'}} }
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Chewy::Query::Nodes::Query do
4
4
  describe '#__render__' do
5
5
  def render &block
6
- Chewy::Query::Context.new(&block).__render__
6
+ Chewy::Query::Filters.new(&block).__render__
7
7
  end
8
8
 
9
9
  specify { render { q(query_string: {query: 'name: hello'}) }.should == {query: {query_string: {query: 'name: hello'}}} }
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Chewy::Query::Nodes::Range do
4
4
  describe '#__render__' do
5
5
  def render &block
6
- Chewy::Query::Context.new(&block).__render__
6
+ Chewy::Query::Filters.new(&block).__render__
7
7
  end
8
8
 
9
9
  specify { render { age > nil }.should == {range: {'age' => {gt: nil}}} }
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Chewy::Query::Nodes::Raw do
4
4
  describe '#__render__' do
5
5
  def render &block
6
- Chewy::Query::Context.new(&block).__render__
6
+ Chewy::Query::Filters.new(&block).__render__
7
7
  end
8
8
 
9
9
  specify { render { r(term: {name: 'name'}) }.should == {term: {name: 'name'}} }
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Chewy::Query::Nodes::Regexp do
4
4
  describe '#__render__' do
5
5
  def render &block
6
- Chewy::Query::Context.new(&block).__render__
6
+ Chewy::Query::Filters.new(&block).__render__
7
7
  end
8
8
 
9
9
  specify { render { names.first == /nam.*/ }.should == {regexp: {'names.first' => 'nam.*'}} }
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Chewy::Query::Nodes::Script do
4
4
  describe '#__render__' do
5
5
  def render &block
6
- Chewy::Query::Context.new(&block).__render__
6
+ Chewy::Query::Filters.new(&block).__render__
7
7
  end
8
8
 
9
9
  specify { render { s('var = val') }.should == {script: {script: 'var = val'}} }
@@ -19,13 +19,13 @@ describe Chewy::Query::Pagination do
19
19
  let(:search) { ProductsIndex.order(:age) }
20
20
 
21
21
  describe '#per, #page' do
22
- specify { search.map { |e| e.attributes.except('_score') }.should == data }
23
- specify { search.page(1).map { |e| e.attributes.except('_score') }.should == data[0..2] }
24
- specify { search.page(2).map { |e| e.attributes.except('_score') }.should == data[3..5] }
25
- specify { search.page(2).per(4).map { |e| e.attributes.except('_score') }.should == data[4..7] }
26
- specify { search.per(2).page(3).map { |e| e.attributes.except('_score') }.should == data[4..5] }
27
- specify { search.per(5).page.map { |e| e.attributes.except('_score') }.should == data[0..4] }
28
- specify { search.page.per(4).map { |e| e.attributes.except('_score') }.should == data[0..3] }
22
+ specify { search.map { |e| e.attributes.except('_score', '_explanation') }.should == data }
23
+ specify { search.page(1).map { |e| e.attributes.except('_score', '_explanation') }.should == data[0..2] }
24
+ specify { search.page(2).map { |e| e.attributes.except('_score', '_explanation') }.should == data[3..5] }
25
+ specify { search.page(2).per(4).map { |e| e.attributes.except('_score', '_explanation') }.should == data[4..7] }
26
+ specify { search.per(2).page(3).map { |e| e.attributes.except('_score', '_explanation') }.should == data[4..5] }
27
+ specify { search.per(5).page.map { |e| e.attributes.except('_score', '_explanation') }.should == data[0..4] }
28
+ specify { search.page.per(4).map { |e| e.attributes.except('_score', '_explanation') }.should == data[0..3] }
29
29
  end
30
30
 
31
31
  describe '#total_pages' do