chewy 6.0.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,14 @@
1
+ # The Chewy Community Code of Conduct
2
+
3
+ **Note:** We have picked the following code of conduct based on [Ruby's own code of conduct](https://www.ruby-lang.org/en/conduct/).
4
+
5
+ This document provides a few simple community guidelines for a safe, respectful,
6
+ productive, and collaborative place for any person who is willing to contribute
7
+ to the Chewy community. It applies to all "collaborative spaces", which are
8
+ defined as community communications channels (such as mailing lists, submitted
9
+ patches, commit comments, etc.).
10
+
11
+ * Participants will be tolerant of opposing views.
12
+ * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
13
+ * When interpreting the words and actions of others, participants should always assume good intentions.
14
+ * Behaviour which can be reasonably considered harassment will not be tolerated.
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,63 @@
1
+ # Contributing
2
+
3
+ If you discover issues, have ideas for improvements or new features,
4
+ please report them to the [issue tracker][1] of the repository or
5
+ submit a pull request. Please, try to follow these guidelines when you
6
+ do so.
7
+
8
+ ## Issue reporting
9
+
10
+ * Check that the issue has not already been reported.
11
+ * Check that the issue has not already been fixed in the latest code
12
+ (a.k.a. `master`).
13
+ * Be clear, concise and precise in your description of the problem.
14
+ * Open an issue with a descriptive title and a summary in grammatically correct,
15
+ complete sentences.
16
+ * Include the versions of Chewy, Elasticsearch, Ruby, Rails, etc.
17
+ * Include any relevant code to the issue summary.
18
+
19
+ ## Pull requests
20
+
21
+ * Read [how to properly contribute to open source projects on GitHub][2].
22
+ * Fork the project.
23
+ * Use a topic/feature branch to easily amend a pull request later, if necessary.
24
+ * Write [good commit messages][3].
25
+ * Use the same coding conventions as the rest of the project.
26
+ * Commit and push until you are happy with your contribution.
27
+ * If your change has a corresponding open GitHub issue, prefix the commit message with `[Fix #github-issue-number]`.
28
+ * Make sure to add tests for it. This is important so I don't break it
29
+ in a future version unintentionally.
30
+ * Add an entry to the [Changelog](CHANGELOG.md).
31
+ * Please try not to mess with the Rakefile, version, or history. If
32
+ you want to have your own version, or is otherwise necessary, that
33
+ is fine, but please isolate to its own commit so I can cherry-pick
34
+ around it.
35
+ * Make sure the test suite is passing and the code you wrote doesn't produce
36
+ RuboCop offenses.
37
+ * [Squash related commits together][5].
38
+ * Open a [pull request][4] that relates to *only* one subject with a clear title
39
+ and description in grammatically correct, complete sentences.
40
+
41
+ ## Changelog entry format
42
+
43
+ Here are a few examples:
44
+
45
+ ```
46
+ * [#753](https://github.com/toptal/chewy/pull/753): Add support for direct_import parameter to skip objects reloading. ([@TikiTDO][], [@dalthon][])
47
+ * [#739](https://github.com/toptal/chewy/pull/739): Remove explicit `main` branch dependencies on `rspec-*` gems after `rspec-mocks` 3.10.2 is released. ([@rabotyaga][])
48
+ ```
49
+
50
+ * Mark it up in [Markdown syntax][6].
51
+ * The entry line should start with `* ` (an asterisk and a space).
52
+ * If the change has a related GitHub issue (e.g. a bug fix for a reported issue), put a link to the issue as `[#123](https://github.com/toptal/chewy/issues/123): `.
53
+ * Describe the brief of the change. The sentence should end with a punctuation.
54
+ * If this is a breaking change, mark it with `**(Breaking)**`.
55
+ * At the end of the entry, add an implicit link to your GitHub user page as `([@username][])`.
56
+ * If this is your first contribution to the project, add a link definition for the implicit link to the bottom of the changelog as `[@username]: https://github.com/username`.
57
+
58
+ [1]: https://github.com/toptal/chewy/issues
59
+ [2]: https://www.gun.io/blog/how-to-github-fork-branch-and-pull-request
60
+ [3]: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
61
+ [4]: https://help.github.com/articles/about-pull-requests
62
+ [5]: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
63
+ [6]: https://daringfireball.net/projects/markdown/syntax
data/README.md CHANGED
@@ -95,13 +95,15 @@ Chewy is compatible with MRI 2.5-3.0¹.
95
95
 
96
96
  > ¹ Ruby 3 is only supported with Rails 6.1
97
97
 
98
- ### Elasticsearch
98
+ ### Elasticsearch compatibility matrix
99
99
 
100
- Chewy 5 is compatible with Elasticsearch 5.
100
+ | Chewy version | Elasticsearch version |
101
+ | ------------- | ---------------------------------- |
102
+ | 7.0.0 | 6.8, 7.x |
103
+ | 6.0.0 | 5.x, 6.x |
104
+ | 5.x | 5.x, limited support for 1.x & 2.x |
101
105
 
102
- Chewy 6 is compatible with Elasticsearch 6. See [Migration guide](migration_guide.md).
103
-
104
- Future versions of Chewy will support Elasticsearch 7.
106
+ See [Migration guide](migration_guide.md).
105
107
 
106
108
  ## Usage
107
109
 
@@ -1028,7 +1030,7 @@ rake chewy:update[-users,places#city] # updates every index in the application e
1028
1030
 
1029
1031
  #### `chewy:sync`
1030
1032
 
1031
- Provides a way to synchronize outdated indexes with the source quickly and without doing a full reset.
1033
+ Provides a way to synchronize outdated indexes with the source quickly and without doing a full reset. By default field `updated_at` is used to find outdated records, but this could be customized by `outdated_sync_field` as described at [Chewy::Type::Syncer](lib/chewy/type/syncer.rb).
1032
1034
 
1033
1035
  Arguments are similar to the ones taken by `chewy:update` task. It is possible to specify a particular type or a whole index.
1034
1036
 
@@ -182,7 +182,7 @@ module Chewy
182
182
  def reset!(suffix = nil, apply_journal: true, journal: false, **import_options)
183
183
  result = if suffix.present?
184
184
  start_time = Time.now
185
- indexes = self.indexes
185
+ indexes = self.indexes - [index_name]
186
186
  create! suffix, alias: false
187
187
 
188
188
  general_name = index_name
@@ -5,14 +5,25 @@ module Chewy
5
5
 
6
6
  module ClassMethods
7
7
  def indexes
8
- client.indices.get_alias(name: index_name).keys
9
- rescue Elasticsearch::Transport::Transport::Errors::NotFound
10
- []
8
+ get_args = {index: index_name}
9
+ get_args[:include_type_name] = true if Runtime.version >= '6.7.0'
10
+ indexes = empty_if_not_found { client.indices.get(**get_args).keys }
11
+ indexes += empty_if_not_found { client.indices.get_alias(name: index_name).keys }
12
+ indexes.compact.uniq
11
13
  end
12
14
 
13
15
  def aliases
14
- name = index_name
15
- client.indices.get_alias(index: name, name: '*')[name].try(:[], 'aliases').try(:keys) || []
16
+ empty_if_not_found do
17
+ client.indices.get_alias(index: index_name, name: '*').values.flat_map do |aliases|
18
+ aliases['aliases'].keys
19
+ end
20
+ end.compact.uniq
21
+ end
22
+
23
+ private
24
+
25
+ def empty_if_not_found
26
+ yield
16
27
  rescue Elasticsearch::Transport::Transport::Errors::NotFound
17
28
  []
18
29
  end
@@ -990,6 +990,7 @@ module Chewy
990
990
 
991
991
  def perform(additional = {})
992
992
  request_body = render.merge(additional)
993
+ request_body[:rest_total_hits_as_int] = true if Runtime.version >= '7.0.0'
993
994
  ActiveSupport::Notifications.instrument 'search_query.chewy',
994
995
  notification_payload(request: request_body) do
995
996
  begin
data/lib/chewy/stash.rb CHANGED
@@ -24,7 +24,7 @@ module Chewy
24
24
  # @param since_time [Time, DateTime] a timestamp from which we load a journal
25
25
  # @param only [Chewy::Index, Array<Chewy::Index>] journal entries related to these indices will be loaded only
26
26
  def self.entries(since_time, only: [])
27
- self.for(only).filter(range: {created_at: {gt: since_time}})
27
+ self.for(only).filter(range: {created_at: {gt: since_time}}).filter.minimum_should_match(1)
28
28
  end
29
29
 
30
30
  # Cleans up all the journal entries until the specified time. If nothing is
@@ -127,7 +127,8 @@ module Chewy
127
127
  private
128
128
 
129
129
  def import_routine(*args)
130
- return if args.first.blank? && !args.first.nil?
130
+ return if !args.first.nil? && empty_objects_or_scope?(args.first)
131
+
131
132
  routine = Routine.new(self, **args.extract_options!)
132
133
  routine.create_indexes!
133
134
 
@@ -138,6 +139,14 @@ module Chewy
138
139
  end
139
140
  end
140
141
 
142
+ def empty_objects_or_scope?(objects_or_scope)
143
+ if objects_or_scope.respond_to?(:empty?)
144
+ objects_or_scope.empty?
145
+ else
146
+ objects_or_scope.blank?
147
+ end
148
+ end
149
+
141
150
  def import_linear(objects, routine)
142
151
  ActiveSupport::Notifications.instrument 'import_objects.chewy', type: self do |payload|
143
152
  adapter.import(*objects, routine.options) do |action_objects|
data/lib/chewy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Chewy
2
- VERSION = '6.0.0'.freeze
2
+ VERSION = '7.0.0'.freeze
3
3
  end
data/migration_guide.md CHANGED
@@ -1,18 +1,34 @@
1
1
  # Migration guide
2
2
 
3
- ## Chewy 5 / ES 5 to Chewy 6 / ES 6
3
+ This document outlines the steps you need to take when migrating between major versions of
4
+ Chewy and Elasticsearch. For simplicity's sake the guide will assume that you're using
5
+ Chewy alongside a matching Elasticsearch version.
4
6
 
5
- In order to upgrade chewy5/ES5 to chewy6/ES6 in the most seamless manner you have to:
6
- * Upgrade to the latest 5.x stable releases: Chewy 5.2, ES 5.6
7
+ ## Chewy 6/Elasticsearch 6 to Chewy 7/Elasticsearch 7
8
+
9
+ In order to upgrade Chewy 6/Elasticsearch 6 to Chewy 7/Elasticsearch 7 in the most seamless manner you have to:
10
+
11
+ * Upgrade to the latest 6.x stable releases, namely Chewy 6.0, Elasticsearch 6.8
12
+ * Study carefully [Breaking changes in 7.0](https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.htmll), make sure your application conforms.
13
+ * Run your test suite on Chewy 7 / Elasticsearch 7
14
+ * Run manual tests on Chewy 7 / Elasticsearch 7
15
+ * Upgrade to Chewy 7
16
+ * Perform a [rolling upgrade](https://www.elastic.co/guide/en/elasticsearch/reference//rolling-upgrades.html) of Elasticsearch
17
+
18
+ ## Chewy 5/Elasticsearch 5 to Chewy 6/Elasticsearch 6
19
+
20
+ In order to upgrade Chewy 5/Elasticsearch 5 to Chewy 6/Elasticsearch 6 in the most seamless manner you have to:
21
+
22
+ * Upgrade to the latest 5.x stable releases, namely Chewy 5.2, Elasticsearch 5.6
7
23
  * [Migrate any multi-typed indexes into single-typed](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/removal-of-types.html)
8
24
  * Using [multi-index queries](https://github.com/toptal/chewy/pull/657) could be helpful
9
- * Parent/Child [relationship is deprecated](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/removal-of-types.html#parent-child-mapping-types) in favor of the [join field](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/parent-join.html)
25
+ * Parent/Child [relationship is deprecated](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/removal-of-types.html#parent-child-mapping-types) in favor of the [join field](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/parent-join.html)
10
26
  * Handle deprecation of `string` type & `not_analyzed` value for the `index` mapping parameter:
11
27
  * replace fields with `{ type: 'string', index: 'not_analyzed'}` by `{type: 'keyword'}`
12
28
  * replace fields with `{ type: 'string', index: 'analyzed'}` by `{type: 'text'}`
13
29
  * `PathHierarchy` tokenizer' param `delimiter` now accepts only one argument, [others should be replaced by character filter ](https://discuss.elastic.co/t/multichar-delimiter-in-path-hierarchy-tokenizer/16203)
14
- * Make sure you don't use any other of the [deprecated ES5 features](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/breaking-changes-6.0.html)
15
- * Run your test suite on ES6
16
- * Run manual tests on ES6
17
- * Perform a [rolling upgrade](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/rolling-upgrades.html) of Elasticsearch
30
+ * Make sure you don't use any other of the [deprecated Elasticsearch 5 features](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/breaking-changes-6.0.html)
31
+ * Run your test suite on Chewy 6 / Elasticsearch 6
32
+ * Run manual tests on Chewy 6 / Elasticsearch 6
18
33
  * Upgrade to Chewy 6
34
+ * Perform a [rolling upgrade](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/rolling-upgrades.html) of Elasticsearch
@@ -3,7 +3,10 @@ require 'spec_helper'
3
3
  describe Chewy::Index::Actions do
4
4
  before { Chewy.massacre }
5
5
 
6
- before { stub_index :dummies }
6
+ before do
7
+ stub_index :dummies
8
+ stub_index :dummies_suffixed
9
+ end
7
10
 
8
11
  describe '.exists?' do
9
12
  specify { expect(DummiesIndex.exists?).to eq(false) }
@@ -25,26 +28,40 @@ describe Chewy::Index::Actions do
25
28
  end
26
29
 
27
30
  context do
28
- before { DummiesIndex.create '2013' }
31
+ before do
32
+ DummiesIndex.create '2013'
33
+ DummiesSuffixedIndex.create 'should_not_appear'
34
+ end
35
+
29
36
  specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(true) }
30
37
  specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(true) }
31
- specify { expect(DummiesIndex.aliases).to eq([]) }
38
+ specify { expect(DummiesIndex.aliases).to eq(['dummies']) }
32
39
  specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
33
40
  specify { expect(DummiesIndex.create('2013')).to eq(false) }
34
41
  specify { expect(DummiesIndex.create('2014')['acknowledged']).to eq(true) }
35
42
 
36
43
  context do
37
44
  before { DummiesIndex.create '2014' }
45
+
38
46
  specify { expect(DummiesIndex.indexes).to match_array(%w[dummies_2013 dummies_2014]) }
39
47
  end
40
48
  end
41
49
 
42
50
  context do
43
- before { DummiesIndex.create '2013', alias: false }
51
+ before do
52
+ DummiesIndex.create '2013', alias: false
53
+ DummiesSuffixedIndex.create 'should_not_appear'
54
+ end
55
+
44
56
  specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
45
57
  specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(true) }
46
58
  specify { expect(DummiesIndex.aliases).to eq([]) }
47
59
  specify { expect(DummiesIndex.indexes).to eq([]) }
60
+ specify { expect(DummiesIndex.exists?).to eq(false) }
61
+ # Unfortunately, without alias we can't figure out that this dummies_2013 index is related to DummiesIndex
62
+ # it would be awesome to have the following specs passing
63
+ # specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
64
+ # specify { expect(DummiesIndex.exists?).to eq(true) }
48
65
  end
49
66
  end
50
67
 
@@ -53,7 +70,11 @@ describe Chewy::Index::Actions do
53
70
  specify { expect(DummiesIndex.create!('2013')['acknowledged']).to eq(true) }
54
71
 
55
72
  context do
56
- before { DummiesIndex.create }
73
+ before do
74
+ DummiesIndex.create
75
+ DummiesSuffixedIndex.create 'should_not_appear'
76
+ end
77
+
57
78
  specify do
58
79
  expect { DummiesIndex.create! }.to raise_error(Elasticsearch::Transport::Transport::Errors::BadRequest).with_message(/already exists.*dummies/)
59
80
  end
@@ -61,10 +82,14 @@ describe Chewy::Index::Actions do
61
82
  end
62
83
 
63
84
  context do
64
- before { DummiesIndex.create! '2013' }
85
+ before do
86
+ DummiesIndex.create! '2013'
87
+ DummiesSuffixedIndex.create! 'should_not_appear'
88
+ end
89
+
65
90
  specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(true) }
66
91
  specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(true) }
67
- specify { expect(DummiesIndex.aliases).to eq([]) }
92
+ specify { expect(DummiesIndex.aliases).to eq(['dummies']) }
68
93
  specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
69
94
  specify do
70
95
  expect { DummiesIndex.create!('2013') }.to raise_error(Elasticsearch::Transport::Transport::Errors::BadRequest).with_message(/already exists.*dummies_2013/)
@@ -73,16 +98,26 @@ describe Chewy::Index::Actions do
73
98
 
74
99
  context do
75
100
  before { DummiesIndex.create! '2014' }
101
+
76
102
  specify { expect(DummiesIndex.indexes).to match_array(%w[dummies_2013 dummies_2014]) }
77
103
  end
78
104
  end
79
105
 
80
106
  context do
81
- before { DummiesIndex.create! '2013', alias: false }
107
+ before do
108
+ DummiesIndex.create! '2013', alias: false
109
+ DummiesSuffixedIndex.create! 'should_not_appear'
110
+ end
111
+
82
112
  specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
83
113
  specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(true) }
