elasticsearch-model 7.0.0 → 7.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/README.md +15 -27
  4. data/Rakefile +13 -14
  5. data/elasticsearch-model.gemspec +37 -40
  6. data/examples/activerecord_article.rb +1 -1
  7. data/examples/activerecord_associations.rb +2 -2
  8. data/examples/activerecord_custom_analyzer.rb +3 -3
  9. data/examples/activerecord_mapping_completion.rb +1 -1
  10. data/examples/activerecord_mapping_edge_ngram.rb +1 -1
  11. data/examples/couchbase_article.rb +1 -1
  12. data/examples/datamapper_article.rb +1 -1
  13. data/examples/mongoid_article.rb +1 -1
  14. data/examples/ohm_article.rb +1 -1
  15. data/examples/riak_article.rb +1 -1
  16. data/gemfiles/4.0.gemfile +4 -3
  17. data/lib/elasticsearch/model/adapter.rb +1 -1
  18. data/lib/elasticsearch/model/adapters/active_record.rb +2 -2
  19. data/lib/elasticsearch/model/adapters/default.rb +1 -1
  20. data/lib/elasticsearch/model/adapters/mongoid.rb +1 -1
  21. data/lib/elasticsearch/model/adapters/multiple.rb +1 -1
  22. data/lib/elasticsearch/model/callbacks.rb +1 -1
  23. data/lib/elasticsearch/model/client.rb +1 -6
  24. data/lib/elasticsearch/model/ext/active_record.rb +1 -1
  25. data/lib/elasticsearch/model/hash_wrapper.rb +1 -1
  26. data/lib/elasticsearch/model/importing.rb +11 -5
  27. data/lib/elasticsearch/model/indexing.rb +4 -4
  28. data/lib/elasticsearch/model/multimodel.rb +2 -2
  29. data/lib/elasticsearch/model/naming.rb +1 -1
  30. data/lib/elasticsearch/model/proxy.rb +7 -4
  31. data/lib/elasticsearch/model/response/aggregations.rb +1 -1
  32. data/lib/elasticsearch/model/response/base.rb +1 -1
  33. data/lib/elasticsearch/model/response/pagination/kaminari.rb +1 -1
  34. data/lib/elasticsearch/model/response/pagination/will_paginate.rb +1 -1
  35. data/lib/elasticsearch/model/response/pagination.rb +1 -1
  36. data/lib/elasticsearch/model/response/records.rb +1 -1
  37. data/lib/elasticsearch/model/response/result.rb +1 -1
  38. data/lib/elasticsearch/model/response/results.rb +2 -1
  39. data/lib/elasticsearch/model/response/suggestions.rb +1 -1
  40. data/lib/elasticsearch/model/response.rb +1 -1
  41. data/lib/elasticsearch/model/searching.rb +1 -1
  42. data/lib/elasticsearch/model/serializing.rb +1 -1
  43. data/lib/elasticsearch/model/version.rb +2 -2
  44. data/lib/elasticsearch/model.rb +4 -4
  45. data/spec/elasticsearch/model/adapter_spec.rb +1 -1
  46. data/spec/elasticsearch/model/adapters/active_record/associations_spec.rb +1 -1
  47. data/spec/elasticsearch/model/adapters/active_record/basic_spec.rb +1 -1
  48. data/spec/elasticsearch/model/adapters/active_record/dynamic_index_name_spec.rb +1 -1
  49. data/spec/elasticsearch/model/adapters/active_record/import_spec.rb +2 -13
  50. data/spec/elasticsearch/model/adapters/active_record/multi_model_spec.rb +1 -1
  51. data/spec/elasticsearch/model/adapters/active_record/namespaced_model_spec.rb +1 -1
  52. data/spec/elasticsearch/model/adapters/active_record/pagination_spec.rb +1 -1
  53. data/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb +1 -1
  54. data/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb +1 -1
  55. data/spec/elasticsearch/model/adapters/active_record_spec.rb +1 -1
  56. data/spec/elasticsearch/model/adapters/default_spec.rb +1 -1
  57. data/spec/elasticsearch/model/adapters/mongoid/basic_spec.rb +1 -1
  58. data/spec/elasticsearch/model/adapters/mongoid/multi_model_spec.rb +12 -12
  59. data/spec/elasticsearch/model/adapters/mongoid_spec.rb +1 -1
  60. data/spec/elasticsearch/model/adapters/multiple_spec.rb +1 -1
  61. data/spec/elasticsearch/model/callbacks_spec.rb +1 -1
  62. data/spec/elasticsearch/model/client_spec.rb +4 -4
  63. data/spec/elasticsearch/model/hash_wrapper_spec.rb +1 -1
  64. data/spec/elasticsearch/model/importing_spec.rb +13 -1
  65. data/spec/elasticsearch/model/indexing_spec.rb +17 -42
  66. data/spec/elasticsearch/model/module_spec.rb +3 -2
  67. data/spec/elasticsearch/model/multimodel_spec.rb +1 -1
  68. data/spec/elasticsearch/model/naming_spec.rb +1 -1
  69. data/spec/elasticsearch/model/proxy_spec.rb +10 -2
  70. data/spec/elasticsearch/model/response/aggregations_spec.rb +1 -1
  71. data/spec/elasticsearch/model/response/base_spec.rb +1 -1
  72. data/spec/elasticsearch/model/response/pagination/kaminari_spec.rb +1 -1
  73. data/spec/elasticsearch/model/response/pagination/will_paginate_spec.rb +1 -1
  74. data/spec/elasticsearch/model/response/records_spec.rb +1 -1
  75. data/spec/elasticsearch/model/response/response_spec.rb +1 -1
  76. data/spec/elasticsearch/model/response/result_spec.rb +1 -1
  77. data/spec/elasticsearch/model/response/results_spec.rb +13 -1
  78. data/spec/elasticsearch/model/searching_search_request_spec.rb +1 -1
  79. data/spec/elasticsearch/model/searching_spec.rb +1 -1
  80. data/spec/elasticsearch/model/serializing_spec.rb +1 -1
  81. data/spec/spec_helper.rb +11 -3
  82. data/spec/support/app/answer.rb +2 -2
  83. data/spec/support/app/article.rb +1 -1
  84. data/spec/support/app/article_for_pagination.rb +1 -1
  85. data/spec/support/app/article_no_type.rb +1 -1
  86. data/spec/support/app/article_with_custom_serialization.rb +1 -1
  87. data/spec/support/app/article_with_dynamic_index_name.rb +1 -1
  88. data/spec/support/app/author.rb +1 -1
  89. data/spec/support/app/authorship.rb +1 -1
  90. data/spec/support/app/category.rb +1 -1
  91. data/spec/support/app/comment.rb +1 -1
  92. data/spec/support/app/episode.rb +1 -1
  93. data/spec/support/app/image.rb +1 -1
  94. data/spec/support/app/import_article.rb +1 -1
  95. data/spec/support/app/mongoid_article.rb +1 -1
  96. data/spec/support/app/namespaced_book.rb +1 -1
  97. data/spec/support/app/parent_and_child_searchable.rb +1 -1
  98. data/spec/support/app/post.rb +1 -1
  99. data/spec/support/app/question.rb +1 -1
  100. data/spec/support/app/searchable.rb +1 -1
  101. data/spec/support/app/series.rb +1 -1
  102. data/spec/support/app.rb +2 -2
  103. metadata +40 -54
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ced6c99b3278104e708dc2db19a73422273f92b9c18d3aa1f0d552e0ba27d97
4
- data.tar.gz: 9075efe50a3f7da082933e3e9acc9751901dc4561f92a70c4d3cbea000c581ee
3
+ metadata.gz: e1aecf263867f2176d7819eccd7e23f9b37bc85132223b8f64398ab85736ea75
4
+ data.tar.gz: af80ff000fcf065f2694141bfcdc282a947cfea05f5ece2f11a24897f5753039
5
5
  SHA512:
