chewy 0.10.1 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +240 -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/.rubocop.yml +25 -25
- data/Appraisals +12 -10
- data/CHANGELOG.md +312 -331
- data/CODE_OF_CONDUCT.md +14 -0
- data/CONTRIBUTING.md +63 -0
- data/Gemfile +5 -1
- data/LICENSE.txt +1 -1
- data/README.md +143 -77
- data/chewy.gemspec +10 -12
- data/gemfiles/{rails.4.2.mongoid.5.1.gemfile → rails.5.2.activerecord.gemfile} +6 -4
- data/gemfiles/{rails.4.2.activerecord.gemfile → rails.5.2.mongoid.6.4.gemfile} +6 -4
- data/gemfiles/{rails.4.0.activerecord.gemfile → rails.6.0.activerecord.gemfile} +6 -3
- data/gemfiles/rails.6.1.activerecord.gemfile +19 -0
- data/gemfiles/sequel.4.45.gemfile +2 -2
- data/lib/chewy.rb +2 -1
- data/lib/chewy/backports/duplicable.rb +1 -1
- data/lib/chewy/config.rb +10 -39
- data/lib/chewy/fields/base.rb +9 -3
- data/lib/chewy/fields/root.rb +13 -9
- data/lib/chewy/index.rb +3 -1
- data/lib/chewy/index/actions.rb +28 -16
- data/lib/chewy/index/aliases.rb +16 -5
- data/lib/chewy/index/settings.rb +2 -0
- data/lib/chewy/index/specification.rb +12 -10
- data/lib/chewy/minitest/helpers.rb +6 -6
- data/lib/chewy/minitest/search_index_receiver.rb +17 -17
- data/lib/chewy/multi_search.rb +62 -0
- data/lib/chewy/railtie.rb +3 -5
- data/lib/chewy/rake_helper.rb +5 -5
- data/lib/chewy/rspec/update_index.rb +3 -5
- data/lib/chewy/search.rb +4 -11
- data/lib/chewy/search/loader.rb +1 -1
- 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/concerns/query_storage.rb +4 -3
- data/lib/chewy/search/parameters/indices.rb +123 -0
- data/lib/chewy/search/parameters/none.rb +1 -3
- data/lib/chewy/search/request.rb +101 -74
- data/lib/chewy/search/scrolling.rb +7 -6
- data/lib/chewy/stash.rb +31 -22
- data/lib/chewy/strategy/active_job.rb +1 -1
- data/lib/chewy/strategy/atomic.rb +1 -1
- data/lib/chewy/strategy/sidekiq.rb +1 -1
- data/lib/chewy/type.rb +5 -2
- data/lib/chewy/type/adapter/active_record.rb +1 -1
- data/lib/chewy/type/adapter/base.rb +9 -9
- data/lib/chewy/type/adapter/mongoid.rb +2 -4
- data/lib/chewy/type/adapter/orm.rb +7 -4
- data/lib/chewy/type/adapter/sequel.rb +5 -7
- data/lib/chewy/type/crutch.rb +1 -1
- data/lib/chewy/type/import.rb +16 -5
- data/lib/chewy/type/import/bulk_builder.rb +1 -1
- data/lib/chewy/type/import/bulk_request.rb +4 -2
- data/lib/chewy/type/import/journal_builder.rb +3 -3
- data/lib/chewy/type/import/routine.rb +3 -3
- data/lib/chewy/type/mapping.rb +42 -36
- data/lib/chewy/type/observe.rb +16 -12
- data/lib/chewy/type/syncer.rb +6 -7
- data/lib/chewy/type/witchcraft.rb +5 -3
- data/lib/chewy/type/wrapper.rb +14 -4
- data/lib/chewy/version.rb +1 -1
- data/lib/sequel/plugins/chewy_observe.rb +4 -19
- data/migration_guide.md +34 -0
- data/spec/chewy/config_spec.rb +16 -21
- data/spec/chewy/fields/base_spec.rb +68 -70
- data/spec/chewy/fields/root_spec.rb +13 -13
- data/spec/chewy/index/actions_spec.rb +157 -38
- data/spec/chewy/index/aliases_spec.rb +3 -3
- data/spec/chewy/index/specification_spec.rb +25 -16
- data/spec/chewy/index_spec.rb +75 -45
- data/spec/chewy/journal_spec.rb +33 -29
- 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 +123 -95
- data/spec/chewy/rspec/update_index_spec.rb +47 -46
- data/spec/chewy/runtime_spec.rb +2 -2
- data/spec/chewy/search/parameters/indices_spec.rb +190 -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 +103 -70
- data/spec/chewy/search/response_spec.rb +27 -17
- data/spec/chewy/search/scrolling_spec.rb +27 -17
- data/spec/chewy/search_spec.rb +49 -35
- data/spec/chewy/stash_spec.rb +15 -13
- data/spec/chewy/strategy/active_job_spec.rb +15 -2
- data/spec/chewy/strategy/shoryuken_spec.rb +8 -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/journal_builder_spec.rb +17 -15
- data/spec/chewy/type/import_spec.rb +15 -0
- data/spec/chewy/type/mapping_spec.rb +51 -18
- 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 +5 -1
- data/spec/support/active_record.rb +21 -0
- metadata +51 -116
- data/.travis.yml +0 -53
- data/LEGACY_DSL.md +0 -497
- data/gemfiles/rails.4.1.activerecord.gemfile +0 -14
- data/gemfiles/rails.5.0.activerecord.gemfile +0 -15
- data/gemfiles/rails.5.0.mongoid.6.0.gemfile +0 -15
- data/gemfiles/rails.5.1.activerecord.gemfile +0 -15
- data/gemfiles/rails.5.1.mongoid.6.1.gemfile +0 -15
- data/lib/chewy/query.rb +0 -1098
- data/lib/chewy/query/compose.rb +0 -68
- data/lib/chewy/query/criteria.rb +0 -191
- data/lib/chewy/query/filters.rb +0 -227
- data/lib/chewy/query/loading.rb +0 -111
- 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/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 -13
- 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 -636
- data/spec/chewy/search/parameters/indices_boost_spec.rb +0 -83
@@ -29,7 +29,9 @@ describe :search_index_receiver do
|
|
29
29
|
define_type :fizz do
|
30
30
|
root value: ->(_o) { {} }
|
31
31
|
end
|
32
|
+
end
|
32
33
|
|
34
|
+
stub_index(:dummies2) do
|
33
35
|
define_type :buzz do
|
34
36
|
root value: ->(_o) { {} }
|
35
37
|
end
|
@@ -39,15 +41,15 @@ describe :search_index_receiver do
|
|
39
41
|
context 'catch' do
|
40
42
|
specify 'archives more than one type' do
|
41
43
|
receiver.catch search_request(2), DummiesIndex::Fizz
|
42
|
-
receiver.catch search_request(3),
|
43
|
-
expect(receiver.indexes.keys).to match_array([DummiesIndex::Fizz,
|
44
|
+
receiver.catch search_request(3), Dummies2Index::Buzz
|
45
|
+
expect(receiver.indexes.keys).to match_array([DummiesIndex::Fizz, Dummies2Index::Buzz])
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
47
49
|
context 'indexes_for' do
|
48
50
|
before do
|
49
51
|
receiver.catch search_request(2), DummiesIndex::Fizz
|
50
|
-
receiver.catch search_request(3),
|
52
|
+
receiver.catch search_request(3), Dummies2Index::Buzz
|
51
53
|
end
|
52
54
|
|
53
55
|
specify 'returns indexes for a specific type' do
|
@@ -56,7 +58,7 @@ describe :search_index_receiver do
|
|
56
58
|
|
57
59
|
specify 'returns only indexes for all types' do
|
58
60
|
index_responses = receiver.indexes
|
59
|
-
expect(index_responses.keys).to match_array([DummiesIndex::Fizz,
|
61
|
+
expect(index_responses.keys).to match_array([DummiesIndex::Fizz, Dummies2Index::Buzz])
|
60
62
|
expect(parse_request(index_responses.values.flatten)).to match_array([1, 2, 1, 2, 3])
|
61
63
|
end
|
62
64
|
end
|
@@ -64,16 +66,16 @@ describe :search_index_receiver do
|
|
64
66
|
context 'deletes_for' do
|
65
67
|
before do
|
66
68
|
receiver.catch search_request(2, verb: :delete), DummiesIndex::Fizz
|
67
|
-
receiver.catch search_request(3, verb: :delete),
|
69
|
+
receiver.catch search_request(3, verb: :delete), Dummies2Index::Buzz
|
68
70
|
end
|
69
71
|
|
70
72
|
specify 'returns deletes for a specific type' do
|
71
|
-
expect(receiver.deletes_for(
|
73
|
+
expect(receiver.deletes_for(Dummies2Index::Buzz)).to match_array([1, 2, 3])
|
72
74
|
end
|
73
75
|
|
74
76
|
specify 'returns only deletes for all types' do
|
75
77
|
deletes = receiver.deletes
|
76
|
-
expect(deletes.keys).to match_array([DummiesIndex::Fizz,
|
78
|
+
expect(deletes.keys).to match_array([DummiesIndex::Fizz, Dummies2Index::Buzz])
|
77
79
|
expect(deletes.values.flatten).to match_array([1, 2, 1, 2, 3])
|
78
80
|
end
|
79
81
|
end
|
@@ -113,8 +115,8 @@ describe :search_index_receiver do
|
|
113
115
|
context 'updated_indexes' do
|
114
116
|
specify 'provides a list of indices updated' do
|
115
117
|
receiver.catch search_request(2, verb: :delete), DummiesIndex::Fizz
|
116
|
-
receiver.catch search_request(3, verb: :delete),
|
117
|
-
expect(receiver.updated_indexes).to match_array([DummiesIndex::Fizz,
|
118
|
+
receiver.catch search_request(3, verb: :delete), Dummies2Index::Buzz
|
119
|
+
expect(receiver.updated_indexes).to match_array([DummiesIndex::Fizz, Dummies2Index::Buzz])
|
118
120
|
end
|
119
121
|
end
|
120
122
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'chewy/multi_search'
|
3
|
+
|
4
|
+
describe Chewy::MultiSearch do
|
5
|
+
before { Chewy.massacre }
|
6
|
+
|
7
|
+
before do
|
8
|
+
stub_model(:city)
|
9
|
+
stub_model(:country)
|
10
|
+
|
11
|
+
stub_index(:cities) do
|
12
|
+
def self.aggregate_by_country
|
13
|
+
aggs(country: {terms: {field: :country_id}})
|
14
|
+
end
|
15
|
+
|
16
|
+
define_type City do
|
17
|
+
field :name, type: 'keyword'
|
18
|
+
field :country_id, type: 'keyword'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:places_query) { CitiesIndex.all }
|
24
|
+
|
25
|
+
describe '#queries' do
|
26
|
+
specify 'returns the queries that are a part of the multi search' do
|
27
|
+
multi_search = described_class.new([places_query])
|
28
|
+
expect(multi_search.queries).to contain_exactly(places_query)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#add_query' do
|
33
|
+
specify 'adds a query to the multi search' do
|
34
|
+
multi_search = described_class.new([])
|
35
|
+
expect do
|
36
|
+
multi_search.add_query(places_query)
|
37
|
+
end.to change {
|
38
|
+
multi_search.queries
|
39
|
+
}.from([]).to([places_query])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when given two queries' do
|
44
|
+
let(:queries) { [aggregates, results] }
|
45
|
+
let(:aggregates) { CitiesIndex.aggregate_by_country.limit(0) }
|
46
|
+
let(:results) { CitiesIndex.limit(10) }
|
47
|
+
let(:multi_search) { described_class.new(queries) }
|
48
|
+
let(:cities) { Array.new(3) { |i| City.create! name: "Name#{i + 2}", country_id: i + 1 } }
|
49
|
+
before { CitiesIndex.import! city: cities }
|
50
|
+
|
51
|
+
describe '#perform' do
|
52
|
+
specify 'performs each query' do
|
53
|
+
expect { multi_search.perform }
|
54
|
+
.to change(aggregates, :performed?).from(false).to(true)
|
55
|
+
.and change(results, :performed?).from(false).to(true)
|
56
|
+
end
|
57
|
+
|
58
|
+
specify 'issues a single request using the msearch endpoint', :aggregate_failures do
|
59
|
+
expect(Chewy.client).to receive(:msearch).once.and_return('responses' => [])
|
60
|
+
expect(Chewy.client).to_not receive(:search)
|
61
|
+
multi_search.perform
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#responses' do
|
66
|
+
subject(:responses) { multi_search.responses }
|
67
|
+
|
68
|
+
context 'on a previously performed multi search' do
|
69
|
+
before { multi_search.perform }
|
70
|
+
|
71
|
+
it 'does not perform the query again' do
|
72
|
+
expect(Chewy.client).to_not receive(:msearch)
|
73
|
+
multi_search.responses
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
specify 'returns the results of each query', :aggregate_failures do
|
78
|
+
is_expected.to have(2).responses
|
79
|
+
expect(responses[0]).to be_a(Chewy::Search::Response)
|
80
|
+
expect(responses[1]).to be_a(Chewy::Search::Response)
|
81
|
+
expect(responses[1].wrappers).to all(be_a CitiesIndex::City)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -7,24 +7,39 @@ describe Chewy::RakeHelper, :orm do
|
|
7
7
|
stub_model(:city)
|
8
8
|
stub_model(:country)
|
9
9
|
|
10
|
-
stub_index(:
|
10
|
+
stub_index(:cities) do
|
11
11
|
define_type City do
|
12
12
|
field :name
|
13
13
|
field :updated_at, type: 'date'
|
14
14
|
end
|
15
|
+
end
|
16
|
+
stub_index(:countries) do
|
15
17
|
define_type Country
|
16
18
|
end
|
17
19
|
stub_index(:users)
|
18
20
|
|
19
|
-
allow(described_class).to receive(:all_indexes) { [
|
21
|
+
allow(described_class).to receive(:all_indexes) { [CitiesIndex, CountriesIndex, UsersIndex] }
|
20
22
|
end
|
21
23
|
|
22
24
|
let!(:cities) { Array.new(3) { |i| City.create!(name: "Name#{i + 1}") } }
|
23
25
|
let!(:countries) { Array.new(2) { |i| Country.create!(name: "Name#{i + 1}") } }
|
24
26
|
let(:journal) do
|
25
27
|
Chewy::Stash::Journal.import([
|
26
|
-
{
|
27
|
-
|
28
|
+
{
|
29
|
+
index_name: 'cities',
|
30
|
+
type_name: 'city',
|
31
|
+
action: 'index',
|
32
|
+
references: cities.first(2).map(&:id).map(&:to_s)
|
33
|
+
.map(&:to_json).map(&Base64.method(:encode64)),
|
34
|
+
created_at: 2.minutes.since
|
35
|
+
},
|
36
|
+
{
|
37
|
+
index_name: 'countries',
|
38
|
+
type_name: 'country',
|
39
|
+
action: 'index',
|
40
|
+
references: [Base64.encode64(countries.first.id.to_s.to_json)],
|
41
|
+
created_at: 4.minutes.since
|
42
|
+
}
|
28
43
|
])
|
29
44
|
end
|
30
45
|
|
@@ -34,44 +49,45 @@ describe Chewy::RakeHelper, :orm do
|
|
34
49
|
specify do
|
35
50
|
output = StringIO.new
|
36
51
|
expect { described_class.reset(output: output) }
|
37
|
-
.to update_index(
|
52
|
+
.to update_index(CitiesIndex)
|
38
53
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
39
|
-
\\AResetting
|
40
|
-
Imported
|
41
|
-
|
42
|
-
|
43
|
-
Imported
|
44
|
-
|
45
|
-
Imported
|
54
|
+
\\AResetting CitiesIndex
|
55
|
+
Imported CitiesIndex::City in \\d+s, stats: index 3
|
56
|
+
Applying journal to \\[CitiesIndex::City\\], 2 entries, stage 1
|
57
|
+
Imported CitiesIndex::City in \\d+s, stats: index 2
|
58
|
+
Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
|
59
|
+
Resetting CountriesIndex
|
60
|
+
Imported CountriesIndex::Country in \\d+s, stats: index 2
|
61
|
+
Applying journal to \\[CountriesIndex::Country\\], 1 entries, stage 1
|
62
|
+
Imported CountriesIndex::Country in \\d+s, stats: index 1
|
63
|
+
Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
|
46
64
|
Resetting UsersIndex
|
47
|
-
Imported Chewy::Stash::Specification
|
65
|
+
Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
|
48
66
|
Total: \\d+s\\Z
|
49
67
|
OUTPUT
|
50
68
|
end
|
51
69
|
|
52
70
|
specify do
|
53
71
|
output = StringIO.new
|
54
|
-
expect { described_class.reset(only: '
|
55
|
-
.to update_index(
|
72
|
+
expect { described_class.reset(only: 'cities', output: output) }
|
73
|
+
.to update_index(CitiesIndex)
|
56
74
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
57
|
-
\\AResetting
|
58
|
-
Imported
|
59
|
-
|
60
|
-
|
61
|
-
Imported
|
62
|
-
Imported PlacesIndex::Country for \\d+s, stats: index 1
|
63
|
-
Imported Chewy::Stash::Specification for \\d+s, stats: index 1
|
75
|
+
\\AResetting CitiesIndex
|
76
|
+
Imported CitiesIndex::City in \\d+s, stats: index 3
|
77
|
+
Applying journal to \\[CitiesIndex::City\\], 2 entries, stage 1
|
78
|
+
Imported CitiesIndex::City in \\d+s, stats: index 2
|
79
|
+
Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
|
64
80
|
Total: \\d+s\\Z
|
65
81
|
OUTPUT
|
66
82
|
end
|
67
83
|
|
68
84
|
specify do
|
69
85
|
output = StringIO.new
|
70
|
-
expect { described_class.reset(except:
|
71
|
-
.not_to update_index(
|
86
|
+
expect { described_class.reset(except: [CitiesIndex, CountriesIndex], output: output) }
|
87
|
+
.not_to update_index(CitiesIndex)
|
72
88
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
73
89
|
\\AResetting UsersIndex
|
74
|
-
Imported Chewy::Stash::Specification
|
90
|
+
Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
|
75
91
|
Total: \\d+s\\Z
|
76
92
|
OUTPUT
|
77
93
|
end
|
@@ -81,40 +97,46 @@ Total: \\d+s\\Z
|
|
81
97
|
specify do
|
82
98
|
output = StringIO.new
|
83
99
|
expect { described_class.upgrade(output: output) }
|
84
|
-
.to update_index(
|
100
|
+
.to update_index(CitiesIndex)
|
85
101
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
86
|
-
\\AResetting
|
87
|
-
Imported
|
88
|
-
Imported
|
89
|
-
|
102
|
+
\\AResetting CitiesIndex
|
103
|
+
Imported CitiesIndex::City in \\d+s, stats: index 3
|
104
|
+
Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
|
105
|
+
Resetting CountriesIndex
|
106
|
+
Imported CountriesIndex::Country in \\d+s, stats: index 2
|
107
|
+
Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
|
90
108
|
Resetting UsersIndex
|
91
|
-
Imported Chewy::Stash::Specification
|
109
|
+
Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
|
92
110
|
Total: \\d+s\\Z
|
93
111
|
OUTPUT
|
94
112
|
end
|
95
113
|
|
96
114
|
context do
|
97
|
-
before
|
115
|
+
before do
|
116
|
+
CitiesIndex.reset!
|
117
|
+
CountriesIndex.reset!
|
118
|
+
end
|
98
119
|
|
99
120
|
specify do
|
100
121
|
output = StringIO.new
|
101
122
|
expect { described_class.upgrade(output: output) }
|
102
|
-
.not_to update_index(
|
123
|
+
.not_to update_index(CitiesIndex)
|
103
124
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
104
|
-
\\ASkipping
|
125
|
+
\\ASkipping CitiesIndex, the specification didn't change
|
126
|
+
Skipping CountriesIndex, the specification didn't change
|
105
127
|
Resetting UsersIndex
|
106
|
-
Imported Chewy::Stash::Specification
|
128
|
+
Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
|
107
129
|
Total: \\d+s\\Z
|
108
130
|
OUTPUT
|
109
131
|
end
|
110
132
|
|
111
133
|
specify do
|
112
134
|
output = StringIO.new
|
113
|
-
expect { described_class.upgrade(except:
|
114
|
-
.not_to update_index(
|
135
|
+
expect { described_class.upgrade(except: [CitiesIndex, CountriesIndex], output: output) }
|
136
|
+
.not_to update_index(CitiesIndex)
|
115
137
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
116
138
|
\\AResetting UsersIndex
|
117
|
-
Imported Chewy::Stash::Specification
|
139
|
+
Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
|
118
140
|
Total: \\d+s\\Z
|
119
141
|
OUTPUT
|
120
142
|
end
|
@@ -124,8 +146,8 @@ Total: \\d+s\\Z
|
|
124
146
|
|
125
147
|
specify do
|
126
148
|
output = StringIO.new
|
127
|
-
expect { described_class.upgrade(except: [
|
128
|
-
.not_to update_index(
|
149
|
+
expect { described_class.upgrade(except: %w[cities countries], output: output) }
|
150
|
+
.not_to update_index(CitiesIndex)
|
129
151
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
130
152
|
\\ANo index specification was changed
|
131
153
|
Total: \\d+s\\Z
|
@@ -139,45 +161,51 @@ Total: \\d+s\\Z
|
|
139
161
|
specify do
|
140
162
|
output = StringIO.new
|
141
163
|
expect { described_class.update(output: output) }
|
142
|
-
.not_to update_index(
|
164
|
+
.not_to update_index(CitiesIndex)
|
143
165
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
144
|
-
\\ASkipping
|
166
|
+
\\ASkipping CitiesIndex, it does not exists \\(use rake chewy:reset\\[cities\\] to create and update it\\)
|
167
|
+
Skipping CountriesIndex, it does not exists \\(use rake chewy:reset\\[countries\\] to create and update it\\)
|
168
|
+
Total: \\d+s\\Z
|
145
169
|
OUTPUT
|
146
170
|
end
|
147
171
|
|
148
172
|
context do
|
149
|
-
before
|
173
|
+
before do
|
174
|
+
CitiesIndex.reset!
|
175
|
+
CountriesIndex.reset!
|
176
|
+
end
|
150
177
|
|
151
178
|
specify do
|
152
179
|
output = StringIO.new
|
153
180
|
expect { described_class.update(output: output) }
|
154
|
-
.to update_index(
|
181
|
+
.to update_index(CitiesIndex)
|
155
182
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
156
|
-
\\AUpdating
|
157
|
-
Imported
|
158
|
-
|
183
|
+
\\AUpdating CitiesIndex
|
184
|
+
Imported CitiesIndex::City in \\d+s, stats: index 3
|
185
|
+
Updating CountriesIndex
|
186
|
+
Imported CountriesIndex::Country in \\d+s, stats: index 2
|
159
187
|
Total: \\d+s\\Z
|
160
188
|
OUTPUT
|
161
189
|
end
|
162
190
|
|
163
191
|
specify do
|
164
192
|
output = StringIO.new
|
165
|
-
expect { described_class.update(only: '
|
166
|
-
.not_to update_index(
|
193
|
+
expect { described_class.update(only: 'countries', output: output) }
|
194
|
+
.not_to update_index(CitiesIndex)
|
167
195
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
168
|
-
\\AUpdating
|
169
|
-
Imported
|
196
|
+
\\AUpdating CountriesIndex
|
197
|
+
Imported CountriesIndex::Country in \\d+s, stats: index 2
|
170
198
|
Total: \\d+s\\Z
|
171
199
|
OUTPUT
|
172
200
|
end
|
173
201
|
|
174
202
|
specify do
|
175
203
|
output = StringIO.new
|
176
|
-
expect { described_class.update(except:
|
177
|
-
.to update_index(
|
204
|
+
expect { described_class.update(except: CountriesIndex, output: output) }
|
205
|
+
.to update_index(CitiesIndex)
|
178
206
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
179
|
-
\\AUpdating
|
180
|
-
Imported
|
207
|
+
\\AUpdating CitiesIndex
|
208
|
+
Imported CitiesIndex::City in \\d+s, stats: index 3
|
181
209
|
Total: \\d+s\\Z
|
182
210
|
OUTPUT
|
183
211
|
end
|
@@ -188,15 +216,15 @@ Total: \\d+s\\Z
|
|
188
216
|
specify do
|
189
217
|
output = StringIO.new
|
190
218
|
expect { described_class.sync(output: output) }
|
191
|
-
.to update_index(
|
219
|
+
.to update_index(CitiesIndex)
|
192
220
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
193
|
-
\\ASynchronizing
|
194
|
-
Imported
|
221
|
+
\\ASynchronizing CitiesIndex::City
|
222
|
+
Imported CitiesIndex::City in \\d+s, stats: index 3
|
195
223
|
Missing documents: \\[[^\\]]+\\]
|
196
224
|
Took \\d+s
|
197
|
-
Synchronizing
|
198
|
-
|
199
|
-
Imported
|
225
|
+
Synchronizing CountriesIndex::Country
|
226
|
+
CountriesIndex::Country doesn't support outdated synchronization
|
227
|
+
Imported CountriesIndex::Country in \\d+s, stats: index 2
|
200
228
|
Missing documents: \\[[^\\]]+\\]
|
201
229
|
Took \\d+s
|
202
230
|
Total: \\d+s\\Z
|
@@ -205,8 +233,8 @@ Total: \\d+s\\Z
|
|
205
233
|
|
206
234
|
context do
|
207
235
|
before do
|
208
|
-
|
209
|
-
|
236
|
+
CitiesIndex.import(cities.first(2))
|
237
|
+
CountriesIndex.import
|
210
238
|
|
211
239
|
sleep(1) if ActiveSupport::VERSION::STRING < '4.1.0'
|
212
240
|
cities.first.update(name: 'Name5')
|
@@ -215,16 +243,16 @@ Total: \\d+s\\Z
|
|
215
243
|
specify do
|
216
244
|
output = StringIO.new
|
217
245
|
expect { described_class.sync(output: output) }
|
218
|
-
.to update_index(
|
246
|
+
.to update_index(CitiesIndex)
|
219
247
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
220
|
-
\\ASynchronizing
|
221
|
-
Imported
|
248
|
+
\\ASynchronizing CitiesIndex::City
|
249
|
+
Imported CitiesIndex::City in \\d+s, stats: index 2
|
222
250
|
Missing documents: \\["#{cities.last.id}"\\]
|
223
251
|
Outdated documents: \\["#{cities.first.id}"\\]
|
224
252
|
Took \\d+s
|
225
|
-
Synchronizing
|
226
|
-
|
227
|
-
Skipping
|
253
|
+
Synchronizing CountriesIndex::Country
|
254
|
+
CountriesIndex::Country doesn't support outdated synchronization
|
255
|
+
Skipping CountriesIndex::Country, up to date
|
228
256
|
Took \\d+s
|
229
257
|
Total: \\d+s\\Z
|
230
258
|
OUTPUT
|
@@ -232,11 +260,11 @@ Total: \\d+s\\Z
|
|
232
260
|
|
233
261
|
specify do
|
234
262
|
output = StringIO.new
|
235
|
-
expect { described_class.sync(only:
|
236
|
-
.to update_index(
|
263
|
+
expect { described_class.sync(only: CitiesIndex, output: output) }
|
264
|
+
.to update_index(CitiesIndex)
|
237
265
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
238
|
-
\\ASynchronizing
|
239
|
-
Imported
|
266
|
+
\\ASynchronizing CitiesIndex::City
|
267
|
+
Imported CitiesIndex::City in \\d+s, stats: index 2
|
240
268
|
Missing documents: \\["#{cities.last.id}"\\]
|
241
269
|
Outdated documents: \\["#{cities.first.id}"\\]
|
242
270
|
Took \\d+s
|
@@ -246,12 +274,12 @@ Total: \\d+s\\Z
|
|
246
274
|
|
247
275
|
specify do
|
248
276
|
output = StringIO.new
|
249
|
-
expect { described_class.sync(except: ['
|
250
|
-
.not_to update_index(
|
277
|
+
expect { described_class.sync(except: ['cities'], output: output) }
|
278
|
+
.not_to update_index(CitiesIndex)
|
251
279
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
252
|
-
\\ASynchronizing
|
253
|
-
|
254
|
-
Skipping
|
280
|
+
\\ASynchronizing CountriesIndex::Country
|
281
|
+
CountriesIndex::Country doesn't support outdated synchronization
|
282
|
+
Skipping CountriesIndex::Country, up to date
|
255
283
|
Took \\d+s
|
256
284
|
Total: \\d+s\\Z
|
257
285
|
OUTPUT
|
@@ -277,12 +305,12 @@ Total: \\d+s\\Z
|
|
277
305
|
specify do
|
278
306
|
output = StringIO.new
|
279
307
|
expect { described_class.journal_apply(time: Time.now, output: output) }
|
280
|
-
.to update_index(
|
308
|
+
.to update_index(CitiesIndex)
|
281
309
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
282
310
|
\\AApplying journal entries created after [+-:\\d\\s]+
|
283
|
-
Applying journal to \\[
|
284
|
-
Imported
|
285
|
-
Imported
|
311
|
+
Applying journal to \\[CitiesIndex::City, CountriesIndex::Country\\], 3 entries, stage 1
|
312
|
+
Imported CitiesIndex::City in \\d+s, stats: index 2
|
313
|
+
Imported CountriesIndex::Country in \\d+s, stats: index 1
|
286
314
|
Total: \\d+s\\Z
|
287
315
|
OUTPUT
|
288
316
|
end
|
@@ -290,35 +318,35 @@ Total: \\d+s\\Z
|
|
290
318
|
specify do
|
291
319
|
output = StringIO.new
|
292
320
|
expect { described_class.journal_apply(time: 3.minutes.since, output: output) }
|
293
|
-
.not_to update_index(
|
321
|
+
.not_to update_index(CitiesIndex)
|
294
322
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
295
323
|
\\AApplying journal entries created after [+-:\\d\\s]+
|
296
|
-
Applying journal to \\[
|
297
|
-
Imported
|
324
|
+
Applying journal to \\[CountriesIndex::Country\\], 1 entries, stage 1
|
325
|
+
Imported CountriesIndex::Country in \\d+s, stats: index 1
|
298
326
|
Total: \\d+s\\Z
|
299
327
|
OUTPUT
|
300
328
|
end
|
301
329
|
|
302
330
|
specify do
|
303
331
|
output = StringIO.new
|
304
|
-
expect { described_class.journal_apply(time: Time.now, only:
|
305
|
-
.to update_index(
|
332
|
+
expect { described_class.journal_apply(time: Time.now, only: CitiesIndex, output: output) }
|
333
|
+
.to update_index(CitiesIndex)
|
306
334
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
307
335
|
\\AApplying journal entries created after [+-:\\d\\s]+
|
308
|
-
Applying journal to \\[
|
309
|
-
Imported
|
336
|
+
Applying journal to \\[CitiesIndex::City\\], 2 entries, stage 1
|
337
|
+
Imported CitiesIndex::City in \\d+s, stats: index 2
|
310
338
|
Total: \\d+s\\Z
|
311
339
|
OUTPUT
|
312
340
|
end
|
313
341
|
|
314
342
|
specify do
|
315
343
|
output = StringIO.new
|
316
|
-
expect { described_class.journal_apply(time: Time.now, except:
|
317
|
-
.not_to update_index(
|
344
|
+
expect { described_class.journal_apply(time: Time.now, except: CitiesIndex, output: output) }
|
345
|
+
.not_to update_index(CitiesIndex)
|
318
346
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
319
347
|
\\AApplying journal entries created after [+-:\\d\\s]+
|
320
|
-
Applying journal to \\[
|
321
|
-
Imported
|
348
|
+
Applying journal to \\[CountriesIndex::Country\\], 1 entries, stage 1
|
349
|
+
Imported CountriesIndex::Country in \\d+s, stats: index 1
|
322
350
|
Total: \\d+s\\Z
|
323
351
|
OUTPUT
|
324
352
|
end
|
@@ -349,7 +377,7 @@ Total: \\d+s\\Z
|
|
349
377
|
|
350
378
|
specify do
|
351
379
|
output = StringIO.new
|
352
|
-
described_class.journal_clean(only:
|
380
|
+
described_class.journal_clean(only: CitiesIndex, output: output)
|
353
381
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
354
382
|
\\ACleaned up 1 journal entries
|
355
383
|
Total: \\d+s\\Z
|
@@ -358,7 +386,7 @@ Total: \\d+s\\Z
|
|
358
386
|
|
359
387
|
specify do
|
360
388
|
output = StringIO.new
|
361
|
-
described_class.journal_clean(except:
|
389
|
+
described_class.journal_clean(except: CitiesIndex, output: output)
|
362
390
|
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
363
391
|
\\ACleaned up 1 journal entries
|
364
392
|
Total: \\d+s\\Z
|