84
114
  specify { expect(DummiesIndex.aliases).to eq([]) }
85
115
  specify { expect(DummiesIndex.indexes).to eq([]) }
116
+ specify { expect(DummiesIndex.exists?).to eq(false) }
117
+ # Unfortunately, without alias we can't figure out that this dummies_2013 index is related to DummiesIndex
118
+ # it would be awesome to have the following specs passing
119
+ # specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
120
+ # specify { expect(DummiesIndex.exists?).to eq(true) }
86
121
  end
87
122
  end
88
123
 
@@ -91,27 +126,40 @@ describe Chewy::Index::Actions do
91
126
  specify { expect(DummiesIndex.delete('dummies_2013')).to eq(false) }
92
127
 
93
128
  context do
94
- before { DummiesIndex.create }
129
+ before do
130
+ DummiesIndex.create
131
+ DummiesSuffixedIndex.create 'should_not_appear'
132
+ end
133
+
95
134
  specify { expect(DummiesIndex.delete['acknowledged']).to eq(true) }
96
135
 
97
136
  context do
98
137
  before { DummiesIndex.delete }
99
138
  specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
139
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_suffixed')).to eq(true) }
100
140
  end
101
141
  end
102
142
 
103
143
  context do
104
- before { DummiesIndex.create '2013' }
144
+ before do
145
+ DummiesIndex.create '2013'
146
+ DummiesSuffixedIndex.create 'should_not_appear'
147
+ end
148
+
105
149
  specify { expect(DummiesIndex.delete('2013')['acknowledged']).to eq(true) }