6
- metadata.gz: b8f7d0e726d805048544b8ffce8a81b269be4f17c3696241372f6258a7c9add622998718fb23c35b752cc1a51d64a0b8ef42a293b31718f6ba4ed51cfced7586
7
- data.tar.gz: 36e3325b72bfa63f8ea133b44086d579bb8727a6e5d8c71115ab25d424b6058e849a32aa68326f5450c1f0fbe5c75fedead8878893309ffbca29901c773367be
6
+ metadata.gz: 246ae4f642a662a4a0c5fe6e26581c052c15ddf868d9b47b640c3f996e584056a8facc4004d61151647e67e6624d1bb16cad90a4513f303ad0afdeaf84b1eedf
7
+ data.tar.gz: 406c37164bb6fc16068d2edcf6e1183d9c2ba34420d57fab9d3f288416fd0d75173ecc4ad3f37236051d517db717c4fb37ae2d44663f87a6b28213637ea8f7a5
data/Gemfile CHANGED
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -21,6 +21,6 @@ source 'https://rubygems.org'
21
21
  gemspec
22
22
 
23
23
  group :development, :testing do
24
- gem 'rspec'
25
24
  gem 'pry-nav'
25
+ gem 'rspec'
26
26
  end
data/README.md CHANGED
@@ -1,18 +1,14 @@
1
1
  # Elasticsearch::Model
