chewy 7.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 +0 -26
- data/CHANGELOG.md +11 -0
- data/README.md +27 -38
- data/lib/chewy/fields/root.rb +1 -2
- data/lib/chewy/index.rb +4 -15
- data/lib/chewy/index/actions.rb +1 -3
- data/lib/chewy/index/aliases.rb +1 -3
- data/lib/chewy/railtie.rb +2 -18
- data/lib/chewy/search/loader.rb +2 -12
- data/lib/chewy/search/parameters/indices.rb +12 -57
- data/lib/chewy/search/request.rb +20 -40
- data/lib/chewy/search/response.rb +1 -1
- data/lib/chewy/search/scrolling.rb +1 -1
- data/lib/chewy/stash.rb +2 -5
- data/lib/chewy/type/import/bulk_request.rb +1 -2
- data/lib/chewy/type/import/journal_builder.rb +1 -2
- data/lib/chewy/type/import/routine.rb +2 -2
- data/lib/chewy/type/mapping.rb +1 -1
- data/lib/chewy/type/syncer.rb +1 -4
- data/lib/chewy/version.rb +1 -1
- data/lib/tasks/chewy.rake +10 -10
- data/migration_guide.md +6 -3
- data/spec/chewy/fields/base_spec.rb +4 -4
- data/spec/chewy/fields/root_spec.rb +4 -4
- data/spec/chewy/index/specification_spec.rb +13 -13
- data/spec/chewy/index_spec.rb +1 -3
- data/spec/chewy/journal_spec.rb +4 -4
- data/spec/chewy/runtime_spec.rb +1 -1
- data/spec/chewy/search/loader_spec.rb +0 -16
- data/spec/chewy/search/parameters/indices_spec.rb +25 -110
- data/spec/chewy/search/request_spec.rb +11 -28
- data/spec/chewy/search/scrolling_spec.rb +2 -8
- data/spec/chewy/search_spec.rb +2 -2
- data/spec/chewy/type/import/bulk_request_spec.rb +0 -6
- data/spec/chewy/type/import/journal_builder_spec.rb +0 -4
- data/spec/chewy/type/import_spec.rb +2 -2
- data/spec/chewy/type/mapping_spec.rb +5 -37
- metadata +2 -5
- data/lib/chewy/search/parameters/types.rb +0 -20
- data/spec/chewy/search/parameters/types_spec.rb +0 -5
data/spec/chewy/index_spec.rb
CHANGED
@@ -143,8 +143,6 @@ describe Chewy::Index do
|
|
143
143
|
|
144
144
|
describe '.types' do
|
145
145
|
specify { expect(DummiesIndex.types).to eq(DummiesIndex.type_hash.values) }
|
146
|
-
specify { expect(DummiesIndex.types(:dummy)).to be_a Chewy::Search::Request }
|
147
|
-
specify { expect(DummiesIndex.types(:user)).to be_a Chewy::Search::Request }
|
148
146
|
end
|
149
147
|
|
150
148
|
describe '.settings' do
|
@@ -233,7 +231,7 @@ describe Chewy::Index do
|
|
233
231
|
define_type :document do
|
234
232
|
field :date, type: 'date'
|
235
233
|
end
|
236
|
-
end.mappings_hash).to eq(mappings: {
|
234
|
+
end.mappings_hash).to eq(mappings: {properties: {date: {type: 'date'}}})
|
237
235
|
end
|
238
236
|
end
|
239
237
|
|
data/spec/chewy/journal_spec.rb
CHANGED
@@ -137,7 +137,7 @@ describe Chewy::Journal do
|
|
137
137
|
expect(journal_entries.size).to eq 4
|
138
138
|
|
139
139
|
# simulate lost data
|
140
|
-
Chewy.client.delete(index: "#{Chewy.settings[:prefix]}_cities",
|
140
|
+
Chewy.client.delete(index: "#{Chewy.settings[:prefix]}_cities", id: 1, refresh: true)
|
141
141
|
expect(cities_index.count).to eq 1
|
142
142
|
|
143
143
|
described_class.new.apply(time)
|
@@ -192,8 +192,8 @@ describe Chewy::Journal do
|
|
192
192
|
Array.new(2) { |i| Country.create!(id: i + 1) }
|
193
193
|
|
194
194
|
# simulate lost data
|
195
|
-
Chewy.client.delete(index: 'cities',
|
196
|
-
Chewy.client.delete(index: 'countries',
|
195
|
+
Chewy.client.delete(index: 'cities', id: 1, refresh: true)
|
196
|
+
Chewy.client.delete(index: 'countries', id: 1, refresh: true)
|
197
197
|
expect(CitiesIndex.all.to_a.length).to eq 1
|
198
198
|
expect(CountriesIndex.all.to_a.length).to eq 1
|
199
199
|
|
@@ -203,7 +203,7 @@ describe Chewy::Journal do
|
|
203
203
|
expect(CountriesIndex.all.to_a.length).to eq 1
|
204
204
|
|
205
205
|
# Replay on both
|
206
|
-
Chewy.client.delete(index: 'cities',
|
206
|
+
Chewy.client.delete(index: 'cities', id: 1, refresh: true)
|
207
207
|
expect(CitiesIndex.all.to_a.length).to eq 1
|
208
208
|
expect(described_class.new(CitiesIndex, CountriesIndex).apply(time)).to eq(4)
|
209
209
|
expect(CitiesIndex.all.to_a.length).to eq 2
|
data/spec/chewy/runtime_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Chewy::Runtime do
|
4
4
|
describe '.version' do
|
5
5
|
specify { expect(described_class.version).to be_a(described_class::Version) }
|
6
|
-
specify { expect(described_class.version).to be >= '
|
6
|
+
specify { expect(described_class.version).to be >= '7.0' }
|
7
7
|
specify { expect(described_class.version).to be < '8.0' }
|
8
8
|
end
|
9
9
|
end
|
@@ -37,7 +37,6 @@ describe Chewy::Search::Loader do
|
|
37
37
|
specify { expect(subject.derive_type('cities', 'city')).to eq(CitiesIndex::City) }
|
38
38
|
specify { expect(subject.derive_type('cities_suffix', 'city')).to eq(CitiesIndex::City) }
|
39
39
|
|
40
|
-
specify { expect { subject.derive_type('cities', 'place') }.to raise_error(Chewy::UnderivableType) }
|
41
40
|
specify { expect { subject.derive_type('whatever', 'city') }.to raise_error(Chewy::UnderivableType) }
|
42
41
|
specify { expect { subject.derive_type('citiessuffix', 'city') }.to raise_error(Chewy::UnderivableType) }
|
43
42
|
|
@@ -54,21 +53,6 @@ describe Chewy::Search::Loader do
|
|
54
53
|
|
55
54
|
specify { expect(subject.load(hits)).to eq([*cities, *countries]) }
|
56
55
|
|
57
|
-
context do
|
58
|
-
let(:options) { {only: 'city'} }
|
59
|
-
specify { expect(subject.load(hits)).to eq([*cities, nil, nil]) }
|
60
|
-
end
|
61
|
-
|
62
|
-
context do
|
63
|
-
let(:options) { {except: 'city'} }
|
64
|
-
specify { expect(subject.load(hits)).to eq([nil, nil, *countries]) }
|
65
|
-
end
|
66
|
-
|
67
|
-
context do
|
68
|
-
let(:options) { {except: %w[city country]} }
|
69
|
-
specify { expect(subject.load(hits)).to eq([nil, nil, nil, nil]) }
|
70
|
-
end
|
71
|
-
|
72
56
|
context 'scopes', :active_record do
|
73
57
|
context do
|
74
58
|
let(:options) { {scope: -> { where('rating > 2') }} }
|
@@ -9,30 +9,32 @@ describe Chewy::Search::Parameters::Indices do
|
|
9
9
|
stub_index(:second) do
|
10
10
|
define_type :three
|
11
11
|
end
|
12
|
+
|
13
|
+
stub_index(:third)
|
12
14
|
end
|
13
15
|
|
14
|
-
subject { described_class.new(indices: FirstIndex,
|
16
|
+
subject { described_class.new(indices: [FirstIndex, SecondIndex]) }
|
15
17
|
|
16
18
|
describe '#initialize' do
|
17
|
-
specify { expect(described_class.new.value).to eq(indices: []
|
18
|
-
specify { expect(described_class.new(nil).value).to eq(indices: []
|
19
|
-
specify { expect(described_class.new(foo: :whatever).value).to eq(indices: []
|
20
|
-
specify { expect(subject.value).to eq(indices: [FirstIndex
|
19
|
+
specify { expect(described_class.new.value).to eq(indices: []) }
|
20
|
+
specify { expect(described_class.new(nil).value).to eq(indices: []) }
|
21
|
+
specify { expect(described_class.new(foo: :whatever).value).to eq(indices: []) }
|
22
|
+
specify { expect(subject.value).to eq(indices: [FirstIndex, SecondIndex]) }
|
21
23
|
end
|
22
24
|
|
23
25
|
describe '#replace!' do
|
24
26
|
specify do
|
25
27
|
expect { subject.replace!(nil) }
|
26
28
|
.to change { subject.value }
|
27
|
-
.from(indices: [FirstIndex
|
28
|
-
.to(indices: []
|
29
|
+
.from(indices: [FirstIndex, SecondIndex])
|
30
|
+
.to(indices: [])
|
29
31
|
end
|
30
32
|
|
31
33
|
specify do
|
32
|
-
expect { subject.replace!(indices: SecondIndex
|
34
|
+
expect { subject.replace!(indices: SecondIndex) }
|
33
35
|
.to change { subject.value }
|
34
|
-
.from(indices: [FirstIndex
|
35
|
-
.to(indices: [SecondIndex]
|
36
|
+
.from(indices: [FirstIndex, SecondIndex])
|
37
|
+
.to(indices: [SecondIndex])
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
@@ -43,10 +45,10 @@ describe Chewy::Search::Parameters::Indices do
|
|
43
45
|
end
|
44
46
|
|
45
47
|
specify do
|
46
|
-
expect { subject.update!(indices:
|
48
|
+
expect { subject.update!(indices: ThirdIndex) }
|
47
49
|
.to change { subject.value }
|
48
|
-
.from(indices: [FirstIndex
|
49
|
-
.to(indices: [FirstIndex, SecondIndex
|
50
|
+
.from(indices: [FirstIndex, SecondIndex])
|
51
|
+
.to(indices: [FirstIndex, SecondIndex, ThirdIndex])
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
@@ -57,10 +59,8 @@ describe Chewy::Search::Parameters::Indices do
|
|
57
59
|
end
|
58
60
|
|
59
61
|
specify do
|
60
|
-
expect { subject.merge!(described_class.new(indices: SecondIndex
|
61
|
-
.
|
62
|
-
.from(indices: [FirstIndex], types: [SecondIndex::Three])
|
63
|
-
.to(indices: [FirstIndex, SecondIndex], types: [SecondIndex::Three, FirstIndex::One])
|
62
|
+
expect { subject.merge!(described_class.new(indices: SecondIndex)) }
|
63
|
+
.not_to change { subject.value }
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -69,7 +69,7 @@ describe Chewy::Search::Parameters::Indices do
|
|
69
69
|
specify do
|
70
70
|
expect(described_class.new(
|
71
71
|
indices: FirstIndex
|
72
|
-
).render).to eq(index: %w[first]
|
72
|
+
).render).to eq(index: %w[first])
|
73
73
|
end
|
74
74
|
specify do
|
75
75
|
expect(described_class.new(
|
@@ -78,113 +78,28 @@ describe Chewy::Search::Parameters::Indices do
|
|
78
78
|
end
|
79
79
|
specify do
|
80
80
|
expect(described_class.new(
|
81
|
-
|
82
|
-
).render).to eq(index: %w[first
|
83
|
-
end
|
84
|
-
specify do
|
85
|
-
expect(described_class.new(
|
86
|
-
types: :whatever
|
87
|
-
).render).to eq({})
|
88
|
-
end
|
89
|
-
specify do
|
90
|
-
expect(described_class.new(
|
91
|
-
indices: FirstIndex, types: SecondIndex::Three
|
92
|
-
).render).to eq(index: %w[first second], type: %w[one three])
|
93
|
-
end
|
94
|
-
specify do
|
95
|
-
expect(described_class.new(
|
96
|
-
indices: FirstIndex, types: :one
|
97
|
-
).render).to eq(index: %w[first], type: %w[one])
|
98
|
-
end
|
99
|
-
specify do
|
100
|
-
expect(described_class.new(
|
101
|
-
indices: FirstIndex, types: :whatever
|
102
|
-
).render).to eq(index: %w[first], type: %w[one])
|
103
|
-
end
|
104
|
-
specify do
|
105
|
-
expect(described_class.new(
|
106
|
-
indices: FirstIndex, types: %i[one whatever]
|
107
|
-
).render).to eq(index: %w[first], type: %w[one])
|
108
|
-
end
|
109
|
-
specify do
|
110
|
-
expect(described_class.new(
|
111
|
-
indices: :whatever, types: SecondIndex::Three
|
112
|
-
).render).to eq(index: %w[second whatever], type: %w[three])
|
113
|
-
end
|
114
|
-
specify do
|
115
|
-
expect(described_class.new(
|
116
|
-
indices: :whatever, types: [SecondIndex::Three, :whatever]
|
117
|
-
).render).to eq(index: %w[second whatever], type: %w[three whatever])
|
118
|
-
end
|
119
|
-
specify do
|
120
|
-
expect(described_class.new(
|
121
|
-
indices: [FirstIndex, :whatever], types: FirstIndex::One
|
122
|
-
).render).to eq(index: %w[first whatever], type: %w[one])
|
123
|
-
end
|
124
|
-
specify do
|
125
|
-
expect(described_class.new(
|
126
|
-
indices: FirstIndex, types: [FirstIndex::One, :whatever]
|
127
|
-
).render).to eq(index: %w[first], type: %w[one])
|
128
|
-
end
|
129
|
-
specify do
|
130
|
-
expect(described_class.new(
|
131
|
-
indices: FirstIndex, types: [SecondIndex::Three, :whatever]
|
132
|
-
).render).to eq(index: %w[first second], type: %w[one three])
|
133
|
-
end
|
134
|
-
specify do
|
135
|
-
expect(described_class.new(
|
136
|
-
indices: [FirstIndex, :whatever], types: [FirstIndex::One, :whatever]
|
137
|
-
).render).to eq(index: %w[first whatever], type: %w[one whatever])
|
138
|
-
end
|
139
|
-
specify do
|
140
|
-
expect(described_class.new(
|
141
|
-
indices: [FirstIndex, :whatever], types: [SecondIndex::Three, FirstIndex::One]
|
142
|
-
).render).to eq(index: %w[first second whatever], type: %w[one three])
|
81
|
+
indices: [FirstIndex, :whatever]
|
82
|
+
).render).to eq(index: %w[first whatever])
|
143
83
|
end
|
144
84
|
end
|
145
85
|
|
146
86
|
describe '#==' do
|
147
87
|
specify { expect(described_class.new).to eq(described_class.new) }
|
148
88
|
specify do
|
149
|
-
expect(described_class.new(indices:
|
150
|
-
.to eq(described_class.new(indices: SecondIndex, types: :whatever))
|
151
|
-
end
|
152
|
-
specify do
|
153
|
-
expect(described_class.new(indices: :first, types: %w[one]))
|
89
|
+
expect(described_class.new(indices: :first))
|
154
90
|
.to eq(described_class.new(indices: FirstIndex))
|
155
91
|
end
|
156
92
|
specify do
|
157
|
-
expect(described_class.new(indices: FirstIndex
|
158
|
-
.
|
93
|
+
expect(described_class.new(indices: FirstIndex))
|
94
|
+
.to eq(described_class.new(indices: FirstIndex))
|
159
95
|
end
|
160
96
|
end
|
161
97
|
|
162
98
|
describe '#indices' do
|
163
99
|
specify do
|
164
100
|
expect(described_class.new(
|
165
|
-
indices: [FirstIndex, :whatever]
|
166
|
-
|
167
|
-
).indices).to contain_exactly(FirstIndex, SecondIndex)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
describe '#types' do
|
172
|
-
specify do
|
173
|
-
expect(described_class.new(
|
174
|
-
indices: [FirstIndex, :whatever],
|
175
|
-
types: [SecondIndex::Three, :whatever]
|
176
|
-
).types).to contain_exactly(
|
177
|
-
FirstIndex::One, SecondIndex::Three
|
178
|
-
)
|
179
|
-
end
|
180
|
-
|
181
|
-
specify do
|
182
|
-
expect(described_class.new(
|
183
|
-
indices: [FirstIndex, :whatever],
|
184
|
-
types: [FirstIndex::One, SecondIndex::Three, :whatever]
|
185
|
-
).types).to contain_exactly(
|
186
|
-
FirstIndex::One, SecondIndex::Three
|
187
|
-
)
|
101
|
+
indices: [FirstIndex, :whatever]
|
102
|
+
).indices).to contain_exactly(FirstIndex)
|
188
103
|
end
|
189
104
|
end
|
190
105
|
end
|
@@ -46,7 +46,6 @@ describe Chewy::Search::Request do
|
|
46
46
|
expect(subject.render)
|
47
47
|
.to match(
|
48
48
|
index: %w[products],
|
49
|
-
type: array_including(%w[product]),
|
50
49
|
body: {}
|
51
50
|
)
|
52
51
|
end
|
@@ -55,11 +54,11 @@ describe Chewy::Search::Request do
|
|
55
54
|
describe '#inspect' do
|
56
55
|
specify do
|
57
56
|
expect(described_class.new(ProductsIndex).inspect)
|
58
|
-
.to eq('<Chewy::Search::Request {:index=>["products"], :
|
57
|
+
.to eq('<Chewy::Search::Request {:index=>["products"], :body=>{}}>')
|
59
58
|
end
|
60
59
|
specify do
|
61
60
|
expect(ProductsIndex.limit(10).inspect)
|
62
|
-
.to eq('<ProductsIndex::Query {:index=>["products"], :
|
61
|
+
.to eq('<ProductsIndex::Query {:index=>["products"], :body=>{:size=>10}}>')
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
@@ -231,14 +230,6 @@ describe Chewy::Search::Request do
|
|
231
230
|
specify { expect { subject.indices(:cities) }.not_to change { subject.render } }
|
232
231
|
end
|
233
232
|
|
234
|
-
describe '#types' do
|
235
|
-
specify { expect(subject.types(:product).render[:type]).to contain_exactly('product') }
|
236
|
-
specify { expect(subject.types(%i[product city]).types(nil).render[:type]).to match_array(%w[product]) }
|
237
|
-
specify { expect(subject.types(:product).types(:product, :city, :something).render[:type]).to match_array(%w[product]) }
|
238
|
-
specify { expect(subject.types(nil).render[:body]).to be_blank }
|
239
|
-
specify { expect { subject.types(:product) }.not_to change { subject.render } }
|
240
|
-
end
|
241
|
-
|
242
233
|
describe '#indices_boost' do
|
243
234
|
specify { expect(subject.indices_boost(foo: 1.2).render[:body]).to include(indices_boost: [{'foo' => 1.2}]) }
|
244
235
|
specify { expect(subject.indices_boost(foo: 1.2).indices_boost(moo: 1.3).render[:body]).to include(indices_boost: [{'foo' => 1.2}, {'moo' => 1.3}]) }
|
@@ -420,14 +411,10 @@ describe Chewy::Search::Request do
|
|
420
411
|
outer_payload = payload
|
421
412
|
end
|
422
413
|
subject.query(match: {name: 'name3'}).to_a
|
423
|
-
request = {index: ['products'], type: %w[product], body: {query: {match: {name: 'name3'}}}}
|
424
|
-
request[:rest_total_hits_as_int] = true if Chewy::Runtime.version >= '7.0.0'
|
425
414
|
expect(outer_payload).to eq(
|
426
415
|
index: ProductsIndex,
|
427
416
|
indexes: [ProductsIndex],
|
428
|
-
request:
|
429
|
-
type: ProductsIndex::Product,
|
430
|
-
types: [ProductsIndex::Product]
|
417
|
+
request: {index: ['products'], body: {query: {match: {name: 'name3'}}}}
|
431
418
|
)
|
432
419
|
end
|
433
420
|
end
|
@@ -592,12 +579,12 @@ describe Chewy::Search::Request do
|
|
592
579
|
specify { expect(subject.limit(5).pluck(:_id, :age)).to eq([['1', 10], ['2', 20], ['3', 30], ['4', 40], ['5', 50]]) }
|
593
580
|
specify { expect(subject.limit(5).source(:name).pluck(:id, :age)).to eq([[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]]) }
|
594
581
|
specify do
|
595
|
-
expect(subject.limit(5).pluck(:_index, :
|
596
|
-
%w[products
|
597
|
-
%w[products
|
598
|
-
%w[products
|
599
|
-
%w[products
|
600
|
-
%w[products
|
582
|
+
expect(subject.limit(5).pluck(:_index, :name)).to eq([
|
583
|
+
%w[products Name1],
|
584
|
+
%w[products Name2],
|
585
|
+
%w[products Name3],
|
586
|
+
%w[products Name4],
|
587
|
+
%w[products Name5]
|
601
588
|
])
|
602
589
|
end
|
603
590
|
|
@@ -644,9 +631,7 @@ describe Chewy::Search::Request do
|
|
644
631
|
expect(outer_payload).to eq(
|
645
632
|
index: ProductsIndex,
|
646
633
|
indexes: [ProductsIndex],
|
647
|
-
request: {index: ['products'],
|
648
|
-
type: ProductsIndex::Product,
|
649
|
-
types: [ProductsIndex::Product]
|
634
|
+
request: {index: ['products'], body: {query: {match: {name: 'name3'}}}, refresh: true}
|
650
635
|
)
|
651
636
|
end
|
652
637
|
|
@@ -659,9 +644,7 @@ describe Chewy::Search::Request do
|
|
659
644
|
expect(outer_payload).to eq(
|
660
645
|
index: ProductsIndex,
|
661
646
|
indexes: [ProductsIndex],
|
662
|
-
request: {index: ['products'],
|
663
|
-
type: ProductsIndex::Product,
|
664
|
-
types: [ProductsIndex::Product]
|
647
|
+
request: {index: ['products'], body: {query: {match: {name: 'name3'}}}, refresh: false}
|
665
648
|
)
|
666
649
|
end
|
667
650
|
end
|
@@ -119,22 +119,16 @@ describe Chewy::Search::Scrolling, :orm do
|
|
119
119
|
outer_payload << payload
|
120
120
|
end
|
121
121
|
request.scroll_batches(batch_size: 3).to_a
|
122
|
-
request = {index: %w[cities countries], type: %w[city country], body: {sort: ['rating']}, size: 3, scroll: '1m'}
|
123
|
-
request[:rest_total_hits_as_int] = true if Chewy::Runtime.version >= '7.0.0'
|
124
122
|
expect(outer_payload).to match_array([
|
125
123
|
hash_including(
|
126
124
|
index: [CitiesIndex, CountriesIndex],
|
127
125
|
indexes: [CitiesIndex, CountriesIndex],
|
128
|
-
request:
|
129
|
-
type: [CitiesIndex::City, CountriesIndex::Country],
|
130
|
-
types: [CitiesIndex::City, CountriesIndex::Country]
|
126
|
+
request: {index: %w[cities countries], body: {sort: ['rating']}, size: 3, scroll: '1m'}
|
131
127
|
),
|
132
128
|
hash_including(
|
133
129
|
index: [CitiesIndex, CountriesIndex],
|
134
130
|
indexes: [CitiesIndex, CountriesIndex],
|
135
|
-
request: {scroll: '1m', scroll_id: an_instance_of(String)}
|
136
|
-
type: [CitiesIndex::City, CountriesIndex::Country],
|
137
|
-
types: [CitiesIndex::City, CountriesIndex::Country]
|
131
|
+
request: {scroll: '1m', scroll_id: an_instance_of(String)}
|
138
132
|
)
|
139
133
|
])
|
140
134
|
end
|
data/spec/chewy/search_spec.rb
CHANGED
@@ -37,12 +37,12 @@ describe Chewy::Search do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
specify do
|
40
|
-
expect(ProductsIndex.client).to receive(:search).with(hash_including(index: ['products']
|
40
|
+
expect(ProductsIndex.client).to receive(:search).with(hash_including(index: ['products']))
|
41
41
|
ProductsIndex.search_string('hello')
|
42
42
|
end
|
43
43
|
|
44
44
|
specify do
|
45
|
-
expect(ProductsIndex.client).to receive(:search).with(hash_including(index: ['products']
|
45
|
+
expect(ProductsIndex.client).to receive(:search).with(hash_including(index: ['products']))
|
46
46
|
product.search_string('hello')
|
47
47
|
end
|
48
48
|
end
|
@@ -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([
|