106
150
 
107
151
  context do
108
152
  before { DummiesIndex.delete('2013') }
109
153
  specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
110
154
  specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(false) }
155
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_suffixed')).to eq(true) }
111
156
  end
112
157
 
113
158
  context do
114
- before { DummiesIndex.create '2014' }
159
+ before do
160
+ DummiesIndex.create '2014'
161
+ end
162
+
115
163
  specify { expect(DummiesIndex.delete['acknowledged']).to eq(true) }
116
164
 
117
165
  context do
@@ -119,6 +167,7 @@ describe Chewy::Index::Actions do
119
167
  specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
120
168
  specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(false) }
121
169
  specify { expect(Chewy.client.indices.exists(index: 'dummies_2014')).to eq(false) }
170
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_suffixed')).to eq(true) }
122
171
  end
123
172
 
124
173
  context do
@@ -126,6 +175,7 @@ describe Chewy::Index::Actions do
126
175
  specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(true) }
127
176
  specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(true) }
128
177
  specify { expect(Chewy.client.indices.exists(index: 'dummies_2014')).to eq(false) }
178
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_suffixed')).to eq(true) }
129
179
  end
130
180
  end
131
181
  end
@@ -136,27 +186,38 @@ describe Chewy::Index::Actions do
136
186
  specify { expect { DummiesIndex.delete!('2013') }.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound) }