2
2
 
3
- The `elasticsearch-model` library builds on top of the
4
- the [`elasticsearch`](https://github.com/elastic/elasticsearch-ruby) library.
3
+ The `elasticsearch-model` library builds on top of the the [`elasticsearch`](https://github.com/elastic/elasticsearch-ruby) library.
5
4
 
6
- It aims to simplify integration of Ruby classes ("models"), commonly found
7
- e.g. in [Ruby on Rails](http://rubyonrails.org) applications, with the
8
- [Elasticsearch](https://www.elastic.co) search and analytics engine.
5
+ It aims to simplify integration of Ruby classes ("models"), commonly found e.g. in [Ruby on Rails](http://rubyonrails.org) applications, with the [Elasticsearch](https://www.elastic.co) search and analytics engine.
9
6
 
10
7
  ## Compatibility
11
8
 
12
- This library is compatible with Ruby 1.9.3 and higher.
9
+ This library is compatible with Ruby 2.4 and higher.
13
10
 
14
- The library version numbers follow the Elasticsearch major versions, and the `master` branch
15
- is compatible with the Elasticsearch `master` branch, therefore, with the next major version.
11
+ The library version numbers follow the Elasticsearch major versions. The `main` branch is compatible with the latest Elasticsearch stack stable release.
16
12
 
17
13
  | Rubygem | | Elasticsearch |
18
14
  |:-------------:|:-:| :-----------: |
@@ -20,7 +16,7 @@ is compatible with the Elasticsearch `master` branch, therefore, with the next m
20
16
  | 2.x | → | 2.x |
21
17
  | 5.x | → | 5.x |
22
18
  | 6.x | → | 6.x |
23
- | master | → | master |
19
+ | main | → | 7.x |
24
20
 
25
21
  ## Installation
26
22
 
@@ -73,9 +69,7 @@ This will extend the model with functionality related to Elasticsearch.
73
69
 
74
70
  #### Feature Extraction Pattern
75
71
 
76
- Instead of including the `Elasticsearch::Model` module directly in your model,
77
- you can include it in a "concern" or "trait" module, which is quite common pattern in Rails applications,
78
- using e.g. `ActiveSupport::Concern` as the instrumentation:
72
+ Instead of including the `Elasticsearch::Model` module directly in your model, you can include it in a "concern" or "trait" module, which is quite common pattern in Rails applications, using e.g. `ActiveSupport::Concern` as the instrumentation:
79
73
 
80
74
  ```ruby
81
75
  # In: app/models/concerns/searchable.rb
@@ -122,7 +116,7 @@ See the `Elasticsearch::Model` module documentation for technical information.
122
116
 
123
117
  ### The Elasticsearch client
124
118
 
125
- The module will set up a [client](https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch),
119
+ The module will set up a [client](https://github.com/elastic/elasticsearch-ruby/tree/main/elasticsearch),
126
120
  connected to `localhost:9200`, by default. You can access and use it as any other `Elasticsearch::Client`:
127
121
 
128
122
  ```ruby
@@ -145,7 +139,7 @@ Elasticsearch::Model.client = Elasticsearch::Client.new log: true
145
139
  You might want to do this during your application bootstrap process, e.g. in a Rails initializer.
146
140
 
147
141
  Please refer to the
148
- [`elasticsearch-transport`](https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch-transport)
142
+ [`elasticsearch-transport`](https://github.com/elastic/elasticsearch-ruby/tree/main/elasticsearch-transport)
149
143
  library documentation for all the configuration options, and to the
150
144
  [`elasticsearch-api`](http://rubydoc.info/gems/elasticsearch-api) library documentation
151
145
  for information about the Ruby client API.
@@ -254,7 +248,7 @@ response.records.order(:title).to_a
254
248
  The `records` method returns the real instances of your model, which is useful when you want to access your
255
249
  model methods -- at the expense of slowing down your application, of course.
256
250
  In most cases, working with `results` coming from Elasticsearch is sufficient, and much faster. See the
257
- [`elasticsearch-rails`](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-rails)
251
+ [`elasticsearch-rails`](https://github.com/elastic/elasticsearch-rails/tree/main/elasticsearch-rails)
258
252
  library for more information about compatibility with the Ruby on Rails framework.
259
253
 
260
254
  When you want to access both the database `records` and search `results`, use the `each_with_hit`
@@ -290,11 +284,8 @@ NOTE: It is _not_ possible to chain other methods on top of the `records` object
290
284
 
291
285
  #### Pagination
292
286
 
293
- You can implement pagination with the `from` and `size` search parameters. However, search results
294
- can be automatically paginated with the [`kaminari`](http://rubygems.org/gems/kaminari) or
295
- [`will_paginate`](https://github.com/mislav/will_paginate) gems.
296
- (The pagination gems must be added before the Elasticsearch gems in your Gemfile,
297
- or loaded first in your application.)
287
+ You can implement pagination with the `from` and `size` search parameters. However, search results can be automatically paginated with the [`kaminari`](http://rubygems.org/gems/kaminari) or [`will_paginate`](https://github.com/mislav/will_paginate) gems.
288
+ (The pagination gems must be added before the Elasticsearch gems in your Gemfile, or loaded first in your application.)
298
289
 
299
290
  If Kaminari or WillPaginate is loaded, use the familiar paging methods:
300
291
 
@@ -322,8 +313,7 @@ Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model
322
313
 
323
314
  #### The Elasticsearch DSL
324
315
 
325
- In most situations, you'll want to pass the search definition
326
- in the Elasticsearch [domain-specific language](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html) to the client:
316
+ In most situations, you'll want to pass the search definition in the Elasticsearch [domain-specific language](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html) to the client:
327
317
 
328
318
  ```ruby
329
319
  response = Article.search query: { match: { title: "Fox Dogs" } },
@@ -333,8 +323,7 @@ response.results.first.highlight.title
333
323
  # ["Quick brown <em>fox</em>"]
334
324
  ```
335
325
 
336
- You can pass any object which implements a `to_hash` method, which is called automatically,
337
- so you can use a custom class or your favourite JSON builder to build the search definition:
326
+ You can pass any object which implements a `to_hash` method, which is called automatically, so you can use a custom class or your favourite JSON builder to build the search definition:
338
327
 
339
328
  ```ruby
340
329
  require 'jbuilder'
@@ -354,8 +343,7 @@ response.results.first.title
354
343
  # => "Quick brown fox"
355
344
  ```
356
345
 
357
- Also, you can use the [**`elasticsearch-dsl`**](https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch-dsl) library, which provides a specialized Ruby API for
358
- the Elasticsearch Query DSL:
346
+ Also, you can use the [**`elasticsearch-dsl`**](https://github.com/elastic/elasticsearch-ruby/tree/main/elasticsearch-dsl) library, which provides a specialized Ruby API for the Elasticsearch Query DSL:
359
347
 
360
348
  ```ruby
361
349
  require 'elasticsearch/dsl'
@@ -533,7 +521,7 @@ class Indexer
533
521
  Logger = Sidekiq.logger.level == Logger::DEBUG ? Sidekiq.logger : nil
534
522
  Client = Elasticsearch::Client.new host: 'localhost:9200', logger: Logger
535
523
 
536
- def perform_async(operation, record_id)
524
+ def perform(operation, record_id)
537
525
  logger.debug [operation, "ID: #{record_id}"]
538
526
 
539
527
  case operation.to_s
data/Rakefile CHANGED
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -15,29 +15,28 @@
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
17
 
18
- require "bundler/gem_tasks"
18
+ require 'bundler/gem_tasks'
19
19
 
20
- desc "Run unit tests"
21
- task :default => 'test:unit'
22
- task :test => 'test:unit'
20
+ desc 'Run unit tests'
21
+ task default: 'test:all'
22
+ task test: 'test:all'
23
23
 
24
- if RUBY_VERSION < '2.3'
25
- GEMFILES = ['3.0.gemfile', '4.0.gemfile', '5.0.gemfile']
26
- else
27
- GEMFILES = ['4.0.gemfile', '5.0.gemfile', '6.0.gemfile']
28
- end
24
+ gemfiles = ['5.0.gemfile', '6.0.gemfile']
25
+ gemfiles << '4.0.gemfile' if RUBY_VERSION < '2.7'
26
+ GEMFILES = gemfiles.freeze
29
27
 
30
28
  namespace :bundle do
31
29
  desc 'Install dependencies for all the Gemfiles in /gemfiles. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0'
32
30
  task :install do
33
31
  unless defined?(JRUBY_VERSION)
34
- puts '-'*80
32
+ puts '-' * 80
35
33
  gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map { |v| "#{v}.gemfile"} : GEMFILES
36
34
  gemfiles.each do |gemfile|
37
- Bundler.with_clean_env do
35
+ puts "GEMFILE: #{gemfile}"
36
+ Bundler.with_unbundled_env do
38
37
  sh "bundle install --gemfile #{File.expand_path('../gemfiles/'+gemfile, __FILE__)}"
39
38
  end
40
- puts '-'*80
39
+ puts '-' * 80
41
40
  end
42
41
  end
43
42
  end
@@ -47,12 +46,12 @@ end
47
46
 
48
47
  require 'rake/testtask'
49
48
  namespace :test do
50
-
51
49
  desc 'Run all tests. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0'
52
50
  task :all, [:rails_versions] do |task, args|
53
51
  gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map {|v| "#{v}.gemfile"} : GEMFILES
54
52
  puts '-' * 80
55
53
  gemfiles.each do |gemfile|
54
+ puts "GEMFILE: #{gemfile}"
56
55
  sh "BUNDLE_GEMFILE='#{File.expand_path("../gemfiles/#{gemfile}", __FILE__)}' " +
57
56
  " bundle exec rspec"
58
57
  puts '-' * 80
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -16,56 +16,53 @@
16
16
  # under the License.
17
17
 
18
18
  # coding: utf-8
19
- lib = File.expand_path('../lib', __FILE__)
19
+
20
+ lib = File.expand_path('lib', __dir__)
20
21
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
21
22
  require 'elasticsearch/model/version'
22
23
 
23
24
  Gem::Specification.new do |s|
24
- s.name = "elasticsearch-model"
25
+ s.name = 'elasticsearch-model'
25
26
  s.version = Elasticsearch::Model::VERSION
26
- s.authors = ["Karel Minarik"]
27
- s.email = ["karel.minarik@elasticsearch.org"]
28
- s.description = "ActiveModel/Record integrations for Elasticsearch."
29
- s.summary = "ActiveModel/Record integrations for Elasticsearch."
30
- s.homepage = "https://github.com/elasticsearch/elasticsearch-rails/"
31
- s.license = "Apache 2"
27
+ s.authors = ['Karel Minarik']
28
+ s.email = ['karel.minarik@elasticsearch.org']
29
+ s.description = 'ActiveModel/Record integrations for Elasticsearch.'
30
+ s.summary = 'ActiveModel/Record integrations for Elasticsearch.'
31
+ s.homepage = 'https://github.com/elasticsearch/elasticsearch-rails/'
32
+ s.license = 'Apache 2'
32
33
 
33
34
  s.files = `git ls-files`.split($/)
34
35
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
35
36
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
36
- s.require_paths = ["lib"]
37
-
38
- s.extra_rdoc_files = [ "README.md", "LICENSE.txt" ]
39
- s.rdoc_options = [ "--charset=UTF-8" ]
40
-
41
- s.required_ruby_version = ">= 1.9.3"
42
-
43
- s.add_dependency "elasticsearch", '> 1'
44
- s.add_dependency "activesupport", '> 3'
45
- s.add_dependency "hashie"
46
-
47
- s.add_development_dependency "bundler"
48
- s.add_development_dependency "rake", "~> 11.1"
49
-
50
- s.add_development_dependency "elasticsearch-extensions"
37
+ s.require_paths = ['lib']
51
38
 
52
- s.add_development_dependency "sqlite3" unless defined?(JRUBY_VERSION)
53
- s.add_development_dependency "activemodel", "> 3"
39
+ s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
40
+ s.rdoc_options = ['--charset=UTF-8']
54
41
 
55
- s.add_development_dependency "oj" unless defined?(JRUBY_VERSION)
56
- s.add_development_dependency "kaminari"
57
- s.add_development_dependency "will_paginate"
42
+ s.required_ruby_version = '>= 2.4'
58
43
 
59
- s.add_development_dependency "minitest"
60
- s.add_development_dependency "test-unit"
61
- s.add_development_dependency "shoulda-context"
62
- s.add_development_dependency "mocha"
63
- s.add_development_dependency "turn"
64
- s.add_development_dependency "yard"
65
- s.add_development_dependency "ruby-prof" unless defined?(JRUBY_VERSION)
66
- s.add_development_dependency "pry"
44
+ s.add_dependency 'activesupport', '> 3'
45
+ s.add_dependency 'elasticsearch', '~> 7'
46
+ s.add_dependency 'hashie'
67
47
 
68
- s.add_development_dependency "simplecov"
69
- s.add_development_dependency "cane"
70
- s.add_development_dependency "require-prof"
48
+ s.add_development_dependency 'activemodel', '> 3'
49
+ s.add_development_dependency 'bundler'
50
+ s.add_development_dependency 'cane'
51
+ s.add_development_dependency 'kaminari'
52
+ s.add_development_dependency 'minitest'
53
+ s.add_development_dependency 'mocha'
54
+ s.add_development_dependency 'pry'
55
+ s.add_development_dependency 'rake', '~> 12'
56
+ s.add_development_dependency 'require-prof'
57
+ s.add_development_dependency 'shoulda-context'
58
+ s.add_development_dependency 'simplecov'
59
+ s.add_development_dependency 'test-unit'
60
+ s.add_development_dependency 'turn'
61
+ s.add_development_dependency 'will_paginate'
62
+ s.add_development_dependency 'yard'
63
+ unless defined?(JRUBY_VERSION)
64
+ s.add_development_dependency 'oj'
65
+ s.add_development_dependency 'ruby-prof'
66
+ s.add_development_dependency 'sqlite3'
67
+ end
71
68
  end
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -81,7 +81,7 @@ end
81
81
  # ----- Elasticsearch client setup ----------------------------------------------------------------
82
82
 
83
83
  Elasticsearch::Model.client = Elasticsearch::Client.new log: true
84
- Elasticsearch::Model.client.transport.logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" }
84
+ Elasticsearch::Model.client.transport.transport.logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" }
85
85
 
86
86
  # ----- Search integration ------------------------------------------------------------------------
87
87
 
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -37,8 +37,8 @@ ActiveRecord::Schema.define(version: 1) do
37
37
  end
38
38
  end
39
39
 
40
- Elasticsearch::Model.client.transport.logger = ActiveSupport::Logger.new(STDOUT)
41
- Elasticsearch::Model.client.transport.logger.formatter = lambda { |s, d, p, m| "#{m.ansi(:faint)}\n" }
40
+ Elasticsearch::Model.client.transport.transport.logger = ActiveSupport::Logger.new(STDOUT)
41
+ Elasticsearch::Model.client.transport.transport.logger.formatter = lambda { |s, d, p, m| "#{m.ansi(:faint)}\n" }
42
42
 
43
43
  class Article < ActiveRecord::Base
44
44
  include Elasticsearch::Model
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
data/gemfiles/4.0.gemfile CHANGED
@@ -26,10 +26,11 @@ gemspec path: '../'
26
26
 
27
27
  gem 'activemodel', '~> 4'
28
28
  gem 'activerecord', '~> 4'
29
- gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION)
30
29
  gem 'mongoid', '~> 5'
30
+ gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION)
31
31
 
32
32
  group :development, :testing do
33
- gem 'rspec'
33
+ gem 'bigdecimal', '~> 1'
34
34
  gem 'pry-nav'
35
- end
35
+ gem 'rspec'
36
+ end
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -102,7 +102,7 @@ module Elasticsearch
102
102
  scope = scope.__send__(named_scope) if named_scope
103
103
  scope = scope.instance_exec(&query) if query
104
104
 
105
- scope.find_in_batches(options) do |batch|
105
+ scope.find_in_batches(**options) do |batch|
106
106
  batch = self.__send__(preprocess, batch) if preprocess
107
107
  yield(batch) if batch.present?
108
108
  end
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -17,13 +17,10 @@
17
17
 
18
18
  module Elasticsearch
19
19
  module Model
20
-
21
20
  # Contains an `Elasticsearch::Client` instance
22
21
  #
23
22
  module Client
24
-
25
23
  module ClassMethods
26
-
27
24
  # Get the client for a specific model class
28
25
  #
29
26
  # @example Get the client for `Article` and perform API request
@@ -48,7 +45,6 @@ module Elasticsearch
48
45
  end
49
46
 
50
47
  module InstanceMethods
51
-
52
48
  # Get or set the client for a specific model instance
53
49
  #
54
50
  # @example Get the client for a specific record and perform API request
@@ -72,7 +68,6 @@ module Elasticsearch
72
68
  @client = client
73
69
  end
74
70
  end
75
-
76
71
  end
77
72
  end
78
73
  end
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -6,7 +6,7 @@
6
6
  # not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
8
  #
9
- # http://www.apache.org/licenses/LICENSE-2.0
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
10
  #
11
11
  # Unless required by applicable law or agreed to in writing,
12
12
  # software distributed under the License is distributed on an
@@ -143,6 +143,7 @@ module Elasticsearch
143
143
  target_index = options.delete(:index) || index_name
144
144
  target_type = options.delete(:type) || document_type
145
145
  transform = options.delete(:transform) || __transform
146
+ pipeline = options.delete(:pipeline)
146
147
  return_value = options.delete(:return) || 'count'
147
148
 
148
149
  unless transform.respond_to?(:call)
@@ -158,10 +159,15 @@ module Elasticsearch
158
159
  end
159
160
 
160
161
  __find_in_batches(options) do |batch|
161
- response = client.bulk \
162
- index: target_index,
163
- type: target_type,
164
- body: __batch_to_bulk(batch, transform)
162
+ params = {
163
+ index: target_index,
164
+ type: target_type,
165
+ body: __batch_to_bulk(batch, transform)
166
+ }
167
+
168
+ params[:pipeline] = pipeline if pipeline
169
+
170
+ response = client.bulk params
165
171
 
166
172
  yield response if block_given?
167
173