chewy 5.0.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +214 -0
  3. data/Appraisals +1 -17
  4. data/CHANGELOG.md +40 -0
  5. data/Gemfile +2 -0
  6. data/LICENSE.txt +1 -1
  7. data/README.md +61 -35
  8. data/chewy.gemspec +4 -4
  9. data/gemfiles/rails.5.2.activerecord.gemfile +4 -3
  10. data/gemfiles/{rails.5.0.activerecord.gemfile → rails.5.2.mongoid.6.4.gemfile} +4 -3
  11. data/gemfiles/{rails.5.0.mongoid.6.1.gemfile → rails.6.0.activerecord.gemfile} +4 -3
  12. data/gemfiles/{rails.5.1.activerecord.gemfile → rails.6.1.activerecord.gemfile} +6 -3
  13. data/gemfiles/ruby3.gemfile +10 -0
  14. data/lib/chewy/backports/duplicable.rb +1 -1
  15. data/lib/chewy/fields/base.rb +1 -1
  16. data/lib/chewy/fields/root.rb +2 -2
  17. data/lib/chewy/index/actions.rb +9 -3
  18. data/lib/chewy/query/loading.rb +1 -1
  19. data/lib/chewy/query/nodes/field.rb +1 -1
  20. data/lib/chewy/query.rb +5 -0
  21. data/lib/chewy/railtie.rb +1 -1
  22. data/lib/chewy/search/loader.rb +1 -1
  23. data/lib/chewy/search/parameters/allow_partial_search_results.rb +27 -0
  24. data/lib/chewy/search/parameters/indices.rb +123 -0
  25. data/lib/chewy/search/parameters.rb +24 -6
  26. data/lib/chewy/search/request.rb +76 -51
  27. data/lib/chewy/search/scrolling.rb +3 -5
  28. data/lib/chewy/search.rb +1 -5
  29. data/lib/chewy/strategy/active_job.rb +1 -1
  30. data/lib/chewy/strategy/sidekiq.rb +1 -1
  31. data/lib/chewy/type/adapter/active_record.rb +1 -1
  32. data/lib/chewy/type/adapter/mongoid.rb +1 -1
  33. data/lib/chewy/type/adapter/orm.rb +1 -1
  34. data/lib/chewy/type/adapter/sequel.rb +1 -1
  35. data/lib/chewy/type/import/bulk_request.rb +4 -2
  36. data/lib/chewy/type/import/journal_builder.rb +1 -1
  37. data/lib/chewy/type/import/routine.rb +1 -1
  38. data/lib/chewy/type/import.rb +3 -3
  39. data/lib/chewy/type/mapping.rb +4 -4
  40. data/lib/chewy/type/observe.rb +3 -3
  41. data/lib/chewy/type/witchcraft.rb +1 -1
  42. data/lib/chewy/type/wrapper.rb +1 -1
  43. data/lib/chewy/version.rb +1 -1
  44. data/lib/chewy.rb +1 -1
  45. data/spec/chewy/config_spec.rb +1 -1
  46. data/spec/chewy/fields/base_spec.rb +11 -9
  47. data/spec/chewy/index/actions_spec.rb +2 -2
  48. data/spec/chewy/journal_spec.rb +1 -1
  49. data/spec/chewy/search/parameters/indices_spec.rb +191 -0
  50. data/spec/chewy/search/parameters_spec.rb +20 -3
  51. data/spec/chewy/search/request_spec.rb +25 -9
  52. data/spec/chewy/search/response_spec.rb +8 -2
  53. data/spec/chewy/search_spec.rb +2 -2
  54. data/spec/chewy/strategy/active_job_spec.rb +15 -2
  55. data/spec/chewy/strategy/shoryuken_spec.rb +6 -2
  56. data/spec/chewy/strategy/sidekiq_spec.rb +6 -2
  57. data/spec/chewy/type/adapter/active_record_spec.rb +3 -3
  58. data/spec/chewy/type/import/bulk_builder_spec.rb +1 -1
  59. data/spec/chewy/type/observe_spec.rb +4 -4
  60. data/spec/spec_helper.rb +4 -1
  61. metadata +21 -22
  62. data/.travis.yml +0 -45
  63. data/gemfiles/rails.4.0.activerecord.gemfile +0 -15
  64. data/gemfiles/rails.4.1.activerecord.gemfile +0 -15
  65. data/gemfiles/rails.4.2.activerecord.gemfile +0 -16
  66. data/gemfiles/rails.4.2.mongoid.5.2.gemfile +0 -16
  67. data/gemfiles/rails.5.1.mongoid.6.3.gemfile +0 -16
  68. data/spec/chewy/search/parameters/indices_boost_spec.rb +0 -83