137
187
 
138
188
  context do
139
- before { DummiesIndex.create }
189
+ before do
190
+ DummiesIndex.create
191
+ DummiesSuffixedIndex.create 'should_not_appear'
192
+ end
193
+
140
194
  specify { expect(DummiesIndex.delete!['acknowledged']).to eq(true) }
141
195
 
142
196
  context do
143
197
  before { DummiesIndex.delete! }
144
198
  specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
199
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_suffixed')).to eq(true) }
145
200
  end
146
201
  end
147
202
 
148
203
  context do
149
- before { DummiesIndex.create '2013' }
204
+ before do
205
+ DummiesIndex.create '2013'
206
+ DummiesSuffixedIndex.create 'should_not_appear'
207
+ end
208
+
150
209
  specify { expect(DummiesIndex.delete!('2013')['acknowledged']).to eq(true) }
151
210
 
152
211
  context do
153
212
  before { DummiesIndex.delete!('2013') }
154
213
  specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
155
214
  specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(false) }
215
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_suffixed')).to eq(true) }
156
216
  end
157
217
 
158
218
  context do
159
219
  before { DummiesIndex.create '2014' }
220
+
160
221
  specify { expect(DummiesIndex.delete!['acknowledged']).to eq(true) }
161
222
 
162
223
  context do
