chewy 5.0.0 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +214 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +39 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +16 -0
- data/Appraisals +1 -17
- data/CHANGELOG.md +312 -356
- data/CODE_OF_CONDUCT.md +14 -0
- data/CONTRIBUTING.md +63 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +97 -92
- data/chewy.gemspec +5 -5
- data/gemfiles/rails.5.2.activerecord.gemfile +4 -3
- data/gemfiles/{rails.5.0.activerecord.gemfile → rails.5.2.mongoid.6.4.gemfile} +4 -3
- data/gemfiles/{rails.5.0.mongoid.6.1.gemfile → rails.6.0.activerecord.gemfile} +4 -3
- data/gemfiles/{rails.5.1.activerecord.gemfile → rails.6.1.activerecord.gemfile} +6 -3
- data/lib/chewy.rb +1 -1
- data/lib/chewy/backports/duplicable.rb +1 -1
- data/lib/chewy/config.rb +2 -20
- data/lib/chewy/fields/base.rb +1 -7
- data/lib/chewy/fields/root.rb +3 -4
- data/lib/chewy/index.rb +6 -15
- data/lib/chewy/index/actions.rb +12 -4
- data/lib/chewy/index/aliases.rb +14 -5
- data/lib/chewy/multi_search.rb +62 -0
- data/lib/chewy/railtie.rb +3 -19
- data/lib/chewy/search.rb +2 -9
- data/lib/chewy/search/loader.rb +3 -13
- data/lib/chewy/search/pagination/will_paginate.rb +1 -1
- data/lib/chewy/search/parameters.rb +24 -6
- data/lib/chewy/search/parameters/allow_partial_search_results.rb +27 -0
- data/lib/chewy/search/parameters/indices.rb +78 -0
- data/lib/chewy/search/parameters/none.rb +1 -3
- data/lib/chewy/search/request.rb +92 -85
- data/lib/chewy/search/response.rb +1 -1
- data/lib/chewy/search/scrolling.rb +8 -7
- data/lib/chewy/stash.rb +3 -6
- data/lib/chewy/strategy/active_job.rb +1 -1
- data/lib/chewy/strategy/sidekiq.rb +1 -1
- data/lib/chewy/type.rb +4 -1
- data/lib/chewy/type/adapter/active_record.rb +1 -1
- data/lib/chewy/type/adapter/mongoid.rb +1 -1
- data/lib/chewy/type/adapter/orm.rb +7 -4
- data/lib/chewy/type/adapter/sequel.rb +1 -1
- data/lib/chewy/type/import.rb +14 -4
- data/lib/chewy/type/import/bulk_request.rb +5 -4
- data/lib/chewy/type/import/journal_builder.rb +2 -3
- data/lib/chewy/type/import/routine.rb +3 -3
- data/lib/chewy/type/mapping.rb +5 -5
- data/lib/chewy/type/observe.rb +3 -3
- data/lib/chewy/type/syncer.rb +2 -6
- data/lib/chewy/type/witchcraft.rb +4 -2
- data/lib/chewy/type/wrapper.rb +12 -2
- data/lib/chewy/version.rb +1 -1
- data/lib/tasks/chewy.rake +10 -10
- data/migration_guide.md +37 -0
- data/spec/chewy/config_spec.rb +1 -22
- data/spec/chewy/fields/base_spec.rb +15 -13
- data/spec/chewy/fields/root_spec.rb +4 -4
- data/spec/chewy/index/actions_spec.rb +120 -33
- data/spec/chewy/index/aliases_spec.rb +3 -3
- data/spec/chewy/index/specification_spec.rb +13 -13
- data/spec/chewy/index_spec.rb +17 -42
- data/spec/chewy/journal_spec.rb +25 -21
- data/spec/chewy/minitest/search_index_receiver_spec.rb +11 -9
- data/spec/chewy/multi_search_spec.rb +85 -0
- data/spec/chewy/rake_helper_spec.rb +102 -87
- data/spec/chewy/rspec/update_index_spec.rb +47 -46
- data/spec/chewy/runtime_spec.rb +2 -2
- data/spec/chewy/search/loader_spec.rb +0 -16
- data/spec/chewy/search/parameters/indices_spec.rb +105 -0
- data/spec/chewy/search/parameters/none_spec.rb +1 -1
- data/spec/chewy/search/parameters_spec.rb +21 -4
- data/spec/chewy/search/request_spec.rb +94 -78
- data/spec/chewy/search/response_spec.rb +27 -17
- data/spec/chewy/search/scrolling_spec.rb +22 -18
- data/spec/chewy/search_spec.rb +45 -41
- data/spec/chewy/stash_spec.rb +14 -12
- data/spec/chewy/strategy/active_job_spec.rb +15 -2
- data/spec/chewy/strategy/shoryuken_spec.rb +6 -2
- data/spec/chewy/strategy/sidekiq_spec.rb +6 -2
- data/spec/chewy/type/adapter/active_record_spec.rb +16 -4
- data/spec/chewy/type/import/bulk_builder_spec.rb +9 -94
- data/spec/chewy/type/import/bulk_request_spec.rb +0 -6
- data/spec/chewy/type/import/journal_builder_spec.rb +9 -11
- data/spec/chewy/type/import_spec.rb +11 -2
- data/spec/chewy/type/mapping_spec.rb +8 -38
- data/spec/chewy/type/observe_spec.rb +4 -4
- data/spec/chewy/type/witchcraft_spec.rb +15 -0
- data/spec/chewy/type/wrapper_spec.rb +3 -1
- data/spec/chewy_spec.rb +0 -7
- data/spec/spec_helper.rb +4 -8
- data/spec/support/active_record.rb +21 -0
- metadata +31 -100
- data/.travis.yml +0 -45
- data/LEGACY_DSL.md +0 -497
- data/gemfiles/rails.4.0.activerecord.gemfile +0 -15
- data/gemfiles/rails.4.1.activerecord.gemfile +0 -15
- data/gemfiles/rails.4.2.activerecord.gemfile +0 -16
- data/gemfiles/rails.4.2.mongoid.5.2.gemfile +0 -16
- data/gemfiles/rails.5.1.mongoid.6.3.gemfile +0 -16
- data/lib/chewy/query.rb +0 -1137
- data/lib/chewy/query/compose.rb +0 -68
- data/lib/chewy/query/criteria.rb +0 -191
- data/lib/chewy/query/filters.rb +0 -244
- data/lib/chewy/query/loading.rb +0 -110
- data/lib/chewy/query/nodes/and.rb +0 -25
- data/lib/chewy/query/nodes/base.rb +0 -17
- data/lib/chewy/query/nodes/bool.rb +0 -34
- data/lib/chewy/query/nodes/equal.rb +0 -34
- data/lib/chewy/query/nodes/exists.rb +0 -20
- data/lib/chewy/query/nodes/expr.rb +0 -28
- data/lib/chewy/query/nodes/field.rb +0 -110
- data/lib/chewy/query/nodes/has_child.rb +0 -15
- data/lib/chewy/query/nodes/has_parent.rb +0 -15
- data/lib/chewy/query/nodes/has_relation.rb +0 -59
- data/lib/chewy/query/nodes/match_all.rb +0 -11
- data/lib/chewy/query/nodes/missing.rb +0 -20
- data/lib/chewy/query/nodes/not.rb +0 -25
- data/lib/chewy/query/nodes/or.rb +0 -25
- data/lib/chewy/query/nodes/prefix.rb +0 -19
- data/lib/chewy/query/nodes/query.rb +0 -20
- data/lib/chewy/query/nodes/range.rb +0 -63
- data/lib/chewy/query/nodes/raw.rb +0 -15
- data/lib/chewy/query/nodes/regexp.rb +0 -35
- data/lib/chewy/query/nodes/script.rb +0 -20
- data/lib/chewy/query/pagination.rb +0 -25
- data/lib/chewy/search/parameters/types.rb +0 -20
- data/spec/chewy/query/criteria_spec.rb +0 -700
- data/spec/chewy/query/filters_spec.rb +0 -201
- data/spec/chewy/query/loading_spec.rb +0 -124
- data/spec/chewy/query/nodes/and_spec.rb +0 -12
- data/spec/chewy/query/nodes/bool_spec.rb +0 -14
- data/spec/chewy/query/nodes/equal_spec.rb +0 -32
- data/spec/chewy/query/nodes/exists_spec.rb +0 -18
- data/spec/chewy/query/nodes/has_child_spec.rb +0 -59
- data/spec/chewy/query/nodes/has_parent_spec.rb +0 -59
- data/spec/chewy/query/nodes/match_all_spec.rb +0 -11
- data/spec/chewy/query/nodes/missing_spec.rb +0 -16
- data/spec/chewy/query/nodes/not_spec.rb +0 -14
- data/spec/chewy/query/nodes/or_spec.rb +0 -12
- data/spec/chewy/query/nodes/prefix_spec.rb +0 -16
- data/spec/chewy/query/nodes/query_spec.rb +0 -12
- data/spec/chewy/query/nodes/range_spec.rb +0 -32
- data/spec/chewy/query/nodes/raw_spec.rb +0 -11
- data/spec/chewy/query/nodes/regexp_spec.rb +0 -43
- data/spec/chewy/query/nodes/script_spec.rb +0 -15
- data/spec/chewy/query/pagination/kaminari_spec.rb +0 -5
- data/spec/chewy/query/pagination/will_paginate_spec.rb +0 -5
- data/spec/chewy/query/pagination_spec.rb +0 -39
- data/spec/chewy/query_spec.rb +0 -637
- data/spec/chewy/search/parameters/indices_boost_spec.rb +0 -83
- data/spec/chewy/search/parameters/types_spec.rb +0 -5
@@ -32,7 +32,6 @@ describe Chewy::Type::Import::BulkRequest do
|
|
32
32
|
specify do
|
33
33
|
expect(Chewy.client).to receive(:bulk).with(
|
34
34
|
index: 'places',
|
35
|
-
type: 'city',
|
36
35
|
body: [{index: {id: 42, data: {name: 'Name'}}}]
|
37
36
|
)
|
38
37
|
subject.perform([{index: {id: 42, data: {name: 'Name'}}}])
|
@@ -44,7 +43,6 @@ describe Chewy::Type::Import::BulkRequest do
|
|
44
43
|
specify do
|
45
44
|
expect(Chewy.client).to receive(:bulk).with(
|
46
45
|
index: 'places_suffix',
|
47
|
-
type: 'city',
|
48
46
|
body: [{index: {id: 42, data: {name: 'Name'}}}]
|
49
47
|
)
|
50
48
|
subject.perform([{index: {id: 42, data: {name: 'Name'}}}])
|
@@ -57,7 +55,6 @@ describe Chewy::Type::Import::BulkRequest do
|
|
57
55
|
specify do
|
58
56
|
expect(Chewy.client).to receive(:bulk).with(
|
59
57
|
index: 'places',
|
60
|
-
type: 'city',
|
61
58
|
body: "{\"index\":{\"id\":42}}\n{\"name\":\"#{'Name' * 10}\"}\n{\"index\":{\"id\":43}}\n{\"name\":\"#{'Shame' * 10}\"}\n"
|
62
59
|
)
|
63
60
|
subject.perform([
|
@@ -69,17 +66,14 @@ describe Chewy::Type::Import::BulkRequest do
|
|
69
66
|
specify do
|
70
67
|
expect(Chewy.client).to receive(:bulk).with(
|
71
68
|
index: 'places',
|
72
|
-
type: 'city',
|
73
69
|
body: "{\"index\":{\"id\":42}}\n{\"name\":\"#{'Name' * 30}\"}\n"
|
74
70
|
)
|
75
71
|
expect(Chewy.client).to receive(:bulk).with(
|
76
72
|
index: 'places',
|
77
|
-
type: 'city',
|
78
73
|
body: "{\"index\":{\"id\":43}}\n{\"name\":\"#{'Shame' * 100}\"}\n"
|
79
74
|
)
|
80
75
|
expect(Chewy.client).to receive(:bulk).with(
|
81
76
|
index: 'places',
|
82
|
-
type: 'city',
|
83
77
|
body: "{\"index\":{\"id\":44}}\n{\"name\":\"#{'Blame' * 30}\"}\n"
|
84
78
|
)
|
85
79
|
subject.perform([
|
@@ -3,8 +3,10 @@ require 'spec_helper'
|
|
3
3
|
describe Chewy::Type::Import::JournalBuilder, :orm do
|
4
4
|
before do
|
5
5
|
stub_model(:country)
|
6
|
-
stub_index 'namespace/
|
6
|
+
stub_index 'namespace/cities' do
|
7
7
|
define_type :city
|
8
|
+
end
|
9
|
+
stub_index 'namespace/countries' do
|
8
10
|
define_type Country
|
9
11
|
end
|
10
12
|
Timecop.freeze(time)
|
@@ -13,7 +15,7 @@ describe Chewy::Type::Import::JournalBuilder, :orm do
|
|
13
15
|
|
14
16
|
let(:time) { Time.parse('2017-07-14 12:00Z') }
|
15
17
|
|
16
|
-
let(:type) { Namespace::
|
18
|
+
let(:type) { Namespace::CitiesIndex::City }
|
17
19
|
let(:index) { [] }
|
18
20
|
let(:delete) { [] }
|
19
21
|
subject { described_class.new(type, index: index, delete: delete) }
|
@@ -27,9 +29,8 @@ describe Chewy::Type::Import::JournalBuilder, :orm do
|
|
27
29
|
expect(subject.bulk_body).to eq([{
|
28
30
|
index: {
|
29
31
|
_index: 'chewy_journal',
|
30
|
-
_type: 'journal',
|
31
32
|
data: {
|
32
|
-
'index_name' => 'namespace/
|
33
|
+
'index_name' => 'namespace/cities',
|
33
34
|
'type_name' => 'city',
|
34
35
|
'action' => 'index',
|
35
36
|
'references' => [Base64.encode64('{"id":1,"name":"City"}')],
|
@@ -46,9 +47,8 @@ describe Chewy::Type::Import::JournalBuilder, :orm do
|
|
46
47
|
expect(subject.bulk_body).to eq([{
|
47
48
|
index: {
|
48
49
|
_index: 'chewy_journal',
|
49
|
-
_type: 'journal',
|
50
50
|
data: {
|
51
|
-
'index_name' => 'namespace/
|
51
|
+
'index_name' => 'namespace/cities',
|
52
52
|
'type_name' => 'city',
|
53
53
|
'action' => 'delete',
|
54
54
|
'references' => [Base64.encode64('{"id":1,"name":"City"}')],
|
@@ -60,16 +60,15 @@ describe Chewy::Type::Import::JournalBuilder, :orm do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
context do
|
63
|
-
let(:type) { Namespace::
|
63
|
+
let(:type) { Namespace::CountriesIndex::Country }
|
64
64
|
let(:index) { [Country.new(id: 1, name: 'City')] }
|
65
65
|
let(:delete) { [Country.new(id: 2, name: 'City')] }
|
66
66
|
specify do
|
67
67
|
expect(subject.bulk_body).to eq([{
|
68
68
|
index: {
|
69
69
|
_index: 'chewy_journal',
|
70
|
-
_type: 'journal',
|
71
70
|
data: {
|
72
|
-
'index_name' => 'namespace/
|
71
|
+
'index_name' => 'namespace/countries',
|
73
72
|
'type_name' => 'country',
|
74
73
|
'action' => 'index',
|
75
74
|
'references' => [Base64.encode64('1')],
|
@@ -79,9 +78,8 @@ describe Chewy::Type::Import::JournalBuilder, :orm do
|
|
79
78
|
}, {
|
80
79
|
index: {
|
81
80
|
_index: 'chewy_journal',
|
82
|
-
_type: 'journal',
|
83
81
|
data: {
|
84
|
-
'index_name' => 'namespace/
|
82
|
+
'index_name' => 'namespace/countries',
|
85
83
|
'type_name' => 'country',
|
86
84
|
'action' => 'delete',
|
87
85
|
'references' => [Base64.encode64('2')],
|
@@ -158,6 +158,15 @@ describe Chewy::Type::Import do
|
|
158
158
|
specify do
|
159
159
|
expect { import City.where(id: dummy_cities.first.id) }.to update_index(CitiesIndex::City).and_reindex(dummy_cities.first).only
|
160
160
|
end
|
161
|
+
|
162
|
+
specify do
|
163
|
+
allow(CitiesIndex::City).to receive(:import_linear).and_return(double(present?: false))
|
164
|
+
allow(CitiesIndex::City).to receive(:import_parallel).and_return(double(present?: false))
|
165
|
+
|
166
|
+
expects_no_query(except: /SELECT\s+1\s+AS\s+one\s+FROM/) do
|
167
|
+
import City.where(id: dummy_cities.first.id)
|
168
|
+
end
|
169
|
+
end
|
161
170
|
end
|
162
171
|
end
|
163
172
|
|
@@ -357,8 +366,8 @@ describe Chewy::Type::Import do
|
|
357
366
|
|
358
367
|
# Full match doesn't work here.
|
359
368
|
expect(payload[:errors][:update].keys).to match([
|
360
|
-
hash_including('type' => 'document_missing_exception', 'reason' => '[
|
361
|
-
hash_including('type' => 'document_missing_exception', 'reason' => '[
|
369
|
+
hash_including('type' => 'document_missing_exception', 'reason' => '[_doc][1]: document missing'),
|
370
|
+
hash_including('type' => 'document_missing_exception', 'reason' => '[_doc][3]: document missing')
|
362
371
|
])
|
363
372
|
expect(payload[:errors][:update].values).to eq([['1'], ['3']])
|
364
373
|
expect(imported_cities).to match_array([
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Chewy::Type::Mapping do
|
4
4
|
let(:product) { ProductsIndex::Product }
|
5
|
-
let(:review) {
|
5
|
+
let(:review) { ReviewsIndex::Review }
|
6
6
|
|
7
7
|
before do
|
8
8
|
stub_index(:products) do
|
@@ -20,6 +20,8 @@ describe Chewy::Type::Mapping do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
|
+
end
|
24
|
+
stub_index(:reviews) do
|
23
25
|
define_type :review do
|
24
26
|
field :title, :body
|
25
27
|
field :comments do
|
@@ -57,7 +59,7 @@ describe Chewy::Type::Mapping do
|
|
57
59
|
Chewy.default_root_options = previous_options
|
58
60
|
end
|
59
61
|
|
60
|
-
specify { expect(product.mappings_hash
|
62
|
+
specify { expect(product.mappings_hash).to include(_all: {enabled: false}) }
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
@@ -88,12 +90,11 @@ describe Chewy::Type::Mapping do
|
|
88
90
|
before do
|
89
91
|
stub_index(:products) do
|
90
92
|
define_type :product do
|
91
|
-
root
|
93
|
+
root other_option: 'nothing' do
|
92
94
|
field :name do
|
93
95
|
field :last_name # will be redefined in the following root flock
|
94
96
|
end
|
95
97
|
end
|
96
|
-
root _parent: 'something_else'
|
97
98
|
root other_option: 'option_value' do
|
98
99
|
field :identifier
|
99
100
|
field :name, type: 'integer'
|
@@ -103,45 +104,14 @@ describe Chewy::Type::Mapping do
|
|
103
104
|
end
|
104
105
|
|
105
106
|
specify do
|
106
|
-
expect(product.mappings_hash).to eq(
|
107
|
+
expect(product.mappings_hash).to eq(
|
107
108
|
properties: {
|
108
109
|
name: {type: 'integer'},
|
109
110
|
identifier: {type: Chewy.default_field_type}
|
110
111
|
},
|
111
|
-
other_option: 'option_value'
|
112
|
-
|
113
|
-
})
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
context 'parent-child relationship' do
|
119
|
-
context do
|
120
|
-
before do
|
121
|
-
stub_index(:products) do
|
122
|
-
define_type :product do
|
123
|
-
root _parent: 'project', parent_id: -> { project_id } do
|
124
|
-
field :name, 'surname'
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
112
|
+
other_option: 'option_value'
|
113
|
+
)
|
128
114
|
end
|
129
|
-
|
130
|
-
specify { expect(product.mappings_hash[:product][:_parent]).to eq(type: 'project') }
|
131
|
-
end
|
132
|
-
|
133
|
-
context do
|
134
|
-
before do
|
135
|
-
stub_index(:products) do
|
136
|
-
define_type :product do
|
137
|
-
root parent: {'type' => 'project'}, parent_id: -> { project_id } do
|
138
|
-
field :name, 'surname'
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
specify { expect(product.mappings_hash[:product][:_parent]).to eq('type' => 'project') }
|
145
115
|
end
|
146
116
|
end
|
147
117
|
end
|
@@ -75,11 +75,11 @@ describe Chewy::Type::Observe do
|
|
75
75
|
specify { expect { city.save! }.to update_index('cities#city').and_reindex(city).only }
|
76
76
|
specify { expect { city.save! }.to update_index('countries#country').and_reindex(country1).only }
|
77
77
|
|
78
|
-
specify { expect { city.
|
79
|
-
specify { expect { city.
|
78
|
+
specify { expect { city.update!(country: nil) }.to update_index('cities#city').and_reindex(city).only }
|
79
|
+
specify { expect { city.update!(country: nil) }.to update_index('countries#country').and_reindex(country1).only }
|
80
80
|
|
81
|
-
specify { expect { city.
|
82
|
-
specify { expect { city.
|
81
|
+
specify { expect { city.update!(country: country2) }.to update_index('cities#city').and_reindex(city).only }
|
82
|
+
specify { expect { city.update!(country: country2) }.to update_index('countries#country').and_reindex(country1, country2).only }
|
83
83
|
end
|
84
84
|
|
85
85
|
context do
|
@@ -181,6 +181,21 @@ describe Chewy::Type::Witchcraft do
|
|
181
181
|
]}.as_json)
|
182
182
|
end
|
183
183
|
end
|
184
|
+
|
185
|
+
context do
|
186
|
+
mapping do
|
187
|
+
field :not_present do
|
188
|
+
field :nothing
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
let(:object) do
|
193
|
+
double(not_present: nil)
|
194
|
+
end
|
195
|
+
specify do
|
196
|
+
expect(type.cauldron.brew(object)).to eq({not_present: nil}.as_json)
|
197
|
+
end
|
198
|
+
end
|
184
199
|
end
|
185
200
|
|
186
201
|
context 'dynamic fields' do
|
@@ -63,9 +63,11 @@ describe Chewy::Type::Wrapper do
|
|
63
63
|
|
64
64
|
it do
|
65
65
|
is_expected.to respond_to(:name_highlight)
|
66
|
+
.and respond_to(:name_highlights)
|
66
67
|
.and have_attributes(
|
67
68
|
name: 'Martin',
|
68
|
-
name_highlight: '<b>Mar</b>tin'
|
69
|
+
name_highlight: '<b>Mar</b>tin',
|
70
|
+
name_highlights: ['<b>Mar</b>tin']
|
69
71
|
)
|
70
72
|
end
|
71
73
|
end
|
data/spec/chewy_spec.rb
CHANGED
@@ -15,21 +15,18 @@ describe Chewy do
|
|
15
15
|
|
16
16
|
stub_index('namespace/autocomplete') do
|
17
17
|
define_type :developer
|
18
|
-
define_type :company
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
21
|
specify { expect { described_class.derive_type('some#developers') }.to raise_error(Chewy::UnderivableType, /SomeIndex/) }
|
23
22
|
specify { expect { described_class.derive_type('borogoves#developers') }.to raise_error(Chewy::UnderivableType, /Borogoves/) }
|
24
23
|
specify { expect { described_class.derive_type('developers#borogoves') }.to raise_error(Chewy::UnderivableType, /DevelopersIndex.*borogoves/) }
|
25
|
-
specify { expect { described_class.derive_type('namespace/autocomplete') }.to raise_error(Chewy::UnderivableType, %r{AutocompleteIndex.*namespace/autocomplete#type_name}) }
|
26
24
|
|
27
25
|
specify { expect(described_class.derive_type(DevelopersIndex::Developer)).to eq(DevelopersIndex::Developer) }
|
28
26
|
specify { expect(described_class.derive_type('developers_index')).to eq(DevelopersIndex::Developer) }
|
29
27
|
specify { expect(described_class.derive_type('developers')).to eq(DevelopersIndex::Developer) }
|
30
28
|
specify { expect(described_class.derive_type('developers#developer')).to eq(DevelopersIndex::Developer) }
|
31
29
|
specify { expect(described_class.derive_type('namespace/autocomplete#developer')).to eq(Namespace::AutocompleteIndex::Developer) }
|
32
|
-
specify { expect(described_class.derive_type('namespace/autocomplete#company')).to eq(Namespace::AutocompleteIndex::Company) }
|
33
30
|
end
|
34
31
|
|
35
32
|
describe '.derive_types' do
|
@@ -42,7 +39,6 @@ describe Chewy do
|
|
42
39
|
|
43
40
|
stub_index('namespace/autocomplete') do
|
44
41
|
define_type :developer
|
45
|
-
define_type :company
|
46
42
|
end
|
47
43
|
end
|
48
44
|
|
@@ -58,7 +54,6 @@ describe Chewy do
|
|
58
54
|
specify { expect(described_class.derive_types('developers#developer')).to eq([DevelopersIndex::Developer]) }
|
59
55
|
specify { expect(described_class.derive_types('namespace/autocomplete')).to match_array(Namespace::AutocompleteIndex.types) }
|
60
56
|
specify { expect(described_class.derive_types('namespace/autocomplete#developer')).to eq([Namespace::AutocompleteIndex::Developer]) }
|
61
|
-
specify { expect(described_class.derive_types('namespace/autocomplete#company')).to eq([Namespace::AutocompleteIndex::Company]) }
|
62
57
|
end
|
63
58
|
|
64
59
|
describe '.create_type' do
|
@@ -130,7 +125,6 @@ describe Chewy do
|
|
130
125
|
stub_index(:admins).create!
|
131
126
|
allow(Chewy).to receive_messages(configuration: Chewy.configuration.merge(prefix: 'prefix2'))
|
132
127
|
stub_index(:developers).create!
|
133
|
-
stub_index(:companies).create!
|
134
128
|
|
135
129
|
Chewy.massacre
|
136
130
|
|
@@ -139,7 +133,6 @@ describe Chewy do
|
|
139
133
|
|
140
134
|
specify { expect(AdminsIndex.exists?).to eq(true) }
|
141
135
|
specify { expect(DevelopersIndex.exists?).to eq(false) }
|
142
|
-
specify { expect(CompaniesIndex.exists?).to eq(false) }
|
143
136
|
end
|
144
137
|
|
145
138
|
describe '.client' do
|
data/spec/spec_helper.rb
CHANGED
@@ -21,8 +21,11 @@ require 'support/class_helpers'
|
|
21
21
|
|
22
22
|
require 'chewy/rspec'
|
23
23
|
|
24
|
+
host = ENV['ES_HOST'] || 'localhost'
|
25
|
+
port = ENV['ES_PORT'] || 9250
|
26
|
+
|
24
27
|
Chewy.settings = {
|
25
|
-
host:
|
28
|
+
host: "#{host}:#{port}",
|
26
29
|
wait_for_status: 'green',
|
27
30
|
index: {
|
28
31
|
number_of_shards: 1,
|
@@ -30,15 +33,8 @@ Chewy.settings = {
|
|
30
33
|
}
|
31
34
|
}
|
32
35
|
|
33
|
-
Chewy.default_field_type = 'string' if Chewy::Runtime.version < '5.0'
|
34
36
|
# Chewy.transport_logger = Logger.new(STDERR)
|
35
37
|
|
36
|
-
KEYWORD_FIELD = if Chewy::Runtime.version < '5.0'
|
37
|
-
{type: 'string', index: 'not_analyzed'}
|
38
|
-
else
|
39
|
-
{type: 'keyword'}
|
40
|
-
end
|
41
|
-
|
42
38
|
RSpec.configure do |config|
|
43
39
|
config.mock_with :rspec
|
44
40
|
config.order = :random
|
@@ -29,6 +29,27 @@ module ActiveRecordClassHelpers
|
|
29
29
|
:active_record
|
30
30
|
end
|
31
31
|
|
32
|
+
def expects_db_queries(&block)
|
33
|
+
have_queries = false
|
34
|
+
ActiveSupport::Notifications.subscribed(
|
35
|
+
->(*_) { have_queries = true },
|
36
|
+
'sql.active_record',
|
37
|
+
&block
|
38
|
+
)
|
39
|
+
raise 'Expected some db queries, but none were made' unless have_queries
|
40
|
+
end
|
41
|
+
|
42
|
+
def expects_no_query(except: nil, &block)
|
43
|
+
queries = []
|
44
|
+
ActiveSupport::Notifications.subscribed(
|
45
|
+
->(*args) { queries << args[4][:sql] },
|
46
|
+
'sql.active_record',
|
47
|
+
&block
|
48
|
+
)
|
49
|
+
ofending_queries = except ? queries.find_all { |query| !query.match(except) } : queries
|
50
|
+
raise "Expected no DB queries, but the following ones were made: #{ofending_queries.join(', ')}" if ofending_queries.present?
|
51
|
+
end
|
52
|
+
|
32
53
|
def stub_model(name, superclass = nil, &block)
|
33
54
|
stub_class(name, superclass || ActiveRecord::Base, &block)
|
34
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chewy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Toptal, LLC
|
7
8
|
- pyromaniac
|
8
|
-
autorequire:
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2021-03-03 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: appraisal
|
@@ -86,14 +87,14 @@ dependencies:
|
|
86
87
|
requirements:
|
87
88
|
- - ">="
|
88
89
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
90
|
+
version: 3.7.0
|
90
91
|
type: :development
|
91
92
|
prerelease: false
|
92
93
|
version_requirements: !ruby/object:Gem::Requirement
|
93
94
|
requirements:
|
94
95
|
- - ">="
|
95
96
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
97
|
+
version: 3.7.0
|
97
98
|
- !ruby/object:Gem::Dependency
|
98
99
|
name: rspec-collection_matchers
|
99
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,28 +199,28 @@ dependencies:
|
|
198
199
|
requirements:
|
199
200
|
- - ">="
|
200
201
|
- !ruby/object:Gem::Version
|
201
|
-
version: '
|
202
|
+
version: '5.2'
|
202
203
|
type: :runtime
|
203
204
|
prerelease: false
|
204
205
|
version_requirements: !ruby/object:Gem::Requirement
|
205
206
|
requirements:
|
206
207
|
- - ">="
|
207
208
|
- !ruby/object:Gem::Version
|
208
|
-
version: '
|
209
|
+
version: '5.2'
|
209
210
|
- !ruby/object:Gem::Dependency
|
210
211
|
name: elasticsearch
|
211
212
|
requirement: !ruby/object:Gem::Requirement
|
212
213
|
requirements:
|
213
214
|
- - ">="
|
214
215
|
- !ruby/object:Gem::Version
|
215
|
-
version:
|
216
|
+
version: 6.3.0
|
216
217
|
type: :runtime
|
217
218
|
prerelease: false
|
218
219
|
version_requirements: !ruby/object:Gem::Requirement
|
219
220
|
requirements:
|
220
221
|
- - ">="
|
221
222
|
- !ruby/object:Gem::Version
|
222
|
-
version:
|
223
|
+
version: 6.3.0
|
223
224
|
- !ruby/object:Gem::Dependency
|
224
225
|
name: elasticsearch-dsl
|
225
226
|
requirement: !ruby/object:Gem::Requirement
|
@@ -237,36 +238,36 @@ dependencies:
|
|
237
238
|
description: Chewy provides functionality for Elasticsearch index handling, documents
|
238
239
|
import mappings and chainable query DSL
|
239
240
|
email:
|
241
|
+
- open-source@toptal.com
|
240
242
|
- kinwizard@gmail.com
|
241
243
|
executables: []
|
242
244
|
extensions: []
|
243
245
|
extra_rdoc_files: []
|
244
246
|
files:
|
247
|
+
- ".circleci/config.yml"
|
248
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
249
|
+
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
250
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
245
251
|
- ".gitignore"
|
246
252
|
- ".rspec"
|
247
253
|
- ".rubocop.yml"
|
248
254
|
- ".rubocop_todo.yml"
|
249
|
-
- ".travis.yml"
|
250
255
|
- ".yardopts"
|
251
256
|
- Appraisals
|
252
257
|
- CHANGELOG.md
|
258
|
+
- CODE_OF_CONDUCT.md
|
259
|
+
- CONTRIBUTING.md
|
253
260
|
- Gemfile
|
254
261
|
- Guardfile
|
255
|
-
- LEGACY_DSL.md
|
256
262
|
- LICENSE.txt
|
257
263
|
- README.md
|
258
264
|
- Rakefile
|
259
265
|
- chewy.gemspec
|
260
266
|
- filters
|
261
|
-
- gemfiles/rails.4.0.activerecord.gemfile
|
262
|
-
- gemfiles/rails.4.1.activerecord.gemfile
|
263
|
-
- gemfiles/rails.4.2.activerecord.gemfile
|
264
|
-
- gemfiles/rails.4.2.mongoid.5.2.gemfile
|
265
|
-
- gemfiles/rails.5.0.activerecord.gemfile
|
266
|
-
- gemfiles/rails.5.0.mongoid.6.1.gemfile
|
267
|
-
- gemfiles/rails.5.1.activerecord.gemfile
|
268
|
-
- gemfiles/rails.5.1.mongoid.6.3.gemfile
|
269
267
|
- gemfiles/rails.5.2.activerecord.gemfile
|
268
|
+
- gemfiles/rails.5.2.mongoid.6.4.gemfile
|
269
|
+
- gemfiles/rails.6.0.activerecord.gemfile
|
270
|
+
- gemfiles/rails.6.1.activerecord.gemfile
|
270
271
|
- gemfiles/sequel.4.45.gemfile
|
271
272
|
- lib/chewy.rb
|
272
273
|
- lib/chewy/backports/deep_dup.rb
|
@@ -285,32 +286,7 @@ files:
|
|
285
286
|
- lib/chewy/minitest.rb
|
286
287
|
- lib/chewy/minitest/helpers.rb
|
287
288
|
- lib/chewy/minitest/search_index_receiver.rb
|
288
|
-
- lib/chewy/
|
289
|
-
- lib/chewy/query/compose.rb
|
290
|
-
- lib/chewy/query/criteria.rb
|
291
|
-
- lib/chewy/query/filters.rb
|
292
|
-
- lib/chewy/query/loading.rb
|
293
|
-
- lib/chewy/query/nodes/and.rb
|
294
|
-
- lib/chewy/query/nodes/base.rb
|
295
|
-
- lib/chewy/query/nodes/bool.rb
|
296
|
-
- lib/chewy/query/nodes/equal.rb
|
297
|
-
- lib/chewy/query/nodes/exists.rb
|
298
|
-
- lib/chewy/query/nodes/expr.rb
|
299
|
-
- lib/chewy/query/nodes/field.rb
|
300
|
-
- lib/chewy/query/nodes/has_child.rb
|
301
|
-
- lib/chewy/query/nodes/has_parent.rb
|
302
|
-
- lib/chewy/query/nodes/has_relation.rb
|
303
|
-
- lib/chewy/query/nodes/match_all.rb
|
304
|
-
- lib/chewy/query/nodes/missing.rb
|
305
|
-
- lib/chewy/query/nodes/not.rb
|
306
|
-
- lib/chewy/query/nodes/or.rb
|
307
|
-
- lib/chewy/query/nodes/prefix.rb
|
308
|
-
- lib/chewy/query/nodes/query.rb
|
309
|
-
- lib/chewy/query/nodes/range.rb
|
310
|
-
- lib/chewy/query/nodes/raw.rb
|
311
|
-
- lib/chewy/query/nodes/regexp.rb
|
312
|
-
- lib/chewy/query/nodes/script.rb
|
313
|
-
- lib/chewy/query/pagination.rb
|
289
|
+
- lib/chewy/multi_search.rb
|
314
290
|
- lib/chewy/railtie.rb
|
315
291
|
- lib/chewy/rake_helper.rb
|
316
292
|
- lib/chewy/repository.rb
|
@@ -324,6 +300,7 @@ files:
|
|
324
300
|
- lib/chewy/search/pagination/will_paginate.rb
|
325
301
|
- lib/chewy/search/parameters.rb
|
326
302
|
- lib/chewy/search/parameters/aggs.rb
|
303
|
+
- lib/chewy/search/parameters/allow_partial_search_results.rb
|
327
304
|
- lib/chewy/search/parameters/concerns/bool_storage.rb
|
328
305
|
- lib/chewy/search/parameters/concerns/hash_storage.rb
|
329
306
|
- lib/chewy/search/parameters/concerns/integer_storage.rb
|
@@ -334,6 +311,7 @@ files:
|
|
334
311
|
- lib/chewy/search/parameters/explain.rb
|
335
312
|
- lib/chewy/search/parameters/filter.rb
|
336
313
|
- lib/chewy/search/parameters/highlight.rb
|
314
|
+
- lib/chewy/search/parameters/indices.rb
|
337
315
|
- lib/chewy/search/parameters/indices_boost.rb
|
338
316
|
- lib/chewy/search/parameters/limit.rb
|
339
317
|
- lib/chewy/search/parameters/load.rb
|
@@ -357,7 +335,6 @@ files:
|
|
357
335
|
- lib/chewy/search/parameters/terminate_after.rb
|
358
336
|
- lib/chewy/search/parameters/timeout.rb
|
359
337
|
- lib/chewy/search/parameters/track_scores.rb
|
360
|
-
- lib/chewy/search/parameters/types.rb
|
361
338
|
- lib/chewy/search/parameters/version.rb
|
362
339
|
- lib/chewy/search/query_proxy.rb
|
363
340
|
- lib/chewy/search/request.rb
|
@@ -398,6 +375,7 @@ files:
|
|
398
375
|
- lib/generators/templates/chewy.yml
|
399
376
|
- lib/sequel/plugins/chewy_observe.rb
|
400
377
|
- lib/tasks/chewy.rake
|
378
|
+
- migration_guide.md
|
401
379
|
- spec/chewy/config_spec.rb
|
402
380
|
- spec/chewy/fields/base_spec.rb
|
403
381
|
- spec/chewy/fields/root_spec.rb
|
@@ -410,29 +388,7 @@ files:
|
|
410
388
|
- spec/chewy/journal_spec.rb
|
411
389
|
- spec/chewy/minitest/helpers_spec.rb
|
412
390
|
- spec/chewy/minitest/search_index_receiver_spec.rb
|
413
|
-
- spec/chewy/
|
414
|
-
- spec/chewy/query/filters_spec.rb
|
415
|
-
- spec/chewy/query/loading_spec.rb
|
416
|
-
- spec/chewy/query/nodes/and_spec.rb
|
417
|
-
- spec/chewy/query/nodes/bool_spec.rb
|
418
|
-
- spec/chewy/query/nodes/equal_spec.rb
|
419
|
-
- spec/chewy/query/nodes/exists_spec.rb
|
420
|
-
- spec/chewy/query/nodes/has_child_spec.rb
|
421
|
-
- spec/chewy/query/nodes/has_parent_spec.rb
|
422
|
-
- spec/chewy/query/nodes/match_all_spec.rb
|
423
|
-
- spec/chewy/query/nodes/missing_spec.rb
|
424
|
-
- spec/chewy/query/nodes/not_spec.rb
|
425
|
-
- spec/chewy/query/nodes/or_spec.rb
|
426
|
-
- spec/chewy/query/nodes/prefix_spec.rb
|
427
|
-
- spec/chewy/query/nodes/query_spec.rb
|
428
|
-
- spec/chewy/query/nodes/range_spec.rb
|
429
|
-
- spec/chewy/query/nodes/raw_spec.rb
|
430
|
-
- spec/chewy/query/nodes/regexp_spec.rb
|
431
|
-
- spec/chewy/query/nodes/script_spec.rb
|
432
|
-
- spec/chewy/query/pagination/kaminari_spec.rb
|
433
|
-
- spec/chewy/query/pagination/will_paginate_spec.rb
|
434
|
-
- spec/chewy/query/pagination_spec.rb
|
435
|
-
- spec/chewy/query_spec.rb
|
391
|
+
- spec/chewy/multi_search_spec.rb
|
436
392
|
- spec/chewy/rake_helper_spec.rb
|
437
393
|
- spec/chewy/repository_spec.rb
|
438
394
|
- spec/chewy/rspec/update_index_spec.rb
|
@@ -450,7 +406,7 @@ files:
|
|
450
406
|
- spec/chewy/search/parameters/filter_spec.rb
|
451
407
|
- spec/chewy/search/parameters/hash_storage_examples.rb
|
452
408
|
- spec/chewy/search/parameters/highlight_spec.rb
|
453
|
-
- spec/chewy/search/parameters/
|
409
|
+
- spec/chewy/search/parameters/indices_spec.rb
|
454
410
|
- spec/chewy/search/parameters/integer_storage_examples.rb
|
455
411
|
- spec/chewy/search/parameters/limit_spec.rb
|
456
412
|
- spec/chewy/search/parameters/load_spec.rb
|
@@ -477,7 +433,6 @@ files:
|
|
477
433
|
- spec/chewy/search/parameters/terminate_after_spec.rb
|
478
434
|
- spec/chewy/search/parameters/timeout_spec.rb
|
479
435
|
- spec/chewy/search/parameters/track_scores_spec.rb
|
480
|
-
- spec/chewy/search/parameters/types_spec.rb
|
481
436
|
- spec/chewy/search/parameters/version_spec.rb
|
482
437
|
- spec/chewy/search/parameters_spec.rb
|
483
438
|
- spec/chewy/search/query_proxy_spec.rb
|
@@ -519,7 +474,7 @@ homepage: https://github.com/toptal/chewy
|
|
519
474
|
licenses:
|
520
475
|
- MIT
|
521
476
|
metadata: {}
|
522
|
-
post_install_message:
|
477
|
+
post_install_message:
|
523
478
|
rdoc_options: []
|
524
479
|
require_paths:
|
525
480
|
- lib
|
@@ -534,9 +489,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
534
489
|
- !ruby/object:Gem::Version
|
535
490
|
version: '0'
|
536
491
|
requirements: []
|
537
|
-
|
538
|
-
|
539
|
-
signing_key:
|
492
|
+
rubygems_version: 3.1.2
|
493
|
+
signing_key:
|
540
494
|
specification_version: 4
|
541
495
|
summary: Elasticsearch ODM client wrapper
|
542
496
|
test_files:
|
@@ -552,29 +506,7 @@ test_files:
|
|
552
506
|
- spec/chewy/journal_spec.rb
|
553
507
|
- spec/chewy/minitest/helpers_spec.rb
|
554
508
|
- spec/chewy/minitest/search_index_receiver_spec.rb
|
555
|
-
- spec/chewy/
|
556
|
-
- spec/chewy/query/filters_spec.rb
|
557
|
-
- spec/chewy/query/loading_spec.rb
|
558
|
-
- spec/chewy/query/nodes/and_spec.rb
|
559
|
-
- spec/chewy/query/nodes/bool_spec.rb
|
560
|
-
- spec/chewy/query/nodes/equal_spec.rb
|
561
|
-
- spec/chewy/query/nodes/exists_spec.rb
|
562
|
-
- spec/chewy/query/nodes/has_child_spec.rb
|
563
|
-
- spec/chewy/query/nodes/has_parent_spec.rb
|
564
|
-
- spec/chewy/query/nodes/match_all_spec.rb
|
565
|
-
- spec/chewy/query/nodes/missing_spec.rb
|
566
|
-
- spec/chewy/query/nodes/not_spec.rb
|
567
|
-
- spec/chewy/query/nodes/or_spec.rb
|
568
|
-
- spec/chewy/query/nodes/prefix_spec.rb
|
569
|
-
- spec/chewy/query/nodes/query_spec.rb
|
570
|
-
- spec/chewy/query/nodes/range_spec.rb
|
571
|
-
- spec/chewy/query/nodes/raw_spec.rb
|
572
|
-
- spec/chewy/query/nodes/regexp_spec.rb
|
573
|
-
- spec/chewy/query/nodes/script_spec.rb
|
574
|
-
- spec/chewy/query/pagination/kaminari_spec.rb
|
575
|
-
- spec/chewy/query/pagination/will_paginate_spec.rb
|
576
|
-
- spec/chewy/query/pagination_spec.rb
|
577
|
-
- spec/chewy/query_spec.rb
|
509
|
+
- spec/chewy/multi_search_spec.rb
|
578
510
|
- spec/chewy/rake_helper_spec.rb
|
579
511
|
- spec/chewy/repository_spec.rb
|
580
512
|
- spec/chewy/rspec/update_index_spec.rb
|
@@ -592,7 +524,7 @@ test_files:
|
|
592
524
|
- spec/chewy/search/parameters/filter_spec.rb
|
593
525
|
- spec/chewy/search/parameters/hash_storage_examples.rb
|
594
526
|
- spec/chewy/search/parameters/highlight_spec.rb
|
595
|
-
- spec/chewy/search/parameters/
|
527
|
+
- spec/chewy/search/parameters/indices_spec.rb
|
596
528
|
- spec/chewy/search/parameters/integer_storage_examples.rb
|
597
529
|
- spec/chewy/search/parameters/limit_spec.rb
|
598
530
|
- spec/chewy/search/parameters/load_spec.rb
|
@@ -619,7 +551,6 @@ test_files:
|
|
619
551
|
- spec/chewy/search/parameters/terminate_after_spec.rb
|
620
552
|
- spec/chewy/search/parameters/timeout_spec.rb
|
621
553
|
- spec/chewy/search/parameters/track_scores_spec.rb
|
622
|
-
- spec/chewy/search/parameters/types_spec.rb
|
623
554
|
- spec/chewy/search/parameters/version_spec.rb
|
624
555
|
- spec/chewy/search/parameters_spec.rb
|
625
556
|
- spec/chewy/search/query_proxy_spec.rb
|