@@ -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.update_attributes!(country: nil) }.to update_index('cities#city').and_reindex(city).only }
79
- specify { expect { city.update_attributes!(country: nil) }.to update_index('countries#country').and_reindex(country1).only }
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.update_attributes!(country: country2) }.to update_index('cities#city').and_reindex(city).only }
82
- specify { expect { city.update_attributes!(country: country2) }.to update_index('countries#country').and_reindex(country1, country2).only }
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
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: 'localhost:9250',
28
+ host: "#{host}:#{port}",
26
29
  wait_for_status: 'green',
27
30
  index: {
28
31
  number_of_shards: 1,
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: 5.0.0
4
+ version: 5.2.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: 2018-02-13 00:00:00.000000000 Z
12
+ date: 2021-01-28 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: '0'
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: '0'
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,14 +199,14 @@ dependencies:
198
199
  requirements:
199
200
  - - ">="
200
201
  - !ruby/object:Gem::Version
201
- version: '4.0'
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: '4.0'
209
+ version: '5.2'
209
210
  - !ruby/object:Gem::Dependency
210
211
  name: elasticsearch
211
212
  requirement: !ruby/object:Gem::Requirement
@@ -237,16 +238,17 @@ 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"
245
248
  - ".gitignore"
246
249
  - ".rspec"
247
250
  - ".rubocop.yml"
248
251
  - ".rubocop_todo.yml"
249
- - ".travis.yml"
250
252
  - ".yardopts"
251
253
  - Appraisals
252
254
  - CHANGELOG.md
@@ -258,15 +260,11 @@ files:
258
260
  - Rakefile
259
261
  - chewy.gemspec
260
262
  - 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
263
  - gemfiles/rails.5.2.activerecord.gemfile
264
+ - gemfiles/rails.5.2.mongoid.6.4.gemfile
265
+ - gemfiles/rails.6.0.activerecord.gemfile
266
+ - gemfiles/rails.6.1.activerecord.gemfile
267
+ - gemfiles/ruby3.gemfile
270
268
  - gemfiles/sequel.4.45.gemfile
271
269
  - lib/chewy.rb
272
270
  - lib/chewy/backports/deep_dup.rb
@@ -324,6 +322,7 @@ files:
324
322
  - lib/chewy/search/pagination/will_paginate.rb
325
323
  - lib/chewy/search/parameters.rb
326
324
  - lib/chewy/search/parameters/aggs.rb
325
+ - lib/chewy/search/parameters/allow_partial_search_results.rb
327
326
  - lib/chewy/search/parameters/concerns/bool_storage.rb
328
327
  - lib/chewy/search/parameters/concerns/hash_storage.rb
329
328
  - lib/chewy/search/parameters/concerns/integer_storage.rb
@@ -334,6 +333,7 @@ files:
334
333
  - lib/chewy/search/parameters/explain.rb
335
334
  - lib/chewy/search/parameters/filter.rb
336
335
  - lib/chewy/search/parameters/highlight.rb
336
+ - lib/chewy/search/parameters/indices.rb
337
337
  - lib/chewy/search/parameters/indices_boost.rb
338
338
  - lib/chewy/search/parameters/limit.rb
339
339
  - lib/chewy/search/parameters/load.rb
@@ -450,7 +450,7 @@ files:
450
450
  - spec/chewy/search/parameters/filter_spec.rb
451
451
  - spec/chewy/search/parameters/hash_storage_examples.rb
452
452
  - spec/chewy/search/parameters/highlight_spec.rb
453
- - spec/chewy/search/parameters/indices_boost_spec.rb
453
+ - spec/chewy/search/parameters/indices_spec.rb
454
454
  - spec/chewy/search/parameters/integer_storage_examples.rb
455
455
  - spec/chewy/search/parameters/limit_spec.rb
456
456
  - spec/chewy/search/parameters/load_spec.rb
@@ -519,7 +519,7 @@ homepage: https://github.com/toptal/chewy
519
519
  licenses:
520
520
  - MIT
521
521
  metadata: {}
522
- post_install_message:
522
+ post_install_message:
523
523
  rdoc_options: []
524
524
  require_paths:
525
525
  - lib
@@ -534,9 +534,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
534
534
  - !ruby/object:Gem::Version
535
535
  version: '0'
536
536
  requirements: []
537
- rubyforge_project:
538
- rubygems_version: 2.7.4
539
- signing_key:
537
+ rubygems_version: 3.1.2
538
+ signing_key:
540
539
  specification_version: 4
541
540
  summary: Elasticsearch ODM client wrapper
542
541
  test_files:
@@ -592,7 +591,7 @@ test_files:
592
591
  - spec/chewy/search/parameters/filter_spec.rb
593
592
  - spec/chewy/search/parameters/hash_storage_examples.rb
594
593
  - spec/chewy/search/parameters/highlight_spec.rb
595
- - spec/chewy/search/parameters/indices_boost_spec.rb
594
+ - spec/chewy/search/parameters/indices_spec.rb
596
595
  - spec/chewy/search/parameters/integer_storage_examples.rb
597
596
  - spec/chewy/search/parameters/limit_spec.rb
598
597
  - spec/chewy/search/parameters/load_spec.rb
data/.travis.yml DELETED
@@ -1,45 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- services:
4
- - mongodb
5
- jdk:
6
- - oraclejdk8
7
- rvm:
8
- - 2.4.3
9
- env:
10
- global:
11
- - TEST_CLUSTER_NODES=1
12
- matrix:
13
- - ES_VERSION=5.6.7
14
- gemfile:
15
- - gemfiles/rails.5.0.activerecord.gemfile
16
- - gemfiles/rails.5.1.activerecord.gemfile
17
- - gemfiles/rails.5.0.mongoid.6.1.gemfile
18
- - gemfiles/rails.5.1.mongoid.6.3.gemfile
19
- - gemfiles/sequel.4.45.gemfile
20
- matrix:
21
- include:
22
- - rvm: 2.2.9
23
- gemfile: gemfiles/rails.4.0.activerecord.gemfile
24
- env: ES_VERSION=2.4.6
25
- - rvm: 2.2.9
26
- gemfile: gemfiles/rails.4.1.activerecord.gemfile
27
- env: ES_VERSION=2.4.6
28
- - rvm: 2.3.6
29
- gemfile: gemfiles/rails.4.2.activerecord.gemfile
30
- env: ES_VERSION=2.4.6
31
- - rvm: 2.3.6
32
- gemfile: gemfiles/rails.4.2.mongoid.5.2.gemfile
33
- env: ES_VERSION=2.4.6
34
- - rvm: 2.5.0
35
- gemfile: gemfiles/rails.5.2.activerecord.gemfile
36
- env: ES_VERSION=5.6.7
37
- before_install:
38
- - curl -s https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.6/elasticsearch-2.4.6.tar.gz | tar xz -C /tmp
39
- - curl -s https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.7.tar.gz | tar xz -C /tmp
40
- before_script:
41
- - /tmp/elasticsearch-2.4.6/bin/plugin install delete-by-query
42
- - TEST_CLUSTER_COMMAND=/tmp/elasticsearch-$ES_VERSION/bin/elasticsearch TEST_CLUSTER_LOGS=/tmp/log rake es:start
43
- script:
44
- - bundle exec rspec
45
- - bundle exec rubocop
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.0.0"
6
- gem "activesupport", "~> 4.0.0"
7
- gem "resque", require: false
8
- gem "shoryuken", require: false
9
- gem "aws-sdk-sqs", require: false
10
- gem "sidekiq", require: false
11
- gem "kaminari", "~> 0.17.0", require: false
12
- gem "will_paginate", require: false
13
- gem "parallel", require: false
14
-
15
- gemspec path: "../"
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.1.0"
6
- gem "activesupport", "~> 4.1.0"
7
- gem "resque", require: false
8
- gem "shoryuken", require: false
9
- gem "aws-sdk-sqs", require: false
10
- gem "sidekiq", require: false
11
- gem "kaminari", "~> 0.17.0", require: false
12
- gem "will_paginate", require: false
13
- gem "parallel", require: false
14
-
15
- gemspec path: "../"
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.2.0"
6
- gem "activesupport", "~> 4.2.0"
7
- gem "activejob", "~> 4.2.0"
8
- gem "resque", require: false
9
- gem "shoryuken", require: false
10
- gem "aws-sdk-sqs", require: false
11
- gem "sidekiq", require: false
12
- gem "kaminari", "~> 0.17.0", require: false
13
- gem "will_paginate", require: false
14
- gem "parallel", require: false
15
-
16
- gemspec path: "../"
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "mongoid", "~> 5.2.0"
6
- gem "activesupport", "~> 4.2.0"
7
- gem "activejob", "~> 4.2.0"
8
- gem "resque", require: false
9
- gem "shoryuken", require: false
10
- gem "aws-sdk-sqs", require: false
11
- gem "sidekiq", require: false
12
- gem "kaminari", "~> 0.17.0", require: false
13
- gem "will_paginate", require: false
14
- gem "parallel", require: false
15
-
16
- gemspec path: "../"
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "mongoid", "~> 6.3.0"
6
- gem "activesupport", "~> 5.1.0"
7
- gem "activejob", "~> 5.1.0"
8
- gem "resque", require: false
9
- gem "shoryuken", require: false
10
- gem "aws-sdk-sqs", require: false
11
- gem "sidekiq", require: false
12
- gem "kaminari-core", "~> 1.1.0", require: false
13
- gem "will_paginate", require: false
14
- gem "parallel", require: false
15
-
16
- gemspec path: "../"
@@ -1,83 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Chewy::Search::Parameters::IndicesBoost do
4
- subject { described_class.new(index: 1.2) }
5
-
6
- describe '#initialize' do
7
- specify { expect(described_class.new.value).to eq({}) }
8
- specify { expect(described_class.new(nil).value).to eq({}) }
9
- specify { expect(subject.value).to eq('index' => 1.2) }
10
- specify { expect(described_class.new(index: '1.2', other: 2).value).to eq('index' => 1.2, 'other' => 2.0) }
11
- end
12
-
13
- describe '#replace!' do
14
- specify do
15
- expect { subject.replace!(nil) }
16
- .to change { subject.value }.from('index' => 1.2).to({})
17
- end
18
-
19
- specify do
20
- expect { subject.replace!(other: 3.1) }
21
- .to change { subject.value }
22
- .from('index' => 1.2).to('other' => 3.1)
23
- end
24
- end
25
-
26
- describe '#update!' do
27
- specify do
28
- expect { subject.update!(nil) }
29
- .not_to change { subject.value }
30
- end
31
-
32
- specify do
33
- expect { subject.update!(other: 3.1) }
34
- .to change { subject.value }
35
- .from('index' => 1.2).to('index' => 1.2, 'other' => 3.1)
36
- end
37
-
38
- context do
39
- before { subject.update!(other: 3.1) }
40
-
41
- specify do
42
- expect { subject.update!(index: 1.5) }
43
- .to change { subject.value }
44
- .from('index' => 1.2, 'other' => 3.1).to('index' => 1.5, 'other' => 3.1)
45
- end
46
-
47
- specify do
48
- expect { subject.update!(index: 1.5) }
49
- .to change { subject.value.keys }
50
- .from(%w[index other]).to(%w[other index])
51
- end
52
- end
53
- end
54
-
55
- describe '#merge!' do
56
- specify do
57
- expect { subject.merge!(described_class.new) }
58
- .not_to change { subject.value }
59
- end
60
-
61
- specify do
62
- expect { subject.merge!(described_class.new(other: 3.1)) }
63
- .to change { subject.value }
64
- .from('index' => 1.2)
65
- .to('index' => 1.2, 'other' => 3.1)
66
- end
67
- end
68
-
69
- describe '#render' do
70
- specify { expect(described_class.new.render).to be_nil }
71
- specify { expect(described_class.new(index: 1.2).render).to eq(indices_boost: [{'index' => 1.2}]) }
72
- specify { expect(described_class.new(index: 1.2, other: 1.3).render).to eq(indices_boost: [{'index' => 1.2}, {'other' => 1.3}]) }
73
- specify { expect(described_class.new(index: 1.2, other: 1.3).tap { |i| i.update!(index: '1.5') }.render).to eq(indices_boost: [{'other' => 1.3}, {'index' => 1.5}]) }
74
- end
75
-
76
- describe '#==' do
77
- specify { expect(described_class.new).to eq(described_class.new) }
78
- specify { expect(described_class.new(index: 1.2)).to eq(described_class.new(index: 1.2)) }
79
- specify { expect(described_class.new(index: 1.2)).not_to eq(described_class.new(other: 1.3)) }
80
- specify { expect(described_class.new(index: 1.2, other: 1.3)).to eq(described_class.new(index: 1.2, other: 1.3)) }
81
- specify { expect(described_class.new(index: 1.2, other: 1.3)).not_to eq(described_class.new(other: 1.3, index: 1.2)) }
82
- end
83
- end