@@ -164,6 +225,7 @@ describe Chewy::Index::Actions do
164
225
  specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(false) }
165
226
  specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(false) }
166
227
  specify { expect(Chewy.client.indices.exists(index: 'dummies_2014')).to eq(false) }
228
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_suffixed')).to eq(true) }
167
229
  end
168
230
 
169
231
  context do
@@ -171,6 +233,7 @@ describe Chewy::Index::Actions do
171
233
  specify { expect(Chewy.client.indices.exists(index: 'dummies')).to eq(true) }
172
234
  specify { expect(Chewy.client.indices.exists(index: 'dummies_2013')).to eq(true) }
173
235
  specify { expect(Chewy.client.indices.exists(index: 'dummies_2014')).to eq(false) }
236
+ specify { expect(Chewy.client.indices.exists(index: 'dummies_suffixed')).to eq(true) }
174
237
  end
175
238
  end
176
239
  end
@@ -184,19 +247,19 @@ describe Chewy::Index::Actions do
184
247
  before { DummiesIndex.purge }
185
248
  specify { expect(DummiesIndex).to be_exists }
186
249
  specify { expect(DummiesIndex.aliases).to eq([]) }
187
- specify { expect(DummiesIndex.indexes).to eq([]) }
250
+ specify { expect(DummiesIndex.indexes).to eq(['dummies']) }
188
251
 
189
252
  context do
190
253
  before { DummiesIndex.purge }
191
254
  specify { expect(DummiesIndex).to be_exists }
192
255
  specify { expect(DummiesIndex.aliases).to eq([]) }
193
- specify { expect(DummiesIndex.indexes).to eq([]) }
256
+ specify { expect(DummiesIndex.indexes).to eq(['dummies']) }
194
257
  end
195
258
 
196
259
  context do
197
260
  before { DummiesIndex.purge('2013') }
198
261
  specify { expect(DummiesIndex).to be_exists }
199
- specify { expect(DummiesIndex.aliases).to eq([]) }
262
+ specify { expect(DummiesIndex.aliases).to eq(['dummies']) }
200
263
  specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
201
264
  end
202
265
  end
@@ -204,20 +267,20 @@ describe Chewy::Index::Actions do
204
267
  context do
205
268
  before { DummiesIndex.purge('2013') }
206
269
  specify { expect(DummiesIndex).to be_exists }
207
- specify { expect(DummiesIndex.aliases).to eq([]) }
270
+ specify { expect(DummiesIndex.aliases).to eq(['dummies']) }
208
271
  specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
209
272
 
210
273
  context do
211
274
  before { DummiesIndex.purge }
212
275
  specify { expect(DummiesIndex).to be_exists }
213
276
  specify { expect(DummiesIndex.aliases).to eq([]) }
214
- specify { expect(DummiesIndex.indexes).to eq([]) }
277
+ specify { expect(DummiesIndex.indexes).to eq(['dummies']) }
215
278
  end
216
279
 
217
280
  context do
218
281
  before { DummiesIndex.purge('2014') }
219
282
  specify { expect(DummiesIndex).to be_exists }
220
- specify { expect(DummiesIndex.aliases).to eq([]) }
283
+ specify { expect(DummiesIndex.aliases).to eq(['dummies']) }
221
284
  specify { expect(DummiesIndex.indexes).to eq(['dummies_2014']) }
222
285
  end
223
286
  end
@@ -231,19 +294,19 @@ describe Chewy::Index::Actions do
231
294
  before { DummiesIndex.purge! }
232
295
  specify { expect(DummiesIndex).to be_exists }
233
296
  specify { expect(DummiesIndex.aliases).to eq([]) }
234
- specify { expect(DummiesIndex.indexes).to eq([]) }
297
+ specify { expect(DummiesIndex.indexes).to eq(['dummies']) }
235
298
 
236
299
  context do
237
300
  before { DummiesIndex.purge! }
238
301
  specify { expect(DummiesIndex).to be_exists }
239
302
  specify { expect(DummiesIndex.aliases).to eq([]) }
240
- specify { expect(DummiesIndex.indexes).to eq([]) }
303
+ specify { expect(DummiesIndex.indexes).to eq(['dummies']) }
241
304
  end
242
305
 
243
306
  context do
244
307
  before { DummiesIndex.purge!('2013') }
245
308
  specify { expect(DummiesIndex).to be_exists }
246
- specify { expect(DummiesIndex.aliases).to eq([]) }
309
+ specify { expect(DummiesIndex.aliases).to eq(['dummies']) }
247
310
  specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
248
311
  end
249
312
  end
@@ -251,20 +314,20 @@ describe Chewy::Index::Actions do
251
314
  context do
252
315
  before { DummiesIndex.purge!('2013') }
253
316
  specify { expect(DummiesIndex).to be_exists }
254
- specify { expect(DummiesIndex.aliases).to eq([]) }
317
+ specify { expect(DummiesIndex.aliases).to eq(['dummies']) }
255
318
  specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
256
319
 
257
320
  context do
258
321
  before { DummiesIndex.purge! }
259
322
  specify { expect(DummiesIndex).to be_exists }
260
323
  specify { expect(DummiesIndex.aliases).to eq([]) }
261
- specify { expect(DummiesIndex.indexes).to eq([]) }
324
+ specify { expect(DummiesIndex.indexes).to eq(['dummies']) }
262
325
  end
263
326
 
264
327
  context do
265
328
  before { DummiesIndex.purge!('2014') }
266
329
  specify { expect(DummiesIndex).to be_exists }
267
- specify { expect(DummiesIndex.aliases).to eq([]) }
330
+ specify { expect(DummiesIndex.aliases).to eq(['dummies']) }
268
331
  specify { expect(DummiesIndex.indexes).to eq(['dummies_2014']) }
269
332
  end
270
333
  end
@@ -361,13 +424,13 @@ describe Chewy::Index::Actions do
361
424
 
362
425
  specify { expect(CitiesIndex.all).to have(1).item }
363
426
  specify { expect(CitiesIndex.aliases).to eq([]) }
364
- specify { expect(CitiesIndex.indexes).to eq([]) }
427
+ specify { expect(CitiesIndex.indexes).to eq(['cities']) }
365
428
 
366
429
  context do
367
430
  before { CitiesIndex.reset!('2013') }
368
431
 
369
432
  specify { expect(CitiesIndex.all).to have(1).item }
370
- specify { expect(CitiesIndex.aliases).to eq([]) }
433
+ specify { expect(CitiesIndex.aliases).to eq(['cities']) }
371
434
  specify { expect(CitiesIndex.indexes).to eq(['cities_2013']) }
372
435
  end
373
436
 
@@ -376,7 +439,7 @@ describe Chewy::Index::Actions do
376
439
 
377
440
  specify { expect(CitiesIndex.all).to have(1).item }
378
441
  specify { expect(CitiesIndex.aliases).to eq([]) }
379
- specify { expect(CitiesIndex.indexes).to eq([]) }
442
+ specify { expect(CitiesIndex.indexes).to eq(['cities']) }
380
443
  end
381
444
  end
382
445
 
@@ -384,14 +447,14 @@ describe Chewy::Index::Actions do
384
447
  before { CitiesIndex.reset!('2013') }
385
448
 
386
449
  specify { expect(CitiesIndex.all).to have(1).item }
387
- specify { expect(CitiesIndex.aliases).to eq([]) }
450
+ specify { expect(CitiesIndex.aliases).to eq(['cities']) }
388
451
  specify { expect(CitiesIndex.indexes).to eq(['cities_2013']) }
389
452
 
390
453
  context do
391
454
  before { CitiesIndex.reset!('2014') }
392
455
 
393
456
  specify { expect(CitiesIndex.all).to have(1).item }
394
- specify { expect(CitiesIndex.aliases).to eq([]) }
457
+ specify { expect(CitiesIndex.aliases).to eq(['cities']) }
395
458
  specify { expect(CitiesIndex.indexes).to eq(['cities_2014']) }
396
459
  specify { expect(Chewy.client.indices.exists(index: 'cities_2013')).to eq(false) }
397
460
  end
@@ -401,7 +464,7 @@ describe Chewy::Index::Actions do
401
464
 
402
465
  specify { expect(CitiesIndex.all).to have(1).item }
403
466
  specify { expect(CitiesIndex.aliases).to eq([]) }
404
- specify { expect(CitiesIndex.indexes).to eq([]) }
467
+ specify { expect(CitiesIndex.indexes).to eq(['cities']) }
405
468
  specify { expect(Chewy.client.indices.exists(index: 'cities_2013')).to eq(false) }
406
469
  end
407
470
  end