From 635536fe54be1c35e041391779763d87749a11ef Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Fri, 28 Feb 2020 19:58:52 +0000 Subject: [PATCH 001/113] Update rake version --- Gemfile | 2 +- elasticsearch-model/elasticsearch-model.gemspec | 2 +- elasticsearch-persistence/elasticsearch-persistence.gemspec | 2 +- elasticsearch-rails/elasticsearch-rails.gemspec | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 466fb946e..b3f93c953 100644 --- a/Gemfile +++ b/Gemfile @@ -17,7 +17,7 @@ source 'https://rubygems.org' -gem "rake", "~> 11.1" +gem "rake", "~> 12" gem 'elasticsearch-extensions' diff --git a/elasticsearch-model/elasticsearch-model.gemspec b/elasticsearch-model/elasticsearch-model.gemspec index fdfeac1fa..1fe334041 100644 --- a/elasticsearch-model/elasticsearch-model.gemspec +++ b/elasticsearch-model/elasticsearch-model.gemspec @@ -45,7 +45,7 @@ Gem::Specification.new do |s| s.add_dependency "hashie" s.add_development_dependency "bundler" - s.add_development_dependency "rake", "~> 11.1" + s.add_development_dependency "rake", "~> 12" s.add_development_dependency "elasticsearch-extensions" diff --git a/elasticsearch-persistence/elasticsearch-persistence.gemspec b/elasticsearch-persistence/elasticsearch-persistence.gemspec index 069f5c0d3..fd2c6fa95 100644 --- a/elasticsearch-persistence/elasticsearch-persistence.gemspec +++ b/elasticsearch-persistence/elasticsearch-persistence.gemspec @@ -47,7 +47,7 @@ Gem::Specification.new do |s| s.add_dependency "hashie" s.add_development_dependency "bundler" - s.add_development_dependency "rake", "~> 11.1" + s.add_development_dependency "rake", "~> 12" s.add_development_dependency "oj" unless defined?(JRUBY_VERSION) diff --git a/elasticsearch-rails/elasticsearch-rails.gemspec b/elasticsearch-rails/elasticsearch-rails.gemspec index 0911b111c..1af576d9f 100644 --- a/elasticsearch-rails/elasticsearch-rails.gemspec +++ b/elasticsearch-rails/elasticsearch-rails.gemspec @@ -41,7 +41,7 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 1.9.3" s.add_development_dependency "bundler" - s.add_development_dependency "rake", "~> 11.1" + s.add_development_dependency "rake", "~> 12" s.add_development_dependency "elasticsearch-extensions" From ccf604d5fba4e370707d33cb289650edc1259715 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 2 Mar 2020 16:52:14 +0000 Subject: [PATCH 002/113] Fix multi_model_spec --- .../adapters/mongoid/multi_model_spec.rb | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid/multi_model_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid/multi_model_spec.rb index 952cda672..d702eecab 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid/multi_model_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid/multi_model_spec.rb @@ -24,10 +24,10 @@ begin ActiveRecord::Schema.define(:version => 1) do - create_table Episode.table_name do |t| - t.string :name - t.datetime :created_at, :default => 'NOW()' - end + create_table Episode.table_name do |t| + t.string :name + t.datetime :created_at, :default => 'NOW()' + end end rescue end @@ -36,22 +36,22 @@ before do clear_tables(Episode, Image) Episode.__elasticsearch__.create_index! force: true - Episode.create name: "TheEpisode" - Episode.create name: "A great Episode" - Episode.create name: "The greatest Episode" + Episode.create name: 'TheEpisode' + Episode.create name: 'A great Episode' + Episode.create name: 'The greatest Episode' Episode.__elasticsearch__.refresh_index! Image.__elasticsearch__.create_index! force: true - Image.create! name: "The Image" - Image.create! name: "A great Image" - Image.create! name: "The greatest Image" + Image.create! name: 'The Image' + Image.create! name: 'A great Image' + Image.create! name: 'The greatest Image' Image.__elasticsearch__.refresh_index! Image.__elasticsearch__.client.cluster.health wait_for_status: 'yellow' end after do [Episode, Image].each do |model| - model.__elasticsearch__.client.delete_by_query(index: model.index_name, q: '*') + model.__elasticsearch__.client.delete_by_query(index: model.index_name, q: '*', body: {}) model.delete_all model.__elasticsearch__.refresh_index! end From 1ef2531be578d53db04e603a8ec42c76933895cd Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 2 Mar 2020 17:08:39 +0000 Subject: [PATCH 003/113] Update Ruby versions, drop 2.2 and 2.3 --- .travis.yml | 14 ++------------ README.md | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index ddb68c295..69dfc5553 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,14 +19,6 @@ branches: matrix: include: - - rvm: 2.2.10 - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0 - - - rvm: 2.3.8 - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0 - - rvm: 2.4.9 jdk: oraclejdk8 env: RAILS_VERSIONS=5.0 @@ -37,7 +29,7 @@ matrix: - rvm: 2.6.5 jdk: oraclejdk8 - env: RAILS_VERSIONS=4.0,5.0,6.0 + env: RAILS_VERSIONS=5.0,6.0 - rvm: 2.7.0 jdk: oraclejdk8 @@ -65,9 +57,7 @@ env: before_install: - source ./.ci/travis_before_script.sh - - if [ $TRAVIS_RUBY_VERSION != "2.2.10" ]; then - gem update --system; - fi + - gem update --system; - gem update bundler - gem --version - bundle version diff --git a/README.md b/README.md index 0c7565394..65cd5d1c1 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Elasticsearch client and Ruby API is provided by the ## Compatibility -The libraries are compatible with Ruby 1.9.3 and higher. +The libraries are compatible with Ruby 2.4 and higher. The version numbers follow the Elasticsearch major versions. The `master` branch is compatible with the Elasticsearch `master` branch, therefore, with the next major version. From 16e53f557a8f152d86959a822c9b692135837bfa Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 2 Mar 2020 17:15:07 +0000 Subject: [PATCH 004/113] Fix/cleanup Rakefile --- elasticsearch-model/Rakefile | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/elasticsearch-model/Rakefile b/elasticsearch-model/Rakefile index 76291b92a..b31a4b5dc 100644 --- a/elasticsearch-model/Rakefile +++ b/elasticsearch-model/Rakefile @@ -15,17 +15,13 @@ # specific language governing permissions and limitations # under the License. -require "bundler/gem_tasks" +require 'bundler/gem_tasks' -desc "Run unit tests" -task :default => 'test:unit' -task :test => 'test:unit' +desc 'Run unit tests' +task default: 'test:all' +task test: 'test:all' -if RUBY_VERSION < '2.3' - GEMFILES = ['3.0.gemfile', '4.0.gemfile', '5.0.gemfile'] -else - GEMFILES = ['4.0.gemfile', '5.0.gemfile', '6.0.gemfile'] -end +GEMFILES = ['4.0.gemfile', '5.0.gemfile', '6.0.gemfile'] namespace :bundle do desc 'Install dependencies for all the Gemfiles in /gemfiles. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0' @@ -47,7 +43,6 @@ end require 'rake/testtask' namespace :test do - desc 'Run all tests. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0' task :all, [:rails_versions] do |task, args| gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map {|v| "#{v}.gemfile"} : GEMFILES From 1c34f6c8f019de29adad6b9758443bd74f6ba4a4 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 2 Mar 2020 17:16:06 +0000 Subject: [PATCH 005/113] Fix specs to include body in spec_helper --- .../model/adapters/active_record/import_spec.rb | 13 +------------ elasticsearch-model/spec/spec_helper.rb | 12 ++++++++++-- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb index 39ff5095f..e4a6088c8 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb @@ -18,7 +18,6 @@ require 'spec_helper' describe 'Elasticsearch::Model::Adapter::ActiveRecord Importing' do - before(:all) do ActiveRecord::Schema.define(:version => 1) do create_table :import_articles do |t| @@ -43,11 +42,9 @@ end describe '#import' do - context 'when no search criteria is specified' do - before do - 10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" } + 10.times { |i| ImportArticle.create! title: 'Test', views: i.to_s } ImportArticle.import ImportArticle.__elasticsearch__.refresh_index! end @@ -58,7 +55,6 @@ end context 'when batch size is specified' do - before do 10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" } end @@ -82,7 +78,6 @@ end context 'when a scope is specified' do - before do 10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" } ImportArticle.import(scope: 'popular', force: true) @@ -95,7 +90,6 @@ end context 'when a query is specified' do - before do 10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" } ImportArticle.import(query: -> { where('views >= 3') }) @@ -108,7 +102,6 @@ end context 'when there are invalid documents' do - let!(:result) do 10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" } new_article @@ -132,7 +125,6 @@ end context 'when a transform proc is specified' do - before do 10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" } ImportArticle.import( transform: ->(a) {{ index: { data: { name: a.title, foo: 'BAR' } }}} ) @@ -151,7 +143,6 @@ end context 'when the model has a default scope' do - around(:all) do |example| 10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" } ImportArticle.instance_eval { default_scope { where('views > 3') } } @@ -170,7 +161,6 @@ end context 'when there is a default scope and a query specified' do - around(:all) do |example| 10.times { |i| ImportArticle.create! title: 'Test', views: "#{i}" } ImportArticle.instance_eval { default_scope { where('views > 3') } } @@ -189,7 +179,6 @@ end context 'when the batch is empty' do - before do ImportArticle.delete_all ImportArticle.import diff --git a/elasticsearch-model/spec/spec_helper.rb b/elasticsearch-model/spec/spec_helper.rb index eb4e5fbbc..7bf7f41dc 100644 --- a/elasticsearch-model/spec/spec_helper.rb +++ b/elasticsearch-model/spec/spec_helper.rb @@ -81,8 +81,16 @@ def active_record_at_least_4? # @since 6.0.1 def clear_indices(*models) models.each do |model| - begin; Elasticsearch::Model.client.delete_by_query(index: model.index_name, q: '*'); rescue; end - end and true + begin + Elasticsearch::Model.client.delete_by_query( + index: model.index_name, + q: '*', + body: {} + ) + rescue + end + end + true end # Delete all documents from the tables of the provided list of models. From 63c24c9fe48a74d00c65145cc55c32f4c6907448 Mon Sep 17 00:00:00 2001 From: Kelly Joseph Price Date: Sat, 23 Sep 2017 12:21:15 -0700 Subject: [PATCH 006/113] Add pipeline to bulk params --- .../lib/elasticsearch/model/importing.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/importing.rb b/elasticsearch-model/lib/elasticsearch/model/importing.rb index 0534c2519..c0519ef9f 100644 --- a/elasticsearch-model/lib/elasticsearch/model/importing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/importing.rb @@ -143,6 +143,7 @@ def import(options={}, &block) target_index = options.delete(:index) || index_name target_type = options.delete(:type) || document_type transform = options.delete(:transform) || __transform + pipeline = options.delete(:pipeline) return_value = options.delete(:return) || 'count' unless transform.respond_to?(:call) @@ -158,10 +159,15 @@ def import(options={}, &block) end __find_in_batches(options) do |batch| - response = client.bulk \ - index: target_index, - type: target_type, - body: __batch_to_bulk(batch, transform) + params = { + index: target_index, + type: target_type, + body: __batch_to_bulk(batch, transform) + } + + params[:pipeline] = pipeline if pipeline + + response = client.bulk params yield response if block_given? From 589fd76f7eb388f5fcc1c4c4b854a47298e6dac6 Mon Sep 17 00:00:00 2001 From: Kelly Joseph Price Date: Wed, 19 Sep 2018 12:26:01 -0700 Subject: [PATCH 007/113] Add spec --- .../spec/elasticsearch/model/importing_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb index f42166a25..19bbff715 100644 --- a/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb @@ -227,5 +227,17 @@ def importing_mixin end end end + + context 'when a pipeline is provided as an options' do + + before do + expect(DummyImportingModel).to receive(:client).and_return(client) + expect(client).to receive(:bulk).with(body: nil, index: 'foo', type: 'foo', pipeline: 'my-pipeline').and_return(response) + end + + it 'uses the pipeline option' do + expect(DummyImportingModel.import(pipeline: 'my-pipeline')).to eq(0) + end + end end end From a3ff5e3b595707e425c0aeb794b74f5e5074eac4 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 23 Mar 2020 12:47:39 +0000 Subject: [PATCH 008/113] [DOCS] Updates Readme Fixes #925 --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 65cd5d1c1..4a45c64ad 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ This repository contains various Ruby and Rails integrations for [Elasticsearch] * Templates for generating example Rails application Elasticsearch client and Ruby API is provided by the -**[elasticsearch-ruby](https://github.com/elasticsearch/elasticsearch-ruby)** project. +**[elasticsearch-ruby](https://github.com/elastic/elasticsearch-ruby)** project. ## Compatibility @@ -59,13 +59,13 @@ gem 'elasticsearch-rails', github: 'elastic/elasticsearch-rails', branch: '5.x' This project is split into three separate gems: -* [**`elasticsearch-model`**](https://github.com/elasticsearch/elasticsearch-rails/tree/master/elasticsearch-model), +* [**`elasticsearch-model`**](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-model), which contains search integration for Ruby/Rails models such as ActiveRecord::Base and Mongoid, -* [**`elasticsearch-persistence`**](https://github.com/elasticsearch/elasticsearch-rails/tree/master/elasticsearch-persistence), +* [**`elasticsearch-persistence`**](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-persistence), which provides a standalone persistence layer for Ruby/Rails objects and models -* [**`elasticsearch-rails`**](https://github.com/elasticsearch/elasticsearch-rails/tree/master/elasticsearch-rails), +* [**`elasticsearch-rails`**](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-rails), which contains various features for Ruby on Rails applications Example of a basic integration into an ActiveRecord-based model: @@ -88,7 +88,7 @@ Article.import ``` You can generate a simple Ruby on Rails application with a single command -(see the [other available templates](https://github.com/elasticsearch/elasticsearch-rails/tree/master/elasticsearch-rails#rails-application-templates)): +(see the [other available templates](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-rails#rails-application-templates)): ```bash rails new searchapp --skip --skip-bundle --template https://raw.github.com/elasticsearch/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/01-basic.rb @@ -115,21 +115,21 @@ repository.save Article.new(title: 'Test') ### Model -* [[README]](https://github.com/elasticsearch/elasticsearch-rails/blob/master/elasticsearch-model/README.md) +* [[README]](https://github.com/elastic/elasticsearch-rails/blob/master/elasticsearch-model/README.md) * [[Documentation]](http://rubydoc.info/gems/elasticsearch-model/) -* [[Test Suite]](https://github.com/elasticsearch/elasticsearch-rails/blob/master/elasticsearch-model/test) +* [[Test Suite]](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-model/spec/elasticsearch/model) ### Persistence -* [[README]](https://github.com/elasticsearch/elasticsearch-rails/blob/master/elasticsearch-persistence/README.md) +* [[README]](https://github.com/elastic/elasticsearch-rails/blob/master/elasticsearch-persistence/README.md) * [[Documentation]](http://rubydoc.info/gems/elasticsearch-persistence/) -* [[Test Suite]](https://github.com/elasticsearch/elasticsearch-rails/blob/master/elasticsearch-persistence/test) +* [[Test Suite]](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-persistence/spec) ### Rails -* [[README]](https://github.com/elasticsearch/elasticsearch-rails/blob/master/elasticsearch-rails/README.md) +* [[README]](https://github.com/elastic/elasticsearch-rails/blob/master/elasticsearch-rails/README.md) * [[Documentation]](http://rubydoc.info/gems/elasticsearch-rails) -* [[Test Suite]](https://github.com/elasticsearch/elasticsearch-rails/blob/master/elasticsearch-rails/test) +* [[Test Suite]](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-rails/spec) ## Development @@ -154,7 +154,7 @@ The test suite expects an Elasticsearch cluster running on port 9250, and **will TEST_CLUSTER_COMMAND=/tmp/builds/elasticsearch-2.0.0-SNAPSHOT/bin/elasticsearch TEST_CLUSTER_NODES=1 bundle exec rake test:cluster:start -See more information in the documentation for the [`elasticsearch-extensions`](https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-extensions#testcluster) gem. +See more information in the documentation for the [`elasticsearch-extensions`](https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch-extensions#testcluster) gem. ## License From 82d799e910add123f2d95d8700ab607ba682a478 Mon Sep 17 00:00:00 2001 From: Orhan Toy Date: Fri, 27 Mar 2020 16:33:11 +0100 Subject: [PATCH 009/113] [DOCS] Move `gem install` to a non-Ruby code block `gem install ...` is not Ruby, and the other places with `gem install` also use the indented block style. --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4a45c64ad..48f5e6f60 100644 --- a/README.md +++ b/README.md @@ -43,10 +43,8 @@ to learn which releases are still actively supported and tested. Install each library from [Rubygems](https://rubygems.org/gems/elasticsearch): -```ruby -gem install elasticsearch-model -gem install elasticsearch-rails -``` + gem install elasticsearch-model + gem install elasticsearch-rails To use an unreleased version, add it to your `Gemfile` for [Bundler](http://bundler.io): From 7dd63debddb8684e02b5e1855c944c238271e23f Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 8 Apr 2020 12:12:03 +0100 Subject: [PATCH 010/113] Test against Elasticsearch version 7.6.0 --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 69dfc5553..d829ee013 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,19 +19,19 @@ branches: matrix: include: - - rvm: 2.4.9 + - rvm: 2.4 jdk: oraclejdk8 env: RAILS_VERSIONS=5.0 - - rvm: 2.5.7 + - rvm: 2.5 jdk: oraclejdk8 env: RAILS_VERSIONS=5.0,6.0 - - rvm: 2.6.5 + - rvm: 2.6 jdk: oraclejdk8 env: RAILS_VERSIONS=5.0,6.0 - - rvm: 2.7.0 + - rvm: 2.7 jdk: oraclejdk8 env: RAILS_VERSIONS=5.0,6.0 @@ -50,7 +50,7 @@ matrix: env: global: - - ELASTICSEARCH_VERSION=7.2.0 + - ELASTICSEARCH_VERSION=7.6.2 - TEST_ES_SERVER=http://localhost:9250 - TEST_CLUSTER_PORT=9250 - QUIET=true From 87613bbd2fafcf77cabf5d7fced3377108010c6f Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 15 Apr 2020 11:09:32 +0100 Subject: [PATCH 011/113] Release 7.1.0 --- CHANGELOG.md | 9 +++++++-- elasticsearch-model/lib/elasticsearch/model/version.rb | 2 +- .../elasticsearch-persistence.gemspec | 2 +- .../lib/elasticsearch/persistence/version.rb | 2 +- elasticsearch-rails/lib/elasticsearch/rails/version.rb | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1ff80f10..b7af564d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ -## 7.0.0.pre +## 7.1.0 + +* Tested with elasticsearch Ruby client version 7.6.0 +* Updates rake version +* Adds pipeline to bulk params [commit](https://github.com/elastic/elasticsearch-rails/commit/63c24c9fe48a74d00c65145cc55c32f4c6907448) + +## 7.0.0 * Update test tasks and travis (#840) * `respond_to_missing?` to silence Ruby 2.4 warnings (#838) @@ -7,7 +13,6 @@ * Only execute update if document attributes is not empty (#862) * Remove bundler version requirement in gemspec files * 7.0 support (#875) -* Update version to 7.0.0.pre ### ActiveModel diff --git a/elasticsearch-model/lib/elasticsearch/model/version.rb b/elasticsearch-model/lib/elasticsearch/model/version.rb index 4d6e36d2e..cc92865fe 100644 --- a/elasticsearch-model/lib/elasticsearch/model/version.rb +++ b/elasticsearch-model/lib/elasticsearch/model/version.rb @@ -17,6 +17,6 @@ module Elasticsearch module Model - VERSION = "7.0.0" + VERSION = "7.1.0" end end diff --git a/elasticsearch-persistence/elasticsearch-persistence.gemspec b/elasticsearch-persistence/elasticsearch-persistence.gemspec index fd2c6fa95..ea21fadb4 100644 --- a/elasticsearch-persistence/elasticsearch-persistence.gemspec +++ b/elasticsearch-persistence/elasticsearch-persistence.gemspec @@ -41,7 +41,7 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 1.9.3" s.add_dependency "elasticsearch", '~> 7' - s.add_dependency "elasticsearch-model", '7.0.0' + s.add_dependency "elasticsearch-model", '7.1.0' s.add_dependency "activesupport", '> 4' s.add_dependency "activemodel", '> 4' s.add_dependency "hashie" diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb index 2953d86a6..e5ba66085 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb @@ -17,6 +17,6 @@ module Elasticsearch module Persistence - VERSION = '7.0.0' + VERSION = '7.1.0' end end diff --git a/elasticsearch-rails/lib/elasticsearch/rails/version.rb b/elasticsearch-rails/lib/elasticsearch/rails/version.rb index 6d5c428e3..23cddcf6f 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/version.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/version.rb @@ -17,6 +17,6 @@ module Elasticsearch module Rails - VERSION = "7.0.0" + VERSION = "7.1.0" end end From 80f85905c03e4b426794129463c8fa512e2757e1 Mon Sep 17 00:00:00 2001 From: Chris Yuska Date: Fri, 8 May 2020 17:12:33 -0400 Subject: [PATCH 012/113] fix: Ruby 2.7 deprecation warning on find_in_batches --- .../lib/elasticsearch/model/adapters/active_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb b/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb index 87a9e2ea7..dfa109161 100644 --- a/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb +++ b/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb @@ -102,7 +102,7 @@ def __find_in_batches(options={}, &block) scope = scope.__send__(named_scope) if named_scope scope = scope.instance_exec(&query) if query - scope.find_in_batches(options) do |batch| + scope.find_in_batches(**options) do |batch| batch = self.__send__(preprocess, batch) if preprocess yield(batch) if batch.present? end From 1c3226d8186af6e8446fa5091f5b27760c29f896 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Fri, 15 May 2020 16:47:50 +0100 Subject: [PATCH 013/113] Update README for generating app with template Related: #938 --- README.md | 15 ++++++++++++++- elasticsearch-rails/README.md | 5 +++-- .../lib/rails/templates/01-basic.rb | 4 ++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 48f5e6f60..4ef960d00 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,20 @@ Article.import ``` You can generate a simple Ruby on Rails application with a single command -(see the [other available templates](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-rails#rails-application-templates)): +(see the [other available templates](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-rails#rails-application-templates)). You'll need to have an Elasticsearch cluster running on your system before generating the app. The easiest way of getting this set up is by running it with Docker with this command: + +```bash + docker run \ + --name elasticsearch-rails-searchapp \ + --publish 9200:9200 \ + --env "discovery.type=single-node" \ + --env "cluster.name=elasticsearch-rails" \ + --env "cluster.routing.allocation.disk.threshold_enabled=false" \ + --rm \ + docker.elastic.co/elasticsearch/elasticsearch-oss:7.6.0 +``` + +Once Elasticsearch is running, you can generate the simple app with this command: ```bash rails new searchapp --skip --skip-bundle --template https://raw.github.com/elasticsearch/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/01-basic.rb diff --git a/elasticsearch-rails/README.md b/elasticsearch-rails/README.md index deb781f3c..687d016ae 100644 --- a/elasticsearch-rails/README.md +++ b/elasticsearch-rails/README.md @@ -17,6 +17,7 @@ is compatible with the Elasticsearch `master` branch, therefore, with the next m | 2.x | → | 2.x | | 5.x | → | 5.x | | 6.x | → | 6.x | +| 7.x | → | 7.x | | master | → | master | ## Installation @@ -98,8 +99,8 @@ You should see the duration of the request to Elasticsearch as part of each log ### Rails Application Templates You can generate a fully working example Ruby on Rails application, with an `Article` model and a search form, -to play with (it even downloads _Elasticsearch_ itself, generates the application skeleton and leaves you with -a _Git_ repository to explore the steps and the code) with the +to play with (it generates the application skeleton and leaves you with a _Git_ repository to explore the +steps and the code) with the [`01-basic.rb`](https://github.com/elastic/elasticsearch-rails/blob/master/elasticsearch-rails/lib/rails/templates/01-basic.rb) template: ```bash diff --git a/elasticsearch-rails/lib/rails/templates/01-basic.rb b/elasticsearch-rails/lib/rails/templates/01-basic.rb index 154eb1f90..e7305ecd5 100644 --- a/elasticsearch-rails/lib/rails/templates/01-basic.rb +++ b/elasticsearch-rails/lib/rails/templates/01-basic.rb @@ -44,7 +44,7 @@ # ----- Check for Elasticsearch ------------------------------------------------------------------- -required_elasticsearch_version = '6' +required_elasticsearch_version = '7' docker_command =<<-CMD.gsub(/\s{1,}/, ' ').strip docker run \ @@ -54,7 +54,7 @@ --env "cluster.name=elasticsearch-rails" \ --env "cluster.routing.allocation.disk.threshold_enabled=false" \ --rm \ - docker.elastic.co/elasticsearch/elasticsearch-oss:6.4.0 + docker.elastic.co/elasticsearch/elasticsearch-oss:7.6.0 CMD begin From e0d46a864db2d1287afee1d88280a838df261bcb Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 26 May 2020 09:39:04 +0100 Subject: [PATCH 014/113] Add headers to missing file --- elasticsearch-rails/spec/lograge_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/elasticsearch-rails/spec/lograge_spec.rb b/elasticsearch-rails/spec/lograge_spec.rb index 4503b538e..6ab0763f9 100644 --- a/elasticsearch-rails/spec/lograge_spec.rb +++ b/elasticsearch-rails/spec/lograge_spec.rb @@ -1,3 +1,20 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + # Licensed to Elasticsearch B.V. under one or more contributor # license agreements. See the NOTICE file distributed with From 8628e73a15b12f84dbfba93c851d90fe2b08332f Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 29 Jun 2020 15:11:51 +0100 Subject: [PATCH 015/113] Linting --- Rakefile | 12 +-- elasticsearch-model/Gemfile | 2 +- .../elasticsearch-model.gemspec | 76 +++++++++---------- elasticsearch-persistence/Gemfile | 6 +- elasticsearch-rails/Gemfile | 10 ++- .../elasticsearch-rails.gemspec | 69 +++++++++-------- 6 files changed, 91 insertions(+), 84 deletions(-) diff --git a/Rakefile b/Rakefile index 40f26188b..9e3181a68 100644 --- a/Rakefile +++ b/Rakefile @@ -17,10 +17,10 @@ require 'pathname' -subprojects = [ 'elasticsearch-rails', 'elasticsearch-persistence' ] +subprojects = ['elasticsearch-rails', 'elasticsearch-persistence'] subprojects << 'elasticsearch-model' unless defined?(JRUBY_VERSION) -__current__ = Pathname( File.expand_path('..', __FILE__) ) +__current__ = Pathname(File.expand_path(__dir__)) def admin_client $admin_client ||= begin @@ -50,7 +50,7 @@ def admin_client end task :default do - system "rake --tasks" + system 'rake --tasks' end task :subprojects do @@ -62,11 +62,11 @@ task :subprojects do end end -desc "Alias for `bundle:install`" -task :bundle => 'bundle:install' +desc 'Alias for `bundle:install`' +task bundle: 'bundle:install' namespace :bundle do - desc "Run `bundle install` in all subprojects" + desc 'Run `bundle install` in all subprojects' task :install do subprojects.each do |project| puts '-'*80 diff --git a/elasticsearch-model/Gemfile b/elasticsearch-model/Gemfile index 6a70a3206..664ab4569 100644 --- a/elasticsearch-model/Gemfile +++ b/elasticsearch-model/Gemfile @@ -21,6 +21,6 @@ source 'https://rubygems.org' gemspec group :development, :testing do - gem 'rspec' gem 'pry-nav' + gem 'rspec' end diff --git a/elasticsearch-model/elasticsearch-model.gemspec b/elasticsearch-model/elasticsearch-model.gemspec index 1fe334041..a0cadd2b2 100644 --- a/elasticsearch-model/elasticsearch-model.gemspec +++ b/elasticsearch-model/elasticsearch-model.gemspec @@ -16,56 +16,54 @@ # under the License. # coding: utf-8 -lib = File.expand_path('../lib', __FILE__) + +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'elasticsearch/model/version' Gem::Specification.new do |s| - s.name = "elasticsearch-model" + s.name = 'elasticsearch-model' s.version = Elasticsearch::Model::VERSION - s.authors = ["Karel Minarik"] - s.email = ["karel.minarik@elasticsearch.org"] - s.description = "ActiveModel/Record integrations for Elasticsearch." - s.summary = "ActiveModel/Record integrations for Elasticsearch." - s.homepage = "https://github.com/elasticsearch/elasticsearch-rails/" - s.license = "Apache 2" + s.authors = ['Karel Minarik'] + s.email = ['karel.minarik@elasticsearch.org'] + s.description = 'ActiveModel/Record integrations for Elasticsearch.' + s.summary = 'ActiveModel/Record integrations for Elasticsearch.' + s.homepage = 'https://github.com/elasticsearch/elasticsearch-rails/' + s.license = 'Apache 2' s.files = `git ls-files`.split($/) s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } s.test_files = s.files.grep(%r{^(test|spec|features)/}) - s.require_paths = ["lib"] - - s.extra_rdoc_files = [ "README.md", "LICENSE.txt" ] - s.rdoc_options = [ "--charset=UTF-8" ] - - s.required_ruby_version = ">= 1.9.3" - - s.add_dependency "elasticsearch", '> 1' - s.add_dependency "activesupport", '> 3' - s.add_dependency "hashie" - - s.add_development_dependency "bundler" - s.add_development_dependency "rake", "~> 12" - - s.add_development_dependency "elasticsearch-extensions" + s.require_paths = ['lib'] - s.add_development_dependency "sqlite3" unless defined?(JRUBY_VERSION) - s.add_development_dependency "activemodel", "> 3" + s.extra_rdoc_files = ['README.md', 'LICENSE.txt'] + s.rdoc_options = ['--charset=UTF-8'] - s.add_development_dependency "oj" unless defined?(JRUBY_VERSION) - s.add_development_dependency "kaminari" - s.add_development_dependency "will_paginate" + s.required_ruby_version = '>= 2.4' - s.add_development_dependency "minitest" - s.add_development_dependency "test-unit" - s.add_development_dependency "shoulda-context" - s.add_development_dependency "mocha" - s.add_development_dependency "turn" - s.add_development_dependency "yard" - s.add_development_dependency "ruby-prof" unless defined?(JRUBY_VERSION) - s.add_development_dependency "pry" + s.add_dependency 'activesupport', '> 3' + s.add_dependency 'elasticsearch', '> 1' + s.add_dependency 'hashie' - s.add_development_dependency "simplecov" - s.add_development_dependency "cane" - s.add_development_dependency "require-prof" + s.add_development_dependency 'activemodel', '> 3' + s.add_development_dependency 'bundler' + s.add_development_dependency 'cane' + s.add_development_dependency 'elasticsearch-extensions' + s.add_development_dependency 'kaminari' + s.add_development_dependency 'minitest' + s.add_development_dependency 'mocha' + s.add_development_dependency 'pry' + s.add_development_dependency 'rake', '~> 12' + s.add_development_dependency 'require-prof' + s.add_development_dependency 'shoulda-context' + s.add_development_dependency 'simplecov' + s.add_development_dependency 'test-unit' + s.add_development_dependency 'turn' + s.add_development_dependency 'will_paginate' + s.add_development_dependency 'yard' + unless defined?(JRUBY_VERSION) + s.add_development_dependency 'oj' + s.add_development_dependency 'ruby-prof' + s.add_development_dependency 'sqlite3' + end end diff --git a/elasticsearch-persistence/Gemfile b/elasticsearch-persistence/Gemfile index 72fbae110..af517a160 100644 --- a/elasticsearch-persistence/Gemfile +++ b/elasticsearch-persistence/Gemfile @@ -20,11 +20,13 @@ source 'https://rubygems.org' # Specify your gem's dependencies in elasticsearch-persistence.gemspec gemspec -gem 'elasticsearch-model', :path => File.expand_path("../../elasticsearch-model", __FILE__), :require => false +gem 'elasticsearch-model', + path: File.expand_path('../elasticsearch-model', __dir__), + require: false gem 'virtus' group :development, :testing do - gem 'rspec' gem 'pry-nav' + gem 'rspec' end diff --git a/elasticsearch-rails/Gemfile b/elasticsearch-rails/Gemfile index ac2583628..6787846e4 100644 --- a/elasticsearch-rails/Gemfile +++ b/elasticsearch-rails/Gemfile @@ -20,12 +20,16 @@ source 'https://rubygems.org' # Specify your gem's dependencies in elasticsearch-rails.gemspec gemspec -gem 'elasticsearch-model', :path => File.expand_path("../../elasticsearch-model", __FILE__), :require => false -gem 'elasticsearch-persistence', :path => File.expand_path("../../elasticsearch-persistence", __FILE__), :require => false +gem 'elasticsearch-model', + path: File.expand_path('../elasticsearch-model', __dir__), + require: false +gem 'elasticsearch-persistence', + path: File.expand_path('../elasticsearch-persistence', __dir__), + require: false group :development, :testing do - gem 'rspec' gem 'pry-nav' + gem 'rspec' gem 'sqlite3' unless defined?(JRUBY_VERSION) end diff --git a/elasticsearch-rails/elasticsearch-rails.gemspec b/elasticsearch-rails/elasticsearch-rails.gemspec index 1af576d9f..400004a77 100644 --- a/elasticsearch-rails/elasticsearch-rails.gemspec +++ b/elasticsearch-rails/elasticsearch-rails.gemspec @@ -21,45 +21,48 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'elasticsearch/rails/version' Gem::Specification.new do |s| - s.name = "elasticsearch-rails" + s.name = 'elasticsearch-rails' s.version = Elasticsearch::Rails::VERSION - s.authors = ["Karel Minarik"] - s.email = ["karel.minarik@elasticsearch.org"] - s.description = "Ruby on Rails integrations for Elasticsearch." - s.summary = "Ruby on Rails integrations for Elasticsearch." - s.homepage = "https://github.com/elasticsearch/elasticsearch-rails/" - s.license = "Apache 2" + s.authors = ['Karel Minarik'] + s.email = ['karel.minarik@elasticsearch.org'] + s.description = 'Ruby on Rails integrations for Elasticsearch.' + s.summary = 'Ruby on Rails integrations for Elasticsearch.' + s.homepage = 'https://github.com/elasticsearch/elasticsearch-rails/' + s.license = 'Apache 2' + s.metadata = { + 'homepage_uri' => 'https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/ruby_on_rails.html', + 'changelog_uri' => 'https://github.com/elastic/elasticsearch-rails/blob/master/CHANGELOG.md', + 'source_code_uri' => 'https://github.com/elastic/elasticsearch-rails/', + 'bug_tracker_uri' => 'https://github.com/elastic/elasticsearch-rails/issues' + } s.files = `git ls-files`.split($/) s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } s.test_files = s.files.grep(%r{^(test|spec|features)/}) - s.require_paths = ["lib"] + s.require_paths = ['lib'] - s.extra_rdoc_files = [ "README.md", "LICENSE.txt" ] - s.rdoc_options = [ "--charset=UTF-8" ] + s.extra_rdoc_files = ['README.md', 'LICENSE.txt'] + s.rdoc_options = ['--charset=UTF-8'] - s.required_ruby_version = ">= 1.9.3" + s.required_ruby_version = '>= 2.4' - s.add_development_dependency "bundler" - s.add_development_dependency "rake", "~> 12" - - s.add_development_dependency "elasticsearch-extensions" - - s.add_development_dependency "rails", ">= 3.1" - - s.add_development_dependency "lograge" - - s.add_development_dependency "minitest" - s.add_development_dependency "test-unit" - s.add_development_dependency "shoulda-context" - s.add_development_dependency "mocha" - s.add_development_dependency "turn" - s.add_development_dependency "yard" - s.add_development_dependency "oj" unless defined?(JRUBY_VERSION) - s.add_development_dependency "ruby-prof" unless defined?(JRUBY_VERSION) - s.add_development_dependency "pry" - - s.add_development_dependency "simplecov" - s.add_development_dependency "cane" - s.add_development_dependency "require-prof" + s.add_development_dependency 'bundler' + s.add_development_dependency 'cane' + s.add_development_dependency 'elasticsearch-extensions' + s.add_development_dependency 'lograge' + s.add_development_dependency 'minitest' + s.add_development_dependency 'mocha' + s.add_development_dependency 'pry' + s.add_development_dependency 'rails', '> 3.1' + s.add_development_dependency 'rake', '~> 12' + s.add_development_dependency 'require-prof' + s.add_development_dependency 'shoulda-context' + s.add_development_dependency 'simplecov' + s.add_development_dependency 'test-unit' + s.add_development_dependency 'turn' + s.add_development_dependency 'yard' + unless defined?(JRUBY_VERSION) + s.add_development_dependency 'oj' + s.add_development_dependency 'ruby-prof' + end end From fdeac4bbde7bd3b841476c1b5a0a43586a065cec Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 29 Jun 2020 17:11:40 +0100 Subject: [PATCH 016/113] Update README, remove Virtus (unmaintained) --- README.md | 44 +++++++++++++---------------- elasticsearch-model/README.md | 34 ++++++++-------------- elasticsearch-persistence/Gemfile | 2 -- elasticsearch-persistence/README.md | 7 ++--- 4 files changed, 33 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 4ef960d00..b0d4da164 100644 --- a/README.md +++ b/README.md @@ -17,28 +17,6 @@ This repository contains various Ruby and Rails integrations for [Elasticsearch] Elasticsearch client and Ruby API is provided by the **[elasticsearch-ruby](https://github.com/elastic/elasticsearch-ruby)** project. -## Compatibility - -The libraries are compatible with Ruby 2.4 and higher. - -The version numbers follow the Elasticsearch major versions. The `master` branch is compatible with -the Elasticsearch `master` branch, therefore, with the next major version. - -| Rubygem | | Elasticsearch | -|:-------------:|:-:| :-----------: | -| 0.1 | → | 1.x | -| 2.x | → | 2.x | -| 5.x | → | 5.x | -| 6.x | → | 6.x | -| 7.x | → | 7.x | -| master | → | master | - -Use a release that matches the major version of Elasticsearch in your stack. Each client version is -backwards compatible with all minor versions of the same major version. - -Check out [Elastic product end of life dates](https://www.elastic.co/support/eol) -to learn which releases are still actively supported and tested. - ## Installation Install each library from [Rubygems](https://rubygems.org/gems/elasticsearch): @@ -53,6 +31,24 @@ gem 'elasticsearch-model', github: 'elastic/elasticsearch-rails', branch: '5.x' gem 'elasticsearch-rails', github: 'elastic/elasticsearch-rails', branch: '5.x' ``` +## Compatibility + +The libraries are compatible with Ruby 2.4 and higher. + +The version numbers follow the Elasticsearch major versions. The `master` branch is compatible with the latest Elasticsearch stack stable release. + +| Rubygem | | Elasticsearch | +|:-------------:|:-:| :-----------: | +| 0.1 | → | 1.x | +| 2.x | → | 2.x | +| 5.x | → | 5.x | +| 6.x | → | 6.x | +| master | → | 7.x | + +Use a release that matches the major version of Elasticsearch in your stack. Each client version is backwards compatible with all minor versions of the same major version. + +Check out [Elastic product end of life dates](https://www.elastic.co/support/eol) to learn which releases are still actively supported and tested. + ## Usage This project is split into three separate gems: @@ -108,10 +104,8 @@ rails new searchapp --skip --skip-bundle --template https://raw.github.com/elast Example of using Elasticsearch as a repository for a Ruby domain object: ```ruby -require 'virtus' class Article - include Virtus.model - attribute :title, String + attr_accessor :title end require 'elasticsearch/persistence' diff --git a/elasticsearch-model/README.md b/elasticsearch-model/README.md index 72662f4ee..bd1b3927b 100644 --- a/elasticsearch-model/README.md +++ b/elasticsearch-model/README.md @@ -1,18 +1,14 @@ # Elasticsearch::Model -The `elasticsearch-model` library builds on top of the -the [`elasticsearch`](https://github.com/elastic/elasticsearch-ruby) library. +The `elasticsearch-model` library builds on top of the the [`elasticsearch`](https://github.com/elastic/elasticsearch-ruby) library. -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. +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. ## Compatibility -This library is compatible with Ruby 1.9.3 and higher. +This library is compatible with Ruby 2.4 and higher. -The library version numbers follow the Elasticsearch major versions, and the `master` branch -is compatible with the Elasticsearch `master` branch, therefore, with the next major version. +The library version numbers follow the Elasticsearch major versions. The `master` branch is compatible with the latest Elasticsearch stack stable release. | Rubygem | | Elasticsearch | |:-------------:|:-:| :-----------: | @@ -20,7 +16,7 @@ is compatible with the Elasticsearch `master` branch, therefore, with the next m | 2.x | → | 2.x | | 5.x | → | 5.x | | 6.x | → | 6.x | -| master | → | master | +| master | → | 7.x | ## Installation @@ -73,9 +69,7 @@ This will extend the model with functionality related to Elasticsearch. #### Feature Extraction Pattern -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: +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: ```ruby # In: app/models/concerns/searchable.rb @@ -290,11 +284,8 @@ NOTE: It is _not_ possible to chain other methods on top of the `records` object #### Pagination -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. -(The pagination gems must be added before the Elasticsearch gems in your Gemfile, -or loaded first in your application.) +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. +(The pagination gems must be added before the Elasticsearch gems in your Gemfile, or loaded first in your application.) If Kaminari or WillPaginate is loaded, use the familiar paging methods: @@ -322,8 +313,7 @@ Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model #### The Elasticsearch DSL -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: +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: ```ruby response = Article.search query: { match: { title: "Fox Dogs" } }, @@ -333,8 +323,7 @@ response.results.first.highlight.title # ["Quick brown fox"] ``` -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: +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: ```ruby require 'jbuilder' @@ -354,8 +343,7 @@ response.results.first.title # => "Quick brown fox" ``` -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 -the Elasticsearch Query DSL: +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 the Elasticsearch Query DSL: ```ruby require 'elasticsearch/dsl' diff --git a/elasticsearch-persistence/Gemfile b/elasticsearch-persistence/Gemfile index af517a160..439b88c36 100644 --- a/elasticsearch-persistence/Gemfile +++ b/elasticsearch-persistence/Gemfile @@ -24,8 +24,6 @@ gem 'elasticsearch-model', path: File.expand_path('../elasticsearch-model', __dir__), require: false -gem 'virtus' - group :development, :testing do gem 'pry-nav' gem 'rspec' diff --git a/elasticsearch-persistence/README.md b/elasticsearch-persistence/README.md index 49807186c..1d4fac551 100644 --- a/elasticsearch-persistence/README.md +++ b/elasticsearch-persistence/README.md @@ -4,10 +4,9 @@ Persistence layer for Ruby domain objects in Elasticsearch, using the Repository ## Compatibility -This library is compatible with Ruby 1.9.3 and higher. +This library is compatible with Ruby 2.4 and higher. -The library version numbers follow the Elasticsearch major versions, and the `master` branch -is compatible with the Elasticsearch `master` branch, therefore, with the next major version. +The library version numbers follow the Elasticsearch major versions. The `master` branch is compatible with the latest Elasticsearch stack stable release. | Rubygem | | Elasticsearch | |:-------------:|:-:| :-----------: | @@ -15,7 +14,7 @@ is compatible with the Elasticsearch `master` branch, therefore, with the next m | 2.x | → | 2.x | | 5.x | → | 5.x | | 6.x | → | 6.x | -| master | → | master | +| master | → | 7.x | ## Installation From a8311823a82b32a06da7f215b8c2ed4d1dd6c949 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 29 Jun 2020 14:37:16 +0100 Subject: [PATCH 017/113] [CI] Updates Elasticsearch version in Travis --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d829ee013..7ae3e4370 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,8 @@ # ----------------------------------------------------------------------------- dist: trusty - sudo: required - language: ruby - services: - mongodb @@ -50,7 +47,7 @@ matrix: env: global: - - ELASTICSEARCH_VERSION=7.6.2 + - ELASTICSEARCH_VERSION=7.8.0 - TEST_ES_SERVER=http://localhost:9250 - TEST_CLUSTER_PORT=9250 - QUIET=true From 239af1c0caa81b82f9b8805947aa94fa39be79c2 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 29 Jun 2020 14:47:23 +0100 Subject: [PATCH 018/113] [CI] Adds GitHub Actions --- .github/workflows/tests.yml | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..4bcdaf1af --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,41 @@ +name: master +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + test-master: + env: + TEST_ES_SERVER: http://localhost:9200 + strategy: + fail-fast: false + matrix: + ruby: [ 2.5, 2.6, 2.7, jruby ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Increase system limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + - uses: elastic/elastic-github-actions/elasticsearch@master + with: + stack-version: 7.8.0 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - name: Bundle + run: | + sudo apt-get install libsqlite3-dev + gem install bundler + bundle install + bundle exec rake bundle:clean + bundle exec rake bundle:install + - name: Test + run: bundle exec rake test:all + From 4c44370c9f4f5f6d764b9dca662be8c0522d1f1a Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 30 Jun 2020 14:24:43 +0100 Subject: [PATCH 019/113] [CI] Don't test Rails 4.0 in model if Ruby > 2.7 --- elasticsearch-model/Rakefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/elasticsearch-model/Rakefile b/elasticsearch-model/Rakefile index b31a4b5dc..02ab0beb7 100644 --- a/elasticsearch-model/Rakefile +++ b/elasticsearch-model/Rakefile @@ -21,7 +21,9 @@ desc 'Run unit tests' task default: 'test:all' task test: 'test:all' -GEMFILES = ['4.0.gemfile', '5.0.gemfile', '6.0.gemfile'] +gemfiles = ['5.0.gemfile', '6.0.gemfile'] +gemfiles << '4.0.gemfile' if RUBY_VERSION < '2.7' +GEMFILES = gemfiles.freeze namespace :bundle do desc 'Install dependencies for all the Gemfiles in /gemfiles. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0' From 10ed5ca03cf297d6bb7b166d45160cc1dcc72aeb Mon Sep 17 00:00:00 2001 From: Michael Chen Date: Wed, 19 Aug 2020 06:01:12 -0700 Subject: [PATCH 020/113] [MODEL] Do not override existing methods (#936) * [MODEL] Do not override existing methods * fix spec to cover this case * Fixes #924 --- elasticsearch-model/lib/elasticsearch/model.rb | 2 +- elasticsearch-model/spec/elasticsearch/model/module_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/elasticsearch-model/lib/elasticsearch/model.rb b/elasticsearch-model/lib/elasticsearch/model.rb index d50308d8d..04adaffc1 100644 --- a/elasticsearch-model/lib/elasticsearch/model.rb +++ b/elasticsearch-model/lib/elasticsearch/model.rb @@ -112,7 +112,7 @@ def self.included(base) # Delegate common methods to the `__elasticsearch__` ClassMethodsProxy, unless they are defined already class << self METHODS.each do |method| - delegate method, to: :__elasticsearch__ unless self.respond_to?(method) + delegate method, to: :__elasticsearch__ unless self.public_instance_methods.include?(method) end end end diff --git a/elasticsearch-model/spec/elasticsearch/model/module_spec.rb b/elasticsearch-model/spec/elasticsearch/model/module_spec.rb index 3f7d682d0..72c90f4c5 100644 --- a/elasticsearch-model/spec/elasticsearch/model/module_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/module_spec.rb @@ -48,6 +48,7 @@ def self.search(query, options={}) end DummyIncludingModel.__send__ :include, Elasticsearch::Model + DummyIncludingModelWithSearchMethodDefined.__send__ :include, Elasticsearch::Model end after(:all) do From b3a34e0cd4e1fed7e6a3dc9cd60f64da353df26d Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 19 Aug 2020 14:12:40 +0100 Subject: [PATCH 021/113] [CI] Run GitHub Actions for 6.x --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4bcdaf1af..a756f8025 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,9 +3,11 @@ on: push: branches: - master + - 6.x pull_request: branches: - master + - 6.x jobs: test-master: env: From eba44426e5a4024ad0d7df8bdc2a1e932cba82d4 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 19 Aug 2020 14:52:04 +0100 Subject: [PATCH 022/113] Selects bigdecimal gem version --- elasticsearch-model/gemfiles/4.0.gemfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/elasticsearch-model/gemfiles/4.0.gemfile b/elasticsearch-model/gemfiles/4.0.gemfile index e7244994a..944568fce 100644 --- a/elasticsearch-model/gemfiles/4.0.gemfile +++ b/elasticsearch-model/gemfiles/4.0.gemfile @@ -26,10 +26,11 @@ gemspec path: '../' gem 'activemodel', '~> 4' gem 'activerecord', '~> 4' -gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION) gem 'mongoid', '~> 5' +gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION) group :development, :testing do - gem 'rspec' + gem 'bigdecimal', '~> 1' gem 'pry-nav' -end \ No newline at end of file + gem 'rspec' +end From df87fef38f6b6c837602371e0228e75a1e5928fa Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 31 Aug 2020 14:13:15 +0100 Subject: [PATCH 023/113] [CI] Adds stalebot configuration --- .github/stale.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 000000000..28276aad3 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,19 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security + - work-in-progress + - backport +# Label to use when marking an issue as stale +staleLabel: stale +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false From 2de67783d2b6927436c0072731fe337fc6677b2b Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 1 Sep 2020 09:04:44 +0100 Subject: [PATCH 024/113] [CI] Migrates tests to GitHub actions, removes Travis CI --- .ci/travis_before_script.sh | 15 ----- .github/workflows/{tests.yml => 2.4.yml} | 13 ++--- .github/workflows/2.5.yml | 40 +++++++++++++ .github/workflows/2.6.yml | 40 +++++++++++++ .github/workflows/2.7.yml | 40 +++++++++++++ .github/workflows/jruby.yml | 40 +++++++++++++ .travis.yml | 71 ------------------------ README.md | 7 ++- elasticsearch-model/Rakefile | 6 +- 9 files changed, 175 insertions(+), 97 deletions(-) delete mode 100755 .ci/travis_before_script.sh rename .github/workflows/{tests.yml => 2.4.yml} (82%) create mode 100644 .github/workflows/2.5.yml create mode 100644 .github/workflows/2.6.yml create mode 100644 .github/workflows/2.7.yml create mode 100644 .github/workflows/jruby.yml delete mode 100644 .travis.yml diff --git a/.ci/travis_before_script.sh b/.ci/travis_before_script.sh deleted file mode 100755 index 547a5a040..000000000 --- a/.ci/travis_before_script.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -if [ "$ELASTICSEARCH_VERSION" == "6.7.1" ] -then - url="https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz" -else - url="https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}-linux-x86_64.tar.gz" -fi - -echo "Downloading elasticsearch from $url" -curl $url | tar xz -C /tmp - -echo "Starting elasticsearch on port ${TEST_CLUSTER_PORT}" -/tmp/elasticsearch-${ELASTICSEARCH_VERSION}/bin/elasticsearch-keystore create -/tmp/elasticsearch-${ELASTICSEARCH_VERSION}/bin/elasticsearch -E http.port=${TEST_CLUSTER_PORT} &> /dev/null & diff --git a/.github/workflows/tests.yml b/.github/workflows/2.4.yml similarity index 82% rename from .github/workflows/tests.yml rename to .github/workflows/2.4.yml index a756f8025..cd2c4dae5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/2.4.yml @@ -1,21 +1,18 @@ -name: master +name: Ruby 2.4 on: push: branches: - master - - 6.x pull_request: branches: - master - - 6.x jobs: - test-master: + tests: env: TEST_ES_SERVER: http://localhost:9200 + RAILS_VERSIONS: '5.0' strategy: fail-fast: false - matrix: - ruby: [ 2.5, 2.6, 2.7, jruby ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -27,10 +24,10 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 7.8.0 + stack-version: 7.9.0 - uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.ruby }} + ruby-version: 2.4 - name: Bundle run: | sudo apt-get install libsqlite3-dev diff --git a/.github/workflows/2.5.yml b/.github/workflows/2.5.yml new file mode 100644 index 000000000..19d432062 --- /dev/null +++ b/.github/workflows/2.5.yml @@ -0,0 +1,40 @@ +name: Ruby 2.5 +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + tests: + env: + TEST_ES_SERVER: http://localhost:9200 + RAILS_VERSIONS: '5.0,6.0' + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Increase system limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + - uses: elastic/elastic-github-actions/elasticsearch@master + with: + stack-version: 7.9.0 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.5 + - name: Bundle + run: | + sudo apt-get install libsqlite3-dev + gem install bundler + bundle install + bundle exec rake bundle:clean + bundle exec rake bundle:install + - name: Test + run: bundle exec rake test:all + diff --git a/.github/workflows/2.6.yml b/.github/workflows/2.6.yml new file mode 100644 index 000000000..da076441e --- /dev/null +++ b/.github/workflows/2.6.yml @@ -0,0 +1,40 @@ +name: Ruby 2.6 +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + tests: + env: + TEST_ES_SERVER: http://localhost:9200 + RAILS_VERSIONS: '5.0,6.0' + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Increase system limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + - uses: elastic/elastic-github-actions/elasticsearch@master + with: + stack-version: 7.9.0 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + - name: Bundle + run: | + sudo apt-get install libsqlite3-dev + gem install bundler + bundle install + bundle exec rake bundle:clean + bundle exec rake bundle:install + - name: Test + run: bundle exec rake test:all + diff --git a/.github/workflows/2.7.yml b/.github/workflows/2.7.yml new file mode 100644 index 000000000..1823e8333 --- /dev/null +++ b/.github/workflows/2.7.yml @@ -0,0 +1,40 @@ +name: Ruby 2.7 +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + tests: + env: + TEST_ES_SERVER: http://localhost:9200 + RAILS_VERSIONS: '5.0,6.0' + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Increase system limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + - uses: elastic/elastic-github-actions/elasticsearch@master + with: + stack-version: 7.9.0 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + - name: Bundle + run: | + sudo apt-get install libsqlite3-dev + gem install bundler + bundle install + bundle exec rake bundle:clean + bundle exec rake bundle:install + - name: Test + run: bundle exec rake test:all + diff --git a/.github/workflows/jruby.yml b/.github/workflows/jruby.yml new file mode 100644 index 000000000..e0dadec1c --- /dev/null +++ b/.github/workflows/jruby.yml @@ -0,0 +1,40 @@ +name: JRuby +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + tests: + env: + TEST_ES_SERVER: http://localhost:9200 + RAILS_VERSIONS: '5.0' + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Increase system limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + - uses: elastic/elastic-github-actions/elasticsearch@master + with: + stack-version: 7.9.0 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: jruby-9.2 + - name: Bundle + run: | + sudo apt-get install libsqlite3-dev + gem install bundler + bundle install + bundle exec rake bundle:clean + bundle exec rake bundle:install + - name: Test + run: bundle exec rake test:all + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7ae3e4370..000000000 --- a/.travis.yml +++ /dev/null @@ -1,71 +0,0 @@ -# ----------------------------------------------------------------------------- -# Configuration file for http://travis-ci.org/elasticsearch/elasticsearch-rails -# ----------------------------------------------------------------------------- - -dist: trusty -sudo: required -language: ruby -services: - - mongodb - -branches: - only: - - master - - 6.x - - 7.x - -matrix: - include: - - rvm: 2.4 - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0 - - - rvm: 2.5 - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0,6.0 - - - rvm: 2.6 - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0,6.0 - - - rvm: 2.7 - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0,6.0 - - - rvm: ruby-head - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0,6.0 - - - rvm: jruby-9.2.9.0 - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0 - - allow_failures: - - rvm: ruby-head - jdk: oraclejdk8 - env: RAILS_VERSIONS=5.0,6.0 - -env: - global: - - ELASTICSEARCH_VERSION=7.8.0 - - TEST_ES_SERVER=http://localhost:9250 - - TEST_CLUSTER_PORT=9250 - - QUIET=true - -before_install: - - source ./.ci/travis_before_script.sh - - gem update --system; - - gem update bundler - - gem --version - - bundle version - -install: - - bundle install - - rake bundle:clean - - rake bundle:install - -script: - - rake test:all - -notifications: - disable: true diff --git a/README.md b/README.md index b0d4da164..220816e6e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ # Elasticsearch -[![Build Status](https://travis-ci.org/elastic/elasticsearch-rails.svg?branch=master)](https://travis-ci.org/elastic/elasticsearch-rails) [![Code Climate](https://codeclimate.com/github/elastic/elasticsearch-rails/badges/gpa.svg)](https://codeclimate.com/github/elastic/elasticsearch-rails) +[![Ruby 2.7](https://github.com/elastic/elasticsearch-rails/workflows/Ruby%202.7/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) +[![Ruby 2.6](https://github.com/elastic/elasticsearch-rails/workflows/Ruby%202.6/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) +[![Ruby 2.5](https://github.com/elastic/elasticsearch-rails/workflows/Ruby%202.5/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) +[![Ruby 2.4](https://github.com/elastic/elasticsearch-rails/workflows/Ruby%202.4/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) +[![JRuby](https://github.com/elastic/elasticsearch-rails/workflows/JRuby/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) +[![Code Climate](https://codeclimate.com/github/elastic/elasticsearch-rails/badges/gpa.svg)](https://codeclimate.com/github/elastic/elasticsearch-rails) This repository contains various Ruby and Rails integrations for [Elasticsearch](http://elasticsearch.org): diff --git a/elasticsearch-model/Rakefile b/elasticsearch-model/Rakefile index 02ab0beb7..3d1ab402a 100644 --- a/elasticsearch-model/Rakefile +++ b/elasticsearch-model/Rakefile @@ -29,13 +29,14 @@ namespace :bundle do desc 'Install dependencies for all the Gemfiles in /gemfiles. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0' task :install do unless defined?(JRUBY_VERSION) - puts '-'*80 + puts '-' * 80 gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map { |v| "#{v}.gemfile"} : GEMFILES gemfiles.each do |gemfile| + puts "GEMFILE: #{gemfile}" Bundler.with_clean_env do sh "bundle install --gemfile #{File.expand_path('../gemfiles/'+gemfile, __FILE__)}" end - puts '-'*80 + puts '-' * 80 end end end @@ -50,6 +51,7 @@ namespace :test do gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map {|v| "#{v}.gemfile"} : GEMFILES puts '-' * 80 gemfiles.each do |gemfile| + puts "GEMFILE: #{gemfile}" sh "BUNDLE_GEMFILE='#{File.expand_path("../gemfiles/#{gemfile}", __FILE__)}' " + " bundle exec rspec" puts '-' * 80 From e4545e4fe2a1ce80009206c831d5740360bad6c2 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 1 Sep 2020 09:28:56 +0100 Subject: [PATCH 025/113] Updates Bundler.with_clean_dev (deprecated) to with_unbundled_env --- elasticsearch-model/Rakefile | 2 +- elasticsearch-persistence/Rakefile | 6 +++--- elasticsearch-rails/Rakefile | 13 ++++++------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/elasticsearch-model/Rakefile b/elasticsearch-model/Rakefile index 3d1ab402a..c2e5c9912 100644 --- a/elasticsearch-model/Rakefile +++ b/elasticsearch-model/Rakefile @@ -33,7 +33,7 @@ namespace :bundle do gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map { |v| "#{v}.gemfile"} : GEMFILES gemfiles.each do |gemfile| puts "GEMFILE: #{gemfile}" - Bundler.with_clean_env do + Bundler.with_unbundled_env do sh "bundle install --gemfile #{File.expand_path('../gemfiles/'+gemfile, __FILE__)}" end puts '-' * 80 diff --git a/elasticsearch-persistence/Rakefile b/elasticsearch-persistence/Rakefile index a49e40051..ec3daf3ca 100644 --- a/elasticsearch-persistence/Rakefile +++ b/elasticsearch-persistence/Rakefile @@ -40,11 +40,11 @@ end namespace :bundle do desc 'Install gem dependencies' task :install do - puts '-'*80 - Bundler.with_clean_env do + puts '-' * 80 + Bundler.with_unbundled_env do sh 'bundle install' end - puts '-'*80 + puts '-' * 80 end end diff --git a/elasticsearch-rails/Rakefile b/elasticsearch-rails/Rakefile index 36cd53074..1a03db185 100644 --- a/elasticsearch-rails/Rakefile +++ b/elasticsearch-rails/Rakefile @@ -18,8 +18,8 @@ require "bundler/gem_tasks" desc "Run unit tests" -task :default => 'test:unit' -task :test => 'test:unit' +task default: 'test:unit' +task test: 'test:unit' # ----- Test tasks ------------------------------------------------------------ @@ -27,24 +27,23 @@ require 'rake/testtask' require 'rspec/core/rake_task' namespace :test do - RSpec::Core::RakeTask.new(:spec) Rake::TestTask.new(:all) do |test| test.verbose = false test.warning = false - test.deps = [ :spec ] unless defined?(JRUBY_VERSION) + test.deps = [:spec] unless defined?(JRUBY_VERSION) end end namespace :bundle do desc 'Install gem dependencies' task :install do - puts '-'*80 - Bundler.with_clean_env do + puts '-' * 80 + Bundler.with_unbundled_env do sh 'bundle install' end - puts '-'*80 + puts '-' * 80 end end From 16a297a56e3d1845cc306c1541794280d4b2fdcc Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 1 Sep 2020 11:22:15 +0100 Subject: [PATCH 026/113] [CI] Test Rails 6 for JRuby --- .github/workflows/jruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jruby.yml b/.github/workflows/jruby.yml index e0dadec1c..fdc9e951b 100644 --- a/.github/workflows/jruby.yml +++ b/.github/workflows/jruby.yml @@ -10,7 +10,7 @@ jobs: tests: env: TEST_ES_SERVER: http://localhost:9200 - RAILS_VERSIONS: '5.0' + RAILS_VERSIONS: '5.0,6.0' strategy: fail-fast: false runs-on: ubuntu-latest From 756a4dae1c51331a54bab8f00b0fcb88b4a480ad Mon Sep 17 00:00:00 2001 From: Fernando Date: Tue, 5 Jan 2021 17:49:50 +0000 Subject: [PATCH 027/113] [CI] Relax stalebot conditions --- .github/stale.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/stale.yml b/.github/stale.yml index 28276aad3..9b77b1806 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,13 +1,14 @@ # Number of days of inactivity before an issue becomes stale -daysUntilStale: 60 +daysUntilStale: 120 # Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 +daysUntilClose: 30 # Issues with these labels will never be considered stale exemptLabels: - pinned - security - work-in-progress - backport + - bug # Label to use when marking an issue as stale staleLabel: stale # Comment to post when marking an issue as stale. Set to `false` to disable From cd9c309b78de443d2e37760998418616ba34276d Mon Sep 17 00:00:00 2001 From: Pierre Chapuis Date: Sat, 6 Feb 2021 11:03:44 +0100 Subject: [PATCH 028/113] deal with `nil` document types in Multimodel --- elasticsearch-model/lib/elasticsearch/model/multimodel.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/multimodel.rb b/elasticsearch-model/lib/elasticsearch/model/multimodel.rb index 2c2306274..f9ef2eaea 100644 --- a/elasticsearch-model/lib/elasticsearch/model/multimodel.rb +++ b/elasticsearch-model/lib/elasticsearch/model/multimodel.rb @@ -85,7 +85,7 @@ def index_name # @return [Array] the list of document types used for retrieving documents # def document_type - models.map { |m| m.document_type } + models.map { |m| m.document_type }.compact.presence end # Get the client common for all models From 65942e3da9cabad2f6965e69c8ef6a0994da9408 Mon Sep 17 00:00:00 2001 From: Takumasa Ochi <4468155+aeroastro@users.noreply.github.com> Date: Tue, 2 Mar 2021 02:08:22 +0900 Subject: [PATCH 029/113] Update dependency to explicitly support version 7 Dependency has been updated to follow Elasticsearch gems' version policy. This improves gem consistency and maintenance efficiency. --- elasticsearch-model/elasticsearch-model.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticsearch-model/elasticsearch-model.gemspec b/elasticsearch-model/elasticsearch-model.gemspec index a0cadd2b2..8f47becd0 100644 --- a/elasticsearch-model/elasticsearch-model.gemspec +++ b/elasticsearch-model/elasticsearch-model.gemspec @@ -42,7 +42,7 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 2.4' s.add_dependency 'activesupport', '> 3' - s.add_dependency 'elasticsearch', '> 1' + s.add_dependency 'elasticsearch', '~> 7' s.add_dependency 'hashie' s.add_development_dependency 'activemodel', '> 3' From 5db9207ca398c5d77f671109360ca7f63e3f2112 Mon Sep 17 00:00:00 2001 From: Takumasa Ochi Date: Tue, 2 Mar 2021 02:35:54 +0900 Subject: [PATCH 030/113] Stop emitting FATAL log when checking existence of indices Passing `ignore: 404` to Elasticsearch::Client can stop FATAL log in addition to stopping exception. This option is supported since the 5.0.4 and 6.0.0 of `elasticsearch-ruby`. https://github.com/elastic/elasticsearch-ruby/blob/36d45f0c12f4e9ef96646f269748ad33b43e974c/CHANGELOG.md#600 https://github.com/elastic/elasticsearch-ruby/blob/36d45f0c12f4e9ef96646f269748ad33b43e974c/CHANGELOG.md#504 This swallowing was implemented following exception catching as follows. https://github.com/elastic/elasticsearch-ruby/commit/9848c977a4cad6ff638b89828a3e6a6c599fe0d7 --- elasticsearch-model/lib/elasticsearch/model/indexing.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/indexing.rb b/elasticsearch-model/lib/elasticsearch/model/indexing.rb index 16ad1b3e4..9659e3408 100644 --- a/elasticsearch-model/lib/elasticsearch/model/indexing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/indexing.rb @@ -270,7 +270,7 @@ def create_index!(options={}) def index_exists?(options={}) target_index = options[:index] || self.index_name - self.client.indices.exists(index: target_index) rescue false + self.client.indices.exists(index: target_index, ignore: 404) end # Deletes the index with corresponding name From ce57cc17e304b0a4af123c1599f37fb892a5d93a Mon Sep 17 00:00:00 2001 From: Takumasa Ochi Date: Tue, 2 Mar 2021 02:43:54 +0900 Subject: [PATCH 031/113] Remove unnecessary exception test on index checking Since we are using `ignore: 404` instead of manual `rescue` at `Elasticsearch::Model::Indexing`, there is no need to stub exceptions in the test. --- .../spec/elasticsearch/model/indexing_spec.rb | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb index 09e7717d5..281865a63 100644 --- a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb @@ -659,36 +659,6 @@ def changes expect(DummyIndexingModel.index_exists?).to be(false) end end - - context 'when the index API raises an error' do - - let(:client) do - double('client').tap do |cl| - expect(cl).to receive(:indices).and_raise(StandardError) - end - end - - it 'returns false' do - expect(DummyIndexingModel.index_exists?).to be(false) - end - end - - context 'when the indices.exists API raises an error' do - - let(:client) do - double('client', indices: indices) - end - - let(:indices) do - double('indices').tap do |ind| - expect(ind).to receive(:exists).and_raise(StandardError) - end - end - - it 'returns false' do - expect(DummyIndexingModel.index_exists?).to be(false) - end - end end describe '#delete_index!' do From ed070b8329ca48b4cb12b513ac81ed78c88acc61 Mon Sep 17 00:00:00 2001 From: Fernando Date: Mon, 1 Mar 2021 22:40:25 +0000 Subject: [PATCH 032/113] Removes dependency on extensions --- Gemfile | 4 +- README.md | 6 +-- Rakefile | 41 +------------------ .../elasticsearch-model.gemspec | 1 - .../elasticsearch-persistence.gemspec | 2 - .../elasticsearch-rails.gemspec | 1 - 6 files changed, 3 insertions(+), 52 deletions(-) diff --git a/Gemfile b/Gemfile index b3f93c953..804c5aae4 100644 --- a/Gemfile +++ b/Gemfile @@ -18,9 +18,7 @@ source 'https://rubygems.org' gem "rake", "~> 12" - -gem 'elasticsearch-extensions' - +gem "elasticsearch" gem "pry" gem "ansi" gem "cane" diff --git a/README.md b/README.md index 220816e6e..96c958674 100644 --- a/README.md +++ b/README.md @@ -160,11 +160,7 @@ You can also unit, integration, or both tests for all sub-projects from the top- rake test:all -The test suite expects an Elasticsearch cluster running on port 9250, and **will delete all the data**. You can launch an isolated, in-memory Elasticsearch cluster with the following Rake task: - - TEST_CLUSTER_COMMAND=/tmp/builds/elasticsearch-2.0.0-SNAPSHOT/bin/elasticsearch TEST_CLUSTER_NODES=1 bundle exec rake test:cluster:start - -See more information in the documentation for the [`elasticsearch-extensions`](https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch-extensions#testcluster) gem. +The test suite expects an Elasticsearch cluster running on port 9250, and **will delete all the data**. ## License diff --git a/Rakefile b/Rakefile index 9e3181a68..ee33d5724 100644 --- a/Rakefile +++ b/Rakefile @@ -16,6 +16,7 @@ # under the License. require 'pathname' +require 'elasticsearch' subprojects = ['elasticsearch-rails', 'elasticsearch-persistence'] subprojects << 'elasticsearch-model' unless defined?(JRUBY_VERSION) @@ -97,26 +98,6 @@ namespace :test do end end - desc "Run Elasticsearch (Docker)" - task :setup_elasticsearch_docker do - begin - sh <<-COMMAND.gsub(/^\s*/, '').gsub(/\s{1,}/, ' ') - docker run -d=true \ - --env "discovery.type=single-node" \ - --env "cluster.name=elasticsearch-rails" \ - --env "http.port=9200" \ - --env "cluster.routing.allocation.disk.threshold_enabled=false" \ - --publish 9250:9200 \ - --rm \ - docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION} - COMMAND - require 'elasticsearch/extensions/test/cluster' - Elasticsearch::Extensions::Test::Cluster::Cluster.new(version: ENV['ELASTICSEARCH_VERSION'], - number_of_nodes: 1).wait_for_green - rescue - end - end - desc "Setup MongoDB (Docker)" task :setup_mongodb_docker do begin @@ -167,26 +148,6 @@ namespace :test do puts "\n" end end - - namespace :cluster do - desc "Start Elasticsearch nodes for tests" - task :start do - require 'elasticsearch/extensions/test/cluster' - Elasticsearch::Extensions::Test::Cluster.start - end - - desc "Stop Elasticsearch nodes for tests" - task :stop do - require 'elasticsearch/extensions/test/cluster' - Elasticsearch::Extensions::Test::Cluster.stop - end - - task :status do - require 'elasticsearch/extensions/test/cluster' - (puts "\e[31m[!] Test cluster not running\e[0m"; exit(1)) unless Elasticsearch::Extensions::Test::Cluster.running? - Elasticsearch::Extensions::Test::Cluster.__print_cluster_info(ENV['TEST_CLUSTER_PORT'] || 9250) - end - end end diff --git a/elasticsearch-model/elasticsearch-model.gemspec b/elasticsearch-model/elasticsearch-model.gemspec index 8f47becd0..1bad4c5c8 100644 --- a/elasticsearch-model/elasticsearch-model.gemspec +++ b/elasticsearch-model/elasticsearch-model.gemspec @@ -48,7 +48,6 @@ Gem::Specification.new do |s| s.add_development_dependency 'activemodel', '> 3' s.add_development_dependency 'bundler' s.add_development_dependency 'cane' - s.add_development_dependency 'elasticsearch-extensions' s.add_development_dependency 'kaminari' s.add_development_dependency 'minitest' s.add_development_dependency 'mocha' diff --git a/elasticsearch-persistence/elasticsearch-persistence.gemspec b/elasticsearch-persistence/elasticsearch-persistence.gemspec index ea21fadb4..b09aaee03 100644 --- a/elasticsearch-persistence/elasticsearch-persistence.gemspec +++ b/elasticsearch-persistence/elasticsearch-persistence.gemspec @@ -53,8 +53,6 @@ Gem::Specification.new do |s| s.add_development_dependency "rails", '> 4' - s.add_development_dependency "elasticsearch-extensions" - s.add_development_dependency "minitest" s.add_development_dependency "test-unit" s.add_development_dependency "shoulda-context" diff --git a/elasticsearch-rails/elasticsearch-rails.gemspec b/elasticsearch-rails/elasticsearch-rails.gemspec index 400004a77..224e7fa36 100644 --- a/elasticsearch-rails/elasticsearch-rails.gemspec +++ b/elasticsearch-rails/elasticsearch-rails.gemspec @@ -48,7 +48,6 @@ Gem::Specification.new do |s| s.add_development_dependency 'bundler' s.add_development_dependency 'cane' - s.add_development_dependency 'elasticsearch-extensions' s.add_development_dependency 'lograge' s.add_development_dependency 'minitest' s.add_development_dependency 'mocha' From 9232d87a63484fa4b50cf7fa6c274318563eaa1d Mon Sep 17 00:00:00 2001 From: Fernando Date: Fri, 5 Mar 2021 11:00:23 +0000 Subject: [PATCH 033/113] [CI] Refactors GitHub actions --- .github/workflows/2.4.yml | 9 ++++++--- .github/workflows/2.5.yml | 8 ++++++-- .github/workflows/2.6.yml | 9 ++++++--- .github/workflows/2.7.yml | 9 ++++++--- .github/workflows/jruby.yml | 7 ++++--- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.github/workflows/2.4.yml b/.github/workflows/2.4.yml index cd2c4dae5..1702ef461 100644 --- a/.github/workflows/2.4.yml +++ b/.github/workflows/2.4.yml @@ -35,6 +35,9 @@ jobs: bundle install bundle exec rake bundle:clean bundle exec rake bundle:install - - name: Test - run: bundle exec rake test:all - + - name: Test elasticsearch-rails + run: cd elasticsearch-rails && bundle exec rake test:all + - name: Test elasticsearch-persistence + run: cd elasticsearch-persistence && bundle exec rake test:all + - name: Test elasticsearch-model + run: cd elasticsearch-model && bundle exec rake test:all diff --git a/.github/workflows/2.5.yml b/.github/workflows/2.5.yml index 19d432062..39ac86520 100644 --- a/.github/workflows/2.5.yml +++ b/.github/workflows/2.5.yml @@ -35,6 +35,10 @@ jobs: bundle install bundle exec rake bundle:clean bundle exec rake bundle:install - - name: Test - run: bundle exec rake test:all + - name: Test elasticsearch-rails + run: cd elasticsearch-rails && bundle exec rake test:all + - name: Test elasticsearch-persistence + run: cd elasticsearch-persistence && bundle exec rake test:all + - name: Test elasticsearch-model + run: cd elasticsearch-model && bundle exec rake test:all diff --git a/.github/workflows/2.6.yml b/.github/workflows/2.6.yml index da076441e..96fb50532 100644 --- a/.github/workflows/2.6.yml +++ b/.github/workflows/2.6.yml @@ -35,6 +35,9 @@ jobs: bundle install bundle exec rake bundle:clean bundle exec rake bundle:install - - name: Test - run: bundle exec rake test:all - + - name: Test elasticsearch-rails + run: cd elasticsearch-rails && bundle exec rake test:all + - name: Test elasticsearch-persistence + run: cd elasticsearch-persistence && bundle exec rake test:all + - name: Test elasticsearch-model + run: cd elasticsearch-model && bundle exec rake test:all diff --git a/.github/workflows/2.7.yml b/.github/workflows/2.7.yml index 1823e8333..cfd01a632 100644 --- a/.github/workflows/2.7.yml +++ b/.github/workflows/2.7.yml @@ -35,6 +35,9 @@ jobs: bundle install bundle exec rake bundle:clean bundle exec rake bundle:install - - name: Test - run: bundle exec rake test:all - + - name: Test elasticsearch-rails + run: cd elasticsearch-rails && bundle exec rake test:all + - name: Test elasticsearch-persistence + run: cd elasticsearch-persistence && bundle exec rake test:all + - name: Test elasticsearch-model + run: cd elasticsearch-model && bundle exec rake test:all diff --git a/.github/workflows/jruby.yml b/.github/workflows/jruby.yml index fdc9e951b..00a63fe08 100644 --- a/.github/workflows/jruby.yml +++ b/.github/workflows/jruby.yml @@ -35,6 +35,7 @@ jobs: bundle install bundle exec rake bundle:clean bundle exec rake bundle:install - - name: Test - run: bundle exec rake test:all - + - name: Test elasticsearch-rails + run: cd elasticsearch-rails && bundle exec rake test:all + - name: Test elasticsearch-persistence + run: cd elasticsearch-persistence && bundle exec rake test:all From 80822d69a7f33a13fdfc294035bf57fa9777ff17 Mon Sep 17 00:00:00 2001 From: Fernando Date: Fri, 5 Mar 2021 11:13:44 +0000 Subject: [PATCH 034/113] [CI] Update Stack version on GitHub Actions --- .github/workflows/2.4.yml | 2 +- .github/workflows/2.5.yml | 2 +- .github/workflows/2.6.yml | 2 +- .github/workflows/2.7.yml | 2 +- .github/workflows/jruby.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/2.4.yml b/.github/workflows/2.4.yml index 1702ef461..bac506823 100644 --- a/.github/workflows/2.4.yml +++ b/.github/workflows/2.4.yml @@ -24,7 +24,7 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 7.9.0 + stack-version: 7.x-SNAPSHOT - uses: ruby/setup-ruby@v1 with: ruby-version: 2.4 diff --git a/.github/workflows/2.5.yml b/.github/workflows/2.5.yml index 39ac86520..058182561 100644 --- a/.github/workflows/2.5.yml +++ b/.github/workflows/2.5.yml @@ -24,7 +24,7 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 7.9.0 + stack-version: 7.x-SNAPSHOT - uses: ruby/setup-ruby@v1 with: ruby-version: 2.5 diff --git a/.github/workflows/2.6.yml b/.github/workflows/2.6.yml index 96fb50532..d4e7f4345 100644 --- a/.github/workflows/2.6.yml +++ b/.github/workflows/2.6.yml @@ -24,7 +24,7 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 7.9.0 + stack-version: 7.x-SNAPSHOT - uses: ruby/setup-ruby@v1 with: ruby-version: 2.6 diff --git a/.github/workflows/2.7.yml b/.github/workflows/2.7.yml index cfd01a632..514ee02eb 100644 --- a/.github/workflows/2.7.yml +++ b/.github/workflows/2.7.yml @@ -24,7 +24,7 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 7.9.0 + stack-version: 7.x-SNAPSHOT - uses: ruby/setup-ruby@v1 with: ruby-version: 2.7 diff --git a/.github/workflows/jruby.yml b/.github/workflows/jruby.yml index 00a63fe08..6a7569b95 100644 --- a/.github/workflows/jruby.yml +++ b/.github/workflows/jruby.yml @@ -24,7 +24,7 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 7.9.0 + stack-version: 7.x-SNAPSHOT - uses: ruby/setup-ruby@v1 with: ruby-version: jruby-9.2 From a4ec07b2d097545ca41c13686c9cbfc9eab9e639 Mon Sep 17 00:00:00 2001 From: Fernando Date: Fri, 2 Apr 2021 09:02:21 +0100 Subject: [PATCH 035/113] Fixes basic template elasticsearch dependency Fixes #984 --- elasticsearch-rails/lib/rails/templates/01-basic.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticsearch-rails/lib/rails/templates/01-basic.rb b/elasticsearch-rails/lib/rails/templates/01-basic.rb index e7305ecd5..516732893 100644 --- a/elasticsearch-rails/lib/rails/templates/01-basic.rb +++ b/elasticsearch-rails/lib/rails/templates/01-basic.rb @@ -156,7 +156,7 @@ say_status "Rubygems", "Adding Elasticsearch libraries into Gemfile...\n", :yellow puts '-'*80, ''; sleep 0.75 -gem 'elasticsearch', git: 'https://github.com/elasticsearch/elasticsearch-ruby.git' +gem 'elasticsearch' gem 'elasticsearch-model', git: 'https://github.com/elasticsearch/elasticsearch-rails.git' gem 'elasticsearch-rails', git: 'https://github.com/elasticsearch/elasticsearch-rails.git' From 62c5fef5c04a5ecdd4c5da65344dd9c90ac9c7e7 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 26 Apr 2021 16:30:59 +0100 Subject: [PATCH 036/113] [CI] Adds license headers check in GH Actions --- .github/check-license-headers.sh | 40 ++++++++++++++++++++++++++++++++ .github/license-header.txt | 16 +++++++++++++ .github/workflows/license.yml | 10 ++++++++ 3 files changed, 66 insertions(+) create mode 100755 .github/check-license-headers.sh create mode 100644 .github/license-header.txt create mode 100644 .github/workflows/license.yml diff --git a/.github/check-license-headers.sh b/.github/check-license-headers.sh new file mode 100755 index 000000000..e9b43d3d0 --- /dev/null +++ b/.github/check-license-headers.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# Check that source code files in this repo have the appropriate license +# header. + +if [ "$TRACE" != "" ]; then + export PS4='${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' + set -o xtrace +fi +set -o errexit +set -o pipefail + +TOP=$(cd "$(dirname "$0")/.." >/dev/null && pwd) +LICENSE=$(cat .github/license-header.txt) + +function check_license_header { + local f + f=$1 + if ! grep -Fxq "$LICENSE" "$f"; then + echo "check-license-headers: error: '$f' does not have required license header" + return 1 + else + return 0 + fi +} + + +cd "$TOP" +nErrors=0 +for f in $(git ls-files | grep -E '\.rb|Rakefile|\.rake|\.erb|Gemfile'); do + if ! check_license_header $f; then + nErrors=$((nErrors+1)) + fi +done + +if [[ $nErrors -eq 0 ]]; then + exit 0 +else + exit 1 +fi diff --git a/.github/license-header.txt b/.github/license-header.txt new file mode 100644 index 000000000..5b0f712aa --- /dev/null +++ b/.github/license-header.txt @@ -0,0 +1,16 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml new file mode 100644 index 000000000..52dec1652 --- /dev/null +++ b/.github/workflows/license.yml @@ -0,0 +1,10 @@ +name: License headers +on: [pull_request] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check license headers + run: | + ./.github/check-license-headers.sh From 40acb452837b19e539715e13516f22eb2263e0b3 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 26 Apr 2021 16:57:09 +0100 Subject: [PATCH 037/113] License: Updates license header in missing files --- .../lib/rails/templates/index.html.dsl.erb | 18 ++++++++++++++++++ .../lib/rails/templates/index.html.erb | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/elasticsearch-rails/lib/rails/templates/index.html.dsl.erb b/elasticsearch-rails/lib/rails/templates/index.html.dsl.erb index 97a9b8f81..5a55894b8 100644 --- a/elasticsearch-rails/lib/rails/templates/index.html.dsl.erb +++ b/elasticsearch-rails/lib/rails/templates/index.html.dsl.erb @@ -1,3 +1,21 @@ +<%# +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +%>

<%= link_to 'Search New York Times articles', root_path %>

diff --git a/elasticsearch-rails/lib/rails/templates/index.html.erb b/elasticsearch-rails/lib/rails/templates/index.html.erb index 656c1f891..b5bb19319 100644 --- a/elasticsearch-rails/lib/rails/templates/index.html.erb +++ b/elasticsearch-rails/lib/rails/templates/index.html.erb @@ -1,3 +1,21 @@ +<%# +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +%>

<%= link_to 'Search New York Times articles', root_path %>

From 473f8052c4047aa2aa2dfe599af2990056980afa Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 28 Apr 2021 09:05:34 +0100 Subject: [PATCH 038/113] [CI] Updates license headers check in GH Actions --- .github/check-license-headers.sh | 40 -------------------------------- .github/check_license_headers.rb | 33 ++++++++++++++++++++++++++ .github/workflows/license.yml | 5 +++- 3 files changed, 37 insertions(+), 41 deletions(-) delete mode 100755 .github/check-license-headers.sh create mode 100644 .github/check_license_headers.rb diff --git a/.github/check-license-headers.sh b/.github/check-license-headers.sh deleted file mode 100755 index e9b43d3d0..000000000 --- a/.github/check-license-headers.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash - -# Check that source code files in this repo have the appropriate license -# header. - -if [ "$TRACE" != "" ]; then - export PS4='${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' - set -o xtrace -fi -set -o errexit -set -o pipefail - -TOP=$(cd "$(dirname "$0")/.." >/dev/null && pwd) -LICENSE=$(cat .github/license-header.txt) - -function check_license_header { - local f - f=$1 - if ! grep -Fxq "$LICENSE" "$f"; then - echo "check-license-headers: error: '$f' does not have required license header" - return 1 - else - return 0 - fi -} - - -cd "$TOP" -nErrors=0 -for f in $(git ls-files | grep -E '\.rb|Rakefile|\.rake|\.erb|Gemfile'); do - if ! check_license_header $f; then - nErrors=$((nErrors+1)) - fi -done - -if [[ $nErrors -eq 0 ]]; then - exit 0 -else - exit 1 -fi diff --git a/.github/check_license_headers.rb b/.github/check_license_headers.rb new file mode 100644 index 000000000..4c3c21fea --- /dev/null +++ b/.github/check_license_headers.rb @@ -0,0 +1,33 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +LICENSE = File.read('./.github/license-header.txt') +files = `git ls-files | grep -E '\.rb|Rakefile|\.rake|\.erb|Gemfile|gemspec'`.split("\n") +errors = [] + +files.each do |file| + unless File.read(file).include?(LICENSE) + errors << file + puts "#{file} doesn't contain the correct license header" + end +end + +if errors.empty? + puts 'All checked files have the correct license header' +else + exit 1 +end diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml index 52dec1652..d7357e56e 100644 --- a/.github/workflows/license.yml +++ b/.github/workflows/license.yml @@ -5,6 +5,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3 - name: Check license headers run: | - ./.github/check-license-headers.sh + ruby ./.github/check_license_headers.rb From 939bf5d5e26acfdd3ab59d85e7fa5f3b661a7ac3 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 28 Apr 2021 09:46:20 +0100 Subject: [PATCH 039/113] License: Updates license headers --- Gemfile | 2 +- Rakefile | 2 +- elasticsearch-model/Gemfile | 2 +- elasticsearch-model/Rakefile | 2 +- elasticsearch-model/elasticsearch-model.gemspec | 2 +- elasticsearch-model/examples/activerecord_article.rb | 2 +- elasticsearch-model/examples/activerecord_associations.rb | 2 +- elasticsearch-model/examples/activerecord_custom_analyzer.rb | 2 +- .../examples/activerecord_mapping_completion.rb | 2 +- .../examples/activerecord_mapping_edge_ngram.rb | 2 +- elasticsearch-model/examples/couchbase_article.rb | 2 +- elasticsearch-model/examples/datamapper_article.rb | 2 +- elasticsearch-model/examples/mongoid_article.rb | 2 +- elasticsearch-model/examples/ohm_article.rb | 2 +- elasticsearch-model/examples/riak_article.rb | 2 +- elasticsearch-model/lib/elasticsearch/model.rb | 2 +- elasticsearch-model/lib/elasticsearch/model/adapter.rb | 2 +- .../lib/elasticsearch/model/adapters/active_record.rb | 2 +- .../lib/elasticsearch/model/adapters/default.rb | 2 +- .../lib/elasticsearch/model/adapters/mongoid.rb | 2 +- .../lib/elasticsearch/model/adapters/multiple.rb | 2 +- elasticsearch-model/lib/elasticsearch/model/callbacks.rb | 2 +- elasticsearch-model/lib/elasticsearch/model/client.rb | 2 +- .../lib/elasticsearch/model/ext/active_record.rb | 2 +- elasticsearch-model/lib/elasticsearch/model/hash_wrapper.rb | 2 +- elasticsearch-model/lib/elasticsearch/model/importing.rb | 2 +- elasticsearch-model/lib/elasticsearch/model/indexing.rb | 2 +- elasticsearch-model/lib/elasticsearch/model/multimodel.rb | 2 +- elasticsearch-model/lib/elasticsearch/model/naming.rb | 2 +- elasticsearch-model/lib/elasticsearch/model/proxy.rb | 2 +- elasticsearch-model/lib/elasticsearch/model/response.rb | 2 +- .../lib/elasticsearch/model/response/aggregations.rb | 2 +- elasticsearch-model/lib/elasticsearch/model/response/base.rb | 2 +- .../lib/elasticsearch/model/response/pagination.rb | 2 +- .../lib/elasticsearch/model/response/pagination/kaminari.rb | 2 +- .../elasticsearch/model/response/pagination/will_paginate.rb | 2 +- .../lib/elasticsearch/model/response/records.rb | 2 +- .../lib/elasticsearch/model/response/result.rb | 2 +- .../lib/elasticsearch/model/response/results.rb | 2 +- .../lib/elasticsearch/model/response/suggestions.rb | 2 +- elasticsearch-model/lib/elasticsearch/model/searching.rb | 2 +- elasticsearch-model/lib/elasticsearch/model/serializing.rb | 2 +- elasticsearch-model/lib/elasticsearch/model/version.rb | 2 +- elasticsearch-model/spec/elasticsearch/model/adapter_spec.rb | 2 +- .../model/adapters/active_record/associations_spec.rb | 2 +- .../elasticsearch/model/adapters/active_record/basic_spec.rb | 2 +- .../model/adapters/active_record/dynamic_index_name_spec.rb | 2 +- .../elasticsearch/model/adapters/active_record/import_spec.rb | 2 +- .../model/adapters/active_record/multi_model_spec.rb | 2 +- .../model/adapters/active_record/namespaced_model_spec.rb | 2 +- .../model/adapters/active_record/pagination_spec.rb | 2 +- .../model/adapters/active_record/parent_child_spec.rb | 2 +- .../model/adapters/active_record/serialization_spec.rb | 2 +- .../spec/elasticsearch/model/adapters/active_record_spec.rb | 2 +- .../spec/elasticsearch/model/adapters/default_spec.rb | 2 +- .../spec/elasticsearch/model/adapters/mongoid/basic_spec.rb | 2 +- .../elasticsearch/model/adapters/mongoid/multi_model_spec.rb | 2 +- .../spec/elasticsearch/model/adapters/mongoid_spec.rb | 2 +- .../spec/elasticsearch/model/adapters/multiple_spec.rb | 2 +- .../spec/elasticsearch/model/callbacks_spec.rb | 2 +- elasticsearch-model/spec/elasticsearch/model/client_spec.rb | 2 +- .../spec/elasticsearch/model/hash_wrapper_spec.rb | 2 +- .../spec/elasticsearch/model/importing_spec.rb | 2 +- elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb | 2 +- elasticsearch-model/spec/elasticsearch/model/module_spec.rb | 2 +- .../spec/elasticsearch/model/multimodel_spec.rb | 2 +- elasticsearch-model/spec/elasticsearch/model/naming_spec.rb | 2 +- elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb | 2 +- .../spec/elasticsearch/model/response/aggregations_spec.rb | 2 +- .../spec/elasticsearch/model/response/base_spec.rb | 2 +- .../elasticsearch/model/response/pagination/kaminari_spec.rb | 2 +- .../model/response/pagination/will_paginate_spec.rb | 2 +- .../spec/elasticsearch/model/response/records_spec.rb | 2 +- .../spec/elasticsearch/model/response/response_spec.rb | 2 +- .../spec/elasticsearch/model/response/result_spec.rb | 2 +- .../spec/elasticsearch/model/response/results_spec.rb | 2 +- .../spec/elasticsearch/model/searching_search_request_spec.rb | 2 +- .../spec/elasticsearch/model/searching_spec.rb | 2 +- .../spec/elasticsearch/model/serializing_spec.rb | 2 +- elasticsearch-model/spec/spec_helper.rb | 2 +- elasticsearch-model/spec/support/app.rb | 4 ++-- elasticsearch-model/spec/support/app/answer.rb | 4 ++-- elasticsearch-model/spec/support/app/article.rb | 2 +- .../spec/support/app/article_for_pagination.rb | 2 +- elasticsearch-model/spec/support/app/article_no_type.rb | 2 +- .../spec/support/app/article_with_custom_serialization.rb | 2 +- .../spec/support/app/article_with_dynamic_index_name.rb | 2 +- elasticsearch-model/spec/support/app/author.rb | 2 +- elasticsearch-model/spec/support/app/authorship.rb | 2 +- elasticsearch-model/spec/support/app/category.rb | 2 +- elasticsearch-model/spec/support/app/comment.rb | 2 +- elasticsearch-model/spec/support/app/episode.rb | 2 +- elasticsearch-model/spec/support/app/image.rb | 2 +- elasticsearch-model/spec/support/app/import_article.rb | 2 +- elasticsearch-model/spec/support/app/mongoid_article.rb | 2 +- elasticsearch-model/spec/support/app/namespaced_book.rb | 2 +- .../spec/support/app/parent_and_child_searchable.rb | 2 +- elasticsearch-model/spec/support/app/post.rb | 2 +- elasticsearch-model/spec/support/app/question.rb | 2 +- elasticsearch-model/spec/support/app/searchable.rb | 2 +- elasticsearch-model/spec/support/app/series.rb | 2 +- elasticsearch-persistence/Gemfile | 2 +- elasticsearch-persistence/Rakefile | 2 +- elasticsearch-persistence/elasticsearch-persistence.gemspec | 2 +- elasticsearch-persistence/examples/notes/Gemfile | 2 +- elasticsearch-persistence/examples/notes/application.rb | 2 +- elasticsearch-persistence/examples/notes/test.rb | 2 +- elasticsearch-persistence/lib/elasticsearch/persistence.rb | 2 +- .../lib/elasticsearch/persistence/repository.rb | 2 +- .../lib/elasticsearch/persistence/repository/dsl.rb | 2 +- .../lib/elasticsearch/persistence/repository/find.rb | 2 +- .../elasticsearch/persistence/repository/response/results.rb | 2 +- .../lib/elasticsearch/persistence/repository/search.rb | 2 +- .../lib/elasticsearch/persistence/repository/serialize.rb | 2 +- .../lib/elasticsearch/persistence/repository/store.rb | 2 +- .../lib/elasticsearch/persistence/version.rb | 2 +- elasticsearch-persistence/spec/repository/find_spec.rb | 2 +- .../spec/repository/response/results_spec.rb | 2 +- elasticsearch-persistence/spec/repository/search_spec.rb | 2 +- elasticsearch-persistence/spec/repository/serialize_spec.rb | 2 +- elasticsearch-persistence/spec/repository/store_spec.rb | 2 +- elasticsearch-persistence/spec/repository_spec.rb | 2 +- elasticsearch-persistence/spec/spec_helper.rb | 2 +- elasticsearch-rails/Gemfile | 2 +- elasticsearch-rails/Rakefile | 2 +- elasticsearch-rails/elasticsearch-rails.gemspec | 2 +- elasticsearch-rails/lib/elasticsearch/rails.rb | 2 +- .../lib/elasticsearch/rails/instrumentation.rb | 2 +- .../elasticsearch/rails/instrumentation/controller_runtime.rb | 2 +- .../lib/elasticsearch/rails/instrumentation/log_subscriber.rb | 2 +- .../lib/elasticsearch/rails/instrumentation/publishers.rb | 2 +- .../lib/elasticsearch/rails/instrumentation/railtie.rb | 2 +- elasticsearch-rails/lib/elasticsearch/rails/lograge.rb | 2 +- elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb | 2 +- elasticsearch-rails/lib/elasticsearch/rails/version.rb | 2 +- elasticsearch-rails/lib/rails/templates/01-basic.rb | 2 +- elasticsearch-rails/lib/rails/templates/02-pretty.rb | 2 +- elasticsearch-rails/lib/rails/templates/03-expert.rb | 2 +- elasticsearch-rails/lib/rails/templates/04-dsl.rb | 2 +- elasticsearch-rails/lib/rails/templates/05-settings-files.rb | 2 +- elasticsearch-rails/lib/rails/templates/indexer.rb | 2 +- .../lib/rails/templates/search_controller_test.dsl.rb | 2 +- .../lib/rails/templates/search_controller_test.rb | 2 +- elasticsearch-rails/lib/rails/templates/searchable.dsl.rb | 2 +- elasticsearch-rails/lib/rails/templates/searchable.rb | 2 +- elasticsearch-rails/lib/rails/templates/seeds.rb | 2 +- elasticsearch-rails/spec/instrumentation_spec.rb | 2 +- elasticsearch-rails/spec/lograge_spec.rb | 2 +- elasticsearch-rails/spec/spec_helper.rb | 2 +- 149 files changed, 151 insertions(+), 151 deletions(-) diff --git a/Gemfile b/Gemfile index 804c5aae4..255f70850 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/Rakefile b/Rakefile index ee33d5724..a2dd17e69 100644 --- a/Rakefile +++ b/Rakefile @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/Gemfile b/elasticsearch-model/Gemfile index 664ab4569..5a31c3095 100644 --- a/elasticsearch-model/Gemfile +++ b/elasticsearch-model/Gemfile @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/Rakefile b/elasticsearch-model/Rakefile index c2e5c9912..ab1d6cab7 100644 --- a/elasticsearch-model/Rakefile +++ b/elasticsearch-model/Rakefile @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/elasticsearch-model.gemspec b/elasticsearch-model/elasticsearch-model.gemspec index 1bad4c5c8..083938d51 100644 --- a/elasticsearch-model/elasticsearch-model.gemspec +++ b/elasticsearch-model/elasticsearch-model.gemspec @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/examples/activerecord_article.rb b/elasticsearch-model/examples/activerecord_article.rb index 2bd2e1e27..1e584fd2c 100644 --- a/elasticsearch-model/examples/activerecord_article.rb +++ b/elasticsearch-model/examples/activerecord_article.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/examples/activerecord_associations.rb b/elasticsearch-model/examples/activerecord_associations.rb index 79a02aa65..b8100b33b 100644 --- a/elasticsearch-model/examples/activerecord_associations.rb +++ b/elasticsearch-model/examples/activerecord_associations.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/examples/activerecord_custom_analyzer.rb b/elasticsearch-model/examples/activerecord_custom_analyzer.rb index e2a79ef23..886eaab91 100644 --- a/elasticsearch-model/examples/activerecord_custom_analyzer.rb +++ b/elasticsearch-model/examples/activerecord_custom_analyzer.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/examples/activerecord_mapping_completion.rb b/elasticsearch-model/examples/activerecord_mapping_completion.rb index 901d93232..264746180 100644 --- a/elasticsearch-model/examples/activerecord_mapping_completion.rb +++ b/elasticsearch-model/examples/activerecord_mapping_completion.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/examples/activerecord_mapping_edge_ngram.rb b/elasticsearch-model/examples/activerecord_mapping_edge_ngram.rb index b3af42959..c1a714f80 100644 --- a/elasticsearch-model/examples/activerecord_mapping_edge_ngram.rb +++ b/elasticsearch-model/examples/activerecord_mapping_edge_ngram.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/examples/couchbase_article.rb b/elasticsearch-model/examples/couchbase_article.rb index b7372a2d0..cfbab22d2 100644 --- a/elasticsearch-model/examples/couchbase_article.rb +++ b/elasticsearch-model/examples/couchbase_article.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/examples/datamapper_article.rb b/elasticsearch-model/examples/datamapper_article.rb index 0c483a005..d29460966 100644 --- a/elasticsearch-model/examples/datamapper_article.rb +++ b/elasticsearch-model/examples/datamapper_article.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/examples/mongoid_article.rb b/elasticsearch-model/examples/mongoid_article.rb index 01d6e5295..e2f3ae464 100644 --- a/elasticsearch-model/examples/mongoid_article.rb +++ b/elasticsearch-model/examples/mongoid_article.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/examples/ohm_article.rb b/elasticsearch-model/examples/ohm_article.rb index 52091083c..1c50877f8 100644 --- a/elasticsearch-model/examples/ohm_article.rb +++ b/elasticsearch-model/examples/ohm_article.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/examples/riak_article.rb b/elasticsearch-model/examples/riak_article.rb index 2ff12d9bd..8fd024e41 100644 --- a/elasticsearch-model/examples/riak_article.rb +++ b/elasticsearch-model/examples/riak_article.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model.rb b/elasticsearch-model/lib/elasticsearch/model.rb index 04adaffc1..fe9c33047 100644 --- a/elasticsearch-model/lib/elasticsearch/model.rb +++ b/elasticsearch-model/lib/elasticsearch/model.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/adapter.rb b/elasticsearch-model/lib/elasticsearch/model/adapter.rb index 5fa2cd974..cdb0c7d0e 100644 --- a/elasticsearch-model/lib/elasticsearch/model/adapter.rb +++ b/elasticsearch-model/lib/elasticsearch/model/adapter.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb b/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb index dfa109161..64e0277d8 100644 --- a/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb +++ b/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/adapters/default.rb b/elasticsearch-model/lib/elasticsearch/model/adapters/default.rb index 62cec409c..9891b5d64 100644 --- a/elasticsearch-model/lib/elasticsearch/model/adapters/default.rb +++ b/elasticsearch-model/lib/elasticsearch/model/adapters/default.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/adapters/mongoid.rb b/elasticsearch-model/lib/elasticsearch/model/adapters/mongoid.rb index fb671158b..8626d743c 100644 --- a/elasticsearch-model/lib/elasticsearch/model/adapters/mongoid.rb +++ b/elasticsearch-model/lib/elasticsearch/model/adapters/mongoid.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/adapters/multiple.rb b/elasticsearch-model/lib/elasticsearch/model/adapters/multiple.rb index b4df631f4..30d851043 100644 --- a/elasticsearch-model/lib/elasticsearch/model/adapters/multiple.rb +++ b/elasticsearch-model/lib/elasticsearch/model/adapters/multiple.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/callbacks.rb b/elasticsearch-model/lib/elasticsearch/model/callbacks.rb index 4f0397e29..cff3d1c9d 100644 --- a/elasticsearch-model/lib/elasticsearch/model/callbacks.rb +++ b/elasticsearch-model/lib/elasticsearch/model/callbacks.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/client.rb b/elasticsearch-model/lib/elasticsearch/model/client.rb index 8a49d98f4..01a122440 100644 --- a/elasticsearch-model/lib/elasticsearch/model/client.rb +++ b/elasticsearch-model/lib/elasticsearch/model/client.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/ext/active_record.rb b/elasticsearch-model/lib/elasticsearch/model/ext/active_record.rb index 543329191..2cdbe7f35 100644 --- a/elasticsearch-model/lib/elasticsearch/model/ext/active_record.rb +++ b/elasticsearch-model/lib/elasticsearch/model/ext/active_record.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/hash_wrapper.rb b/elasticsearch-model/lib/elasticsearch/model/hash_wrapper.rb index 50a5727f4..18f4dad23 100644 --- a/elasticsearch-model/lib/elasticsearch/model/hash_wrapper.rb +++ b/elasticsearch-model/lib/elasticsearch/model/hash_wrapper.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/importing.rb b/elasticsearch-model/lib/elasticsearch/model/importing.rb index c0519ef9f..927dd16ee 100644 --- a/elasticsearch-model/lib/elasticsearch/model/importing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/importing.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/indexing.rb b/elasticsearch-model/lib/elasticsearch/model/indexing.rb index 9659e3408..f35ef7342 100644 --- a/elasticsearch-model/lib/elasticsearch/model/indexing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/indexing.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/multimodel.rb b/elasticsearch-model/lib/elasticsearch/model/multimodel.rb index f9ef2eaea..6b5fc2a81 100644 --- a/elasticsearch-model/lib/elasticsearch/model/multimodel.rb +++ b/elasticsearch-model/lib/elasticsearch/model/multimodel.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/naming.rb b/elasticsearch-model/lib/elasticsearch/model/naming.rb index 9ab489db6..c4c796ab2 100644 --- a/elasticsearch-model/lib/elasticsearch/model/naming.rb +++ b/elasticsearch-model/lib/elasticsearch/model/naming.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/proxy.rb b/elasticsearch-model/lib/elasticsearch/model/proxy.rb index 013bdac12..955280fba 100644 --- a/elasticsearch-model/lib/elasticsearch/model/proxy.rb +++ b/elasticsearch-model/lib/elasticsearch/model/proxy.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/response.rb b/elasticsearch-model/lib/elasticsearch/model/response.rb index 718c06987..5d79a1827 100644 --- a/elasticsearch-model/lib/elasticsearch/model/response.rb +++ b/elasticsearch-model/lib/elasticsearch/model/response.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/response/aggregations.rb b/elasticsearch-model/lib/elasticsearch/model/response/aggregations.rb index c5f42ff54..6fc4a8e89 100644 --- a/elasticsearch-model/lib/elasticsearch/model/response/aggregations.rb +++ b/elasticsearch-model/lib/elasticsearch/model/response/aggregations.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/response/base.rb b/elasticsearch-model/lib/elasticsearch/model/response/base.rb index 2afa1193e..21853d5bb 100644 --- a/elasticsearch-model/lib/elasticsearch/model/response/base.rb +++ b/elasticsearch-model/lib/elasticsearch/model/response/base.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/response/pagination.rb b/elasticsearch-model/lib/elasticsearch/model/response/pagination.rb index 60830c75b..f12604179 100644 --- a/elasticsearch-model/lib/elasticsearch/model/response/pagination.rb +++ b/elasticsearch-model/lib/elasticsearch/model/response/pagination.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/response/pagination/kaminari.rb b/elasticsearch-model/lib/elasticsearch/model/response/pagination/kaminari.rb index 755ed567a..66de07ccb 100644 --- a/elasticsearch-model/lib/elasticsearch/model/response/pagination/kaminari.rb +++ b/elasticsearch-model/lib/elasticsearch/model/response/pagination/kaminari.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/response/pagination/will_paginate.rb b/elasticsearch-model/lib/elasticsearch/model/response/pagination/will_paginate.rb index 88023f12b..2d4658544 100644 --- a/elasticsearch-model/lib/elasticsearch/model/response/pagination/will_paginate.rb +++ b/elasticsearch-model/lib/elasticsearch/model/response/pagination/will_paginate.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/response/records.rb b/elasticsearch-model/lib/elasticsearch/model/response/records.rb index 41aa6fd70..e18ecc83d 100644 --- a/elasticsearch-model/lib/elasticsearch/model/response/records.rb +++ b/elasticsearch-model/lib/elasticsearch/model/response/records.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/response/result.rb b/elasticsearch-model/lib/elasticsearch/model/response/result.rb index 83e07e917..5e102c2b3 100644 --- a/elasticsearch-model/lib/elasticsearch/model/response/result.rb +++ b/elasticsearch-model/lib/elasticsearch/model/response/result.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/response/results.rb b/elasticsearch-model/lib/elasticsearch/model/response/results.rb index b0060f3fe..cf7e5aaf5 100644 --- a/elasticsearch-model/lib/elasticsearch/model/response/results.rb +++ b/elasticsearch-model/lib/elasticsearch/model/response/results.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/response/suggestions.rb b/elasticsearch-model/lib/elasticsearch/model/response/suggestions.rb index d02b1dcf5..72261a930 100644 --- a/elasticsearch-model/lib/elasticsearch/model/response/suggestions.rb +++ b/elasticsearch-model/lib/elasticsearch/model/response/suggestions.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/searching.rb b/elasticsearch-model/lib/elasticsearch/model/searching.rb index 1ee103344..714f98a22 100644 --- a/elasticsearch-model/lib/elasticsearch/model/searching.rb +++ b/elasticsearch-model/lib/elasticsearch/model/searching.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/serializing.rb b/elasticsearch-model/lib/elasticsearch/model/serializing.rb index 43c9afbbf..9433dfa12 100644 --- a/elasticsearch-model/lib/elasticsearch/model/serializing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/serializing.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/lib/elasticsearch/model/version.rb b/elasticsearch-model/lib/elasticsearch/model/version.rb index cc92865fe..ce56f7798 100644 --- a/elasticsearch-model/lib/elasticsearch/model/version.rb +++ b/elasticsearch-model/lib/elasticsearch/model/version.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapter_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapter_spec.rb index a02a633d6..33dd62590 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapter_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapter_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/associations_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/associations_spec.rb index f451f5d49..c3e460ffb 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/associations_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/associations_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb index eef1bd42c..a769b38f6 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/dynamic_index_name_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/dynamic_index_name_spec.rb index 02c2bb59d..abb4a0bdc 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/dynamic_index_name_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/dynamic_index_name_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb index e4a6088c8..1f5fe0847 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/multi_model_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/multi_model_spec.rb index 08dc869d0..c8196242a 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/multi_model_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/multi_model_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/namespaced_model_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/namespaced_model_spec.rb index 3f93eca9d..730dad0e0 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/namespaced_model_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/namespaced_model_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/pagination_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/pagination_spec.rb index fdf296261..c4a503ed7 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/pagination_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/pagination_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb index 675ab3b73..5147943ee 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb index 6e30c64b7..3f01c348b 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record_spec.rb index 02068bc54..8a6fe0171 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/default_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/default_spec.rb index 612e8a784..cbc59fa70 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/default_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/default_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid/basic_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid/basic_spec.rb index 1f12c0afd..0a0e71b58 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid/basic_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid/basic_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid/multi_model_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid/multi_model_spec.rb index d702eecab..5614522c9 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid/multi_model_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid/multi_model_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid_spec.rb index ac8e73551..81a286c0d 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/multiple_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/multiple_spec.rb index c0bf116e6..eb5a983b0 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/multiple_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/multiple_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/callbacks_spec.rb b/elasticsearch-model/spec/elasticsearch/model/callbacks_spec.rb index 325467bbe..f128d8732 100644 --- a/elasticsearch-model/spec/elasticsearch/model/callbacks_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/callbacks_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/client_spec.rb b/elasticsearch-model/spec/elasticsearch/model/client_spec.rb index 9fa9a5943..421bd3c50 100644 --- a/elasticsearch-model/spec/elasticsearch/model/client_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/client_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/hash_wrapper_spec.rb b/elasticsearch-model/spec/elasticsearch/model/hash_wrapper_spec.rb index d300e7bff..ae4c857ac 100644 --- a/elasticsearch-model/spec/elasticsearch/model/hash_wrapper_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/hash_wrapper_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb index 19bbff715..02cde6d6c 100644 --- a/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb index 281865a63..257294fa6 100644 --- a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/module_spec.rb b/elasticsearch-model/spec/elasticsearch/model/module_spec.rb index 72c90f4c5..2712318c5 100644 --- a/elasticsearch-model/spec/elasticsearch/model/module_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/module_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/multimodel_spec.rb b/elasticsearch-model/spec/elasticsearch/model/multimodel_spec.rb index b0cfcb1c2..3652dac1e 100644 --- a/elasticsearch-model/spec/elasticsearch/model/multimodel_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/multimodel_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/naming_spec.rb b/elasticsearch-model/spec/elasticsearch/model/naming_spec.rb index bdd5aafad..57a53b8d7 100644 --- a/elasticsearch-model/spec/elasticsearch/model/naming_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/naming_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb b/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb index f8bed3fbc..e9d9712c8 100644 --- a/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb index 2d3339991..a455140ea 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/response/base_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/base_spec.rb index c4d4499c9..d3459b93b 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/base_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/base_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/response/pagination/kaminari_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/pagination/kaminari_spec.rb index 4ad8ab5a1..15ee6113c 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/pagination/kaminari_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/pagination/kaminari_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/response/pagination/will_paginate_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/pagination/will_paginate_spec.rb index fa78c0784..25f1f0d1e 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/pagination/will_paginate_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/pagination/will_paginate_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/response/records_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/records_spec.rb index 72b46182b..2a80dcfc6 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/records_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/records_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/response/response_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/response_spec.rb index 9406b773a..e9a423812 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/response_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/response_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/response/result_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/result_spec.rb index 7cf701660..5aa7c8f4f 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/result_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/result_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/response/results_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/results_spec.rb index dca4c658c..946043a9f 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/results_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/results_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/searching_search_request_spec.rb b/elasticsearch-model/spec/elasticsearch/model/searching_search_request_spec.rb index a49fa8e28..1f5e72bf2 100644 --- a/elasticsearch-model/spec/elasticsearch/model/searching_search_request_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/searching_search_request_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/searching_spec.rb b/elasticsearch-model/spec/elasticsearch/model/searching_spec.rb index ced7257d9..ccede7435 100644 --- a/elasticsearch-model/spec/elasticsearch/model/searching_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/searching_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/elasticsearch/model/serializing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/serializing_spec.rb index f18079dcc..c5a26a4e4 100644 --- a/elasticsearch-model/spec/elasticsearch/model/serializing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/serializing_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/spec_helper.rb b/elasticsearch-model/spec/spec_helper.rb index 7bf7f41dc..3bb7f8742 100644 --- a/elasticsearch-model/spec/spec_helper.rb +++ b/elasticsearch-model/spec/spec_helper.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app.rb b/elasticsearch-model/spec/support/app.rb index 9169cb09f..b5a26ebff 100644 --- a/elasticsearch-model/spec/support/app.rb +++ b/elasticsearch-model/spec/support/app.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an @@ -43,4 +43,4 @@ require 'support/app/mongoid_article' rescue $stderr.puts("'mongoid' gem is not installed, could not load Mongoid models") -end \ No newline at end of file +end diff --git a/elasticsearch-model/spec/support/app/answer.rb b/elasticsearch-model/spec/support/app/answer.rb index ec94c4b60..9c58cc991 100644 --- a/elasticsearch-model/spec/support/app/answer.rb +++ b/elasticsearch-model/spec/support/app/answer.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an @@ -47,4 +47,4 @@ def as_indexed_json(options={}) after_commit lambda { __elasticsearch__.index_document(routing: (question_id || 1)) }, on: :create after_commit lambda { __elasticsearch__.update_document(routing: (question_id || 1)) }, on: :update after_commit lambda {__elasticsearch__.delete_document(routing: (question_id || 1)) }, on: :destroy -end \ No newline at end of file +end diff --git a/elasticsearch-model/spec/support/app/article.rb b/elasticsearch-model/spec/support/app/article.rb index 82e863b1c..2c122dd77 100644 --- a/elasticsearch-model/spec/support/app/article.rb +++ b/elasticsearch-model/spec/support/app/article.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/article_for_pagination.rb b/elasticsearch-model/spec/support/app/article_for_pagination.rb index b785b40eb..7916e56b9 100644 --- a/elasticsearch-model/spec/support/app/article_for_pagination.rb +++ b/elasticsearch-model/spec/support/app/article_for_pagination.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/article_no_type.rb b/elasticsearch-model/spec/support/app/article_no_type.rb index 5a08746ba..d3cb6b4e3 100644 --- a/elasticsearch-model/spec/support/app/article_no_type.rb +++ b/elasticsearch-model/spec/support/app/article_no_type.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/article_with_custom_serialization.rb b/elasticsearch-model/spec/support/app/article_with_custom_serialization.rb index 784f0338e..527143694 100644 --- a/elasticsearch-model/spec/support/app/article_with_custom_serialization.rb +++ b/elasticsearch-model/spec/support/app/article_with_custom_serialization.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/article_with_dynamic_index_name.rb b/elasticsearch-model/spec/support/app/article_with_dynamic_index_name.rb index d72341d96..6fa1f1298 100644 --- a/elasticsearch-model/spec/support/app/article_with_dynamic_index_name.rb +++ b/elasticsearch-model/spec/support/app/article_with_dynamic_index_name.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/author.rb b/elasticsearch-model/spec/support/app/author.rb index da8de2070..47abe43a3 100644 --- a/elasticsearch-model/spec/support/app/author.rb +++ b/elasticsearch-model/spec/support/app/author.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/authorship.rb b/elasticsearch-model/spec/support/app/authorship.rb index 0ef2c1786..55258f9f7 100644 --- a/elasticsearch-model/spec/support/app/authorship.rb +++ b/elasticsearch-model/spec/support/app/authorship.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/category.rb b/elasticsearch-model/spec/support/app/category.rb index 66518361b..6585ad806 100644 --- a/elasticsearch-model/spec/support/app/category.rb +++ b/elasticsearch-model/spec/support/app/category.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/comment.rb b/elasticsearch-model/spec/support/app/comment.rb index c2fcd16eb..f4ae205d7 100644 --- a/elasticsearch-model/spec/support/app/comment.rb +++ b/elasticsearch-model/spec/support/app/comment.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/episode.rb b/elasticsearch-model/spec/support/app/episode.rb index 66f37a989..34ebfc3eb 100644 --- a/elasticsearch-model/spec/support/app/episode.rb +++ b/elasticsearch-model/spec/support/app/episode.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/image.rb b/elasticsearch-model/spec/support/app/image.rb index e605ae942..155e974cd 100644 --- a/elasticsearch-model/spec/support/app/image.rb +++ b/elasticsearch-model/spec/support/app/image.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/import_article.rb b/elasticsearch-model/spec/support/app/import_article.rb index 4bb228e16..eb0a4962c 100644 --- a/elasticsearch-model/spec/support/app/import_article.rb +++ b/elasticsearch-model/spec/support/app/import_article.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/mongoid_article.rb b/elasticsearch-model/spec/support/app/mongoid_article.rb index 2dacd62b6..5e7c991ca 100644 --- a/elasticsearch-model/spec/support/app/mongoid_article.rb +++ b/elasticsearch-model/spec/support/app/mongoid_article.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/namespaced_book.rb b/elasticsearch-model/spec/support/app/namespaced_book.rb index 32a486ee2..f6d9c838c 100644 --- a/elasticsearch-model/spec/support/app/namespaced_book.rb +++ b/elasticsearch-model/spec/support/app/namespaced_book.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/parent_and_child_searchable.rb b/elasticsearch-model/spec/support/app/parent_and_child_searchable.rb index 15b56186a..91693479f 100644 --- a/elasticsearch-model/spec/support/app/parent_and_child_searchable.rb +++ b/elasticsearch-model/spec/support/app/parent_and_child_searchable.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/post.rb b/elasticsearch-model/spec/support/app/post.rb index 15aa0e041..9805d9cc3 100644 --- a/elasticsearch-model/spec/support/app/post.rb +++ b/elasticsearch-model/spec/support/app/post.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/question.rb b/elasticsearch-model/spec/support/app/question.rb index eec7d3b04..62a7d4550 100644 --- a/elasticsearch-model/spec/support/app/question.rb +++ b/elasticsearch-model/spec/support/app/question.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/searchable.rb b/elasticsearch-model/spec/support/app/searchable.rb index bfa7416a6..81ddf78b3 100644 --- a/elasticsearch-model/spec/support/app/searchable.rb +++ b/elasticsearch-model/spec/support/app/searchable.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-model/spec/support/app/series.rb b/elasticsearch-model/spec/support/app/series.rb index 6028650b4..3b4d17989 100644 --- a/elasticsearch-model/spec/support/app/series.rb +++ b/elasticsearch-model/spec/support/app/series.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/Gemfile b/elasticsearch-persistence/Gemfile index 439b88c36..17e92d051 100644 --- a/elasticsearch-persistence/Gemfile +++ b/elasticsearch-persistence/Gemfile @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/Rakefile b/elasticsearch-persistence/Rakefile index ec3daf3ca..6d53d4c22 100644 --- a/elasticsearch-persistence/Rakefile +++ b/elasticsearch-persistence/Rakefile @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/elasticsearch-persistence.gemspec b/elasticsearch-persistence/elasticsearch-persistence.gemspec index b09aaee03..4d01500db 100644 --- a/elasticsearch-persistence/elasticsearch-persistence.gemspec +++ b/elasticsearch-persistence/elasticsearch-persistence.gemspec @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/examples/notes/Gemfile b/elasticsearch-persistence/examples/notes/Gemfile index 1f98fc7f2..ef2c098c4 100644 --- a/elasticsearch-persistence/examples/notes/Gemfile +++ b/elasticsearch-persistence/examples/notes/Gemfile @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/examples/notes/application.rb b/elasticsearch-persistence/examples/notes/application.rb index 6c122999d..0f1724476 100644 --- a/elasticsearch-persistence/examples/notes/application.rb +++ b/elasticsearch-persistence/examples/notes/application.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/examples/notes/test.rb b/elasticsearch-persistence/examples/notes/test.rb index c99fff3f4..b57105341 100644 --- a/elasticsearch-persistence/examples/notes/test.rb +++ b/elasticsearch-persistence/examples/notes/test.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence.rb b/elasticsearch-persistence/lib/elasticsearch/persistence.rb index cf4337a25..ac845ce77 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/repository.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/repository.rb index c10b5c00b..607de1769 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/repository.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/repository.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/dsl.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/dsl.rb index 81185cfd4..de2848071 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/dsl.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/dsl.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/find.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/find.rb index e2714ce4d..cdd50c042 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/find.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/find.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/response/results.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/response/results.rb index 4eae5b913..1852f192a 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/response/results.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/response/results.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/search.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/search.rb index dcc1b0d51..2aa7db725 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/search.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/search.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/serialize.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/serialize.rb index 04ec367aa..fe68a7fbb 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/serialize.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/serialize.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/store.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/store.rb index 96f68637f..a8eeb1866 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/store.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/store.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb index e5ba66085..b66194776 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/spec/repository/find_spec.rb b/elasticsearch-persistence/spec/repository/find_spec.rb index ab00e8d8b..083ee4c25 100644 --- a/elasticsearch-persistence/spec/repository/find_spec.rb +++ b/elasticsearch-persistence/spec/repository/find_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/spec/repository/response/results_spec.rb b/elasticsearch-persistence/spec/repository/response/results_spec.rb index 981773515..9d98cfc79 100644 --- a/elasticsearch-persistence/spec/repository/response/results_spec.rb +++ b/elasticsearch-persistence/spec/repository/response/results_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/spec/repository/search_spec.rb b/elasticsearch-persistence/spec/repository/search_spec.rb index 6986830c2..8e94ecc1d 100644 --- a/elasticsearch-persistence/spec/repository/search_spec.rb +++ b/elasticsearch-persistence/spec/repository/search_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/spec/repository/serialize_spec.rb b/elasticsearch-persistence/spec/repository/serialize_spec.rb index 7d6dfdfdc..17e358686 100644 --- a/elasticsearch-persistence/spec/repository/serialize_spec.rb +++ b/elasticsearch-persistence/spec/repository/serialize_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/spec/repository/store_spec.rb b/elasticsearch-persistence/spec/repository/store_spec.rb index 569aa410f..bebf810aa 100644 --- a/elasticsearch-persistence/spec/repository/store_spec.rb +++ b/elasticsearch-persistence/spec/repository/store_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/spec/repository_spec.rb b/elasticsearch-persistence/spec/repository_spec.rb index 472687fe5..eb957910f 100644 --- a/elasticsearch-persistence/spec/repository_spec.rb +++ b/elasticsearch-persistence/spec/repository_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-persistence/spec/spec_helper.rb b/elasticsearch-persistence/spec/spec_helper.rb index 73243fe19..6e5f58402 100644 --- a/elasticsearch-persistence/spec/spec_helper.rb +++ b/elasticsearch-persistence/spec/spec_helper.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/Gemfile b/elasticsearch-rails/Gemfile index 6787846e4..90572cba1 100644 --- a/elasticsearch-rails/Gemfile +++ b/elasticsearch-rails/Gemfile @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/Rakefile b/elasticsearch-rails/Rakefile index 1a03db185..20c7d1616 100644 --- a/elasticsearch-rails/Rakefile +++ b/elasticsearch-rails/Rakefile @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/elasticsearch-rails.gemspec b/elasticsearch-rails/elasticsearch-rails.gemspec index 224e7fa36..55951bbaf 100644 --- a/elasticsearch-rails/elasticsearch-rails.gemspec +++ b/elasticsearch-rails/elasticsearch-rails.gemspec @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/elasticsearch/rails.rb b/elasticsearch-rails/lib/elasticsearch/rails.rb index a2f85b1e0..1f6bac36f 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation.rb b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation.rb index 61a23093d..ca210066a 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/controller_runtime.rb b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/controller_runtime.rb index 09ca20ca7..a26765c54 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/controller_runtime.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/controller_runtime.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb index cf313a8c2..c388961c0 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/publishers.rb b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/publishers.rb index ec4e4e743..2c36d91bd 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/publishers.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/publishers.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/railtie.rb b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/railtie.rb index adb1e494a..38fdbc6f1 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/railtie.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/railtie.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/elasticsearch/rails/lograge.rb b/elasticsearch-rails/lib/elasticsearch/rails/lograge.rb index 562756e81..d2bd06467 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/lograge.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/lograge.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb b/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb index 87fef3daa..91f4441ea 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/elasticsearch/rails/version.rb b/elasticsearch-rails/lib/elasticsearch/rails/version.rb index 23cddcf6f..ab125b547 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/version.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/version.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/rails/templates/01-basic.rb b/elasticsearch-rails/lib/rails/templates/01-basic.rb index 516732893..c517a0f3f 100644 --- a/elasticsearch-rails/lib/rails/templates/01-basic.rb +++ b/elasticsearch-rails/lib/rails/templates/01-basic.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/rails/templates/02-pretty.rb b/elasticsearch-rails/lib/rails/templates/02-pretty.rb index 4a70e5f39..3be42b481 100644 --- a/elasticsearch-rails/lib/rails/templates/02-pretty.rb +++ b/elasticsearch-rails/lib/rails/templates/02-pretty.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/rails/templates/03-expert.rb b/elasticsearch-rails/lib/rails/templates/03-expert.rb index dbb4104cb..aa7635531 100644 --- a/elasticsearch-rails/lib/rails/templates/03-expert.rb +++ b/elasticsearch-rails/lib/rails/templates/03-expert.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/rails/templates/04-dsl.rb b/elasticsearch-rails/lib/rails/templates/04-dsl.rb index 1325d57c1..b6eb6f893 100644 --- a/elasticsearch-rails/lib/rails/templates/04-dsl.rb +++ b/elasticsearch-rails/lib/rails/templates/04-dsl.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/rails/templates/05-settings-files.rb b/elasticsearch-rails/lib/rails/templates/05-settings-files.rb index 5c5e4bbeb..cf84213ce 100644 --- a/elasticsearch-rails/lib/rails/templates/05-settings-files.rb +++ b/elasticsearch-rails/lib/rails/templates/05-settings-files.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/rails/templates/indexer.rb b/elasticsearch-rails/lib/rails/templates/indexer.rb index 912b960ca..1ea1d9b6c 100644 --- a/elasticsearch-rails/lib/rails/templates/indexer.rb +++ b/elasticsearch-rails/lib/rails/templates/indexer.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/rails/templates/search_controller_test.dsl.rb b/elasticsearch-rails/lib/rails/templates/search_controller_test.dsl.rb index a73119e66..fd10ad9e1 100644 --- a/elasticsearch-rails/lib/rails/templates/search_controller_test.dsl.rb +++ b/elasticsearch-rails/lib/rails/templates/search_controller_test.dsl.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/rails/templates/search_controller_test.rb b/elasticsearch-rails/lib/rails/templates/search_controller_test.rb index d195772c6..d627ae528 100644 --- a/elasticsearch-rails/lib/rails/templates/search_controller_test.rb +++ b/elasticsearch-rails/lib/rails/templates/search_controller_test.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/rails/templates/searchable.dsl.rb b/elasticsearch-rails/lib/rails/templates/searchable.dsl.rb index fb3ff03d2..a0efeb997 100644 --- a/elasticsearch-rails/lib/rails/templates/searchable.dsl.rb +++ b/elasticsearch-rails/lib/rails/templates/searchable.dsl.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/rails/templates/searchable.rb b/elasticsearch-rails/lib/rails/templates/searchable.rb index d101826ef..cf7e4e800 100644 --- a/elasticsearch-rails/lib/rails/templates/searchable.rb +++ b/elasticsearch-rails/lib/rails/templates/searchable.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/lib/rails/templates/seeds.rb b/elasticsearch-rails/lib/rails/templates/seeds.rb index 74bf4a379..7b7294d2d 100644 --- a/elasticsearch-rails/lib/rails/templates/seeds.rb +++ b/elasticsearch-rails/lib/rails/templates/seeds.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/spec/instrumentation_spec.rb b/elasticsearch-rails/spec/instrumentation_spec.rb index ff70d4266..3fcbc5916 100644 --- a/elasticsearch-rails/spec/instrumentation_spec.rb +++ b/elasticsearch-rails/spec/instrumentation_spec.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/spec/lograge_spec.rb b/elasticsearch-rails/spec/lograge_spec.rb index 6ab0763f9..980aa9f1b 100644 --- a/elasticsearch-rails/spec/lograge_spec.rb +++ b/elasticsearch-rails/spec/lograge_spec.rb @@ -24,7 +24,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/elasticsearch-rails/spec/spec_helper.rb b/elasticsearch-rails/spec/spec_helper.rb index 9c2522eb9..e0a299964 100644 --- a/elasticsearch-rails/spec/spec_helper.rb +++ b/elasticsearch-rails/spec/spec_helper.rb @@ -6,7 +6,7 @@ # not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an From fadded5eb3242afc93c4217612ec2a65fffdd649 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 5 Aug 2021 21:48:07 +0100 Subject: [PATCH 040/113] [CI] Adds manual trigger for GH Actions --- .github/workflows/2.4.yml | 3 +++ .github/workflows/2.5.yml | 3 +++ .github/workflows/2.6.yml | 3 +++ .github/workflows/2.7.yml | 3 +++ .github/workflows/jruby.yml | 3 +++ .github/workflows/license.yml | 2 +- 6 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/2.4.yml b/.github/workflows/2.4.yml index bac506823..b16804be3 100644 --- a/.github/workflows/2.4.yml +++ b/.github/workflows/2.4.yml @@ -6,6 +6,9 @@ on: pull_request: branches: - master + workflow_dispatch: + branches: + - '*' jobs: tests: env: diff --git a/.github/workflows/2.5.yml b/.github/workflows/2.5.yml index 058182561..8d6352206 100644 --- a/.github/workflows/2.5.yml +++ b/.github/workflows/2.5.yml @@ -6,6 +6,9 @@ on: pull_request: branches: - master + workflow_dispatch: + branches: + - '*' jobs: tests: env: diff --git a/.github/workflows/2.6.yml b/.github/workflows/2.6.yml index d4e7f4345..a5c709e2d 100644 --- a/.github/workflows/2.6.yml +++ b/.github/workflows/2.6.yml @@ -6,6 +6,9 @@ on: pull_request: branches: - master + workflow_dispatch: + branches: + - '*' jobs: tests: env: diff --git a/.github/workflows/2.7.yml b/.github/workflows/2.7.yml index 514ee02eb..7a03199bb 100644 --- a/.github/workflows/2.7.yml +++ b/.github/workflows/2.7.yml @@ -6,6 +6,9 @@ on: pull_request: branches: - master + workflow_dispatch: + branches: + - '*' jobs: tests: env: diff --git a/.github/workflows/jruby.yml b/.github/workflows/jruby.yml index 6a7569b95..7175cbfb2 100644 --- a/.github/workflows/jruby.yml +++ b/.github/workflows/jruby.yml @@ -6,6 +6,9 @@ on: pull_request: branches: - master + workflow_dispatch: + branches: + - '*' jobs: tests: env: diff --git a/.github/workflows/license.yml b/.github/workflows/license.yml index d7357e56e..27201b4b7 100644 --- a/.github/workflows/license.yml +++ b/.github/workflows/license.yml @@ -1,5 +1,5 @@ name: License headers -on: [pull_request] +on: [pull_request, workflow_dispatch] jobs: build: runs-on: ubuntu-latest From 2a01d9fdc7686d7a9b5830c36ecdb521af8a1610 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 5 Aug 2021 21:56:07 +0100 Subject: [PATCH 041/113] [STORE] Update specs --- elasticsearch-persistence/spec/repository_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch-persistence/spec/repository_spec.rb b/elasticsearch-persistence/spec/repository_spec.rb index eb957910f..05aeb1f53 100644 --- a/elasticsearch-persistence/spec/repository_spec.rb +++ b/elasticsearch-persistence/spec/repository_spec.rb @@ -104,7 +104,7 @@ class RepositoryWithoutDSL end it 'sets a default client' do - expect(repository.client).to be_a(Elasticsearch::Transport::Client) + expect(repository.client).to be_a(Elasticsearch::Client) end @@ -465,7 +465,7 @@ class RepositoryWithoutDSL end it 'sets a default on the instance' do - expect(RepositoryWithoutDSL.new.client).to be_a(Elasticsearch::Transport::Client) + expect(RepositoryWithoutDSL.new.client).to be_a(Elasticsearch::Client) end it 'allows the value to be overridden with options on the instance' do From f0500422a8f15584a731e52d907f15b8f37c7714 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 5 Aug 2021 22:02:00 +0100 Subject: [PATCH 042/113] [MODEL] Fixes indexing to use right logger in client --- elasticsearch-model/lib/elasticsearch/model.rb | 4 ++-- elasticsearch-model/lib/elasticsearch/model/client.rb | 5 ----- .../lib/elasticsearch/model/indexing.rb | 4 ++-- .../spec/elasticsearch/model/indexing_spec.rb | 10 ++++++++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/elasticsearch-model/lib/elasticsearch/model.rb b/elasticsearch-model/lib/elasticsearch/model.rb index fe9c33047..af2f34cb6 100644 --- a/elasticsearch-model/lib/elasticsearch/model.rb +++ b/elasticsearch-model/lib/elasticsearch/model.rb @@ -127,7 +127,7 @@ module ClassMethods # @example Get the client # # Elasticsearch::Model.client - # => # + # => # # def client @client ||= Elasticsearch::Client.new @@ -138,7 +138,7 @@ def client # @example Configure (set) the client for all models # # Elasticsearch::Model.client = Elasticsearch::Client.new host: 'http://localhost:9200', tracer: true - # => # + # => # # # @note You have to set the client before you call Elasticsearch methods on the model, # or set it directly on the model; see {Elasticsearch::Model::Client::ClassMethods#client} diff --git a/elasticsearch-model/lib/elasticsearch/model/client.rb b/elasticsearch-model/lib/elasticsearch/model/client.rb index 01a122440..b47a0925f 100644 --- a/elasticsearch-model/lib/elasticsearch/model/client.rb +++ b/elasticsearch-model/lib/elasticsearch/model/client.rb @@ -17,13 +17,10 @@ module Elasticsearch module Model - # Contains an `Elasticsearch::Client` instance # module Client - module ClassMethods - # Get the client for a specific model class # # @example Get the client for `Article` and perform API request @@ -48,7 +45,6 @@ def client=(client) end module InstanceMethods - # Get or set the client for a specific model instance # # @example Get the client for a specific record and perform API request @@ -72,7 +68,6 @@ def client=(client) @client = client end end - end end end diff --git a/elasticsearch-model/lib/elasticsearch/model/indexing.rb b/elasticsearch-model/lib/elasticsearch/model/indexing.rb index f35ef7342..3ebd8cfb4 100644 --- a/elasticsearch-model/lib/elasticsearch/model/indexing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/indexing.rb @@ -290,7 +290,7 @@ def delete_index!(options={}) self.client.indices.delete index: target_index rescue Exception => e if e.class.to_s =~ /NotFound/ && options[:force] - client.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.logger + client.transport.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.transport.logger nil else raise e @@ -317,7 +317,7 @@ def refresh_index!(options={}) self.client.indices.refresh index: target_index rescue Exception => e if e.class.to_s =~ /NotFound/ && options[:force] - client.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.logger + client.transport.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.transport.logger nil else raise e diff --git a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb index 257294fa6..efda997c8 100644 --- a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb @@ -676,9 +676,15 @@ class ::DummyIndexingModelForRecreate end context 'when the index is not found' do - let(:client) do - double('client', indices: indices, transport: double('transport', { logger: nil })) + double( + 'client', + indices: indices, + transport: double( + 'transport', + double('transport', { logger: nil }) + ) + ) end let(:indices) do From 5d5df6332474351f8c5a6ec82db9e4369cbb8970 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 5 Aug 2021 22:20:27 +0100 Subject: [PATCH 043/113] [MODEL] Updates ES client spec for client 7.14.0 --- .../spec/elasticsearch/model/client_spec.rb | 6 ++-- .../spec/elasticsearch/model/indexing_spec.rb | 35 +++++++++---------- .../spec/elasticsearch/model/module_spec.rb | 2 +- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/elasticsearch-model/spec/elasticsearch/model/client_spec.rb b/elasticsearch-model/spec/elasticsearch/model/client_spec.rb index 421bd3c50..12814d701 100644 --- a/elasticsearch-model/spec/elasticsearch/model/client_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/client_spec.rb @@ -33,14 +33,14 @@ class ::DummyClientModel context 'when a class includes the client module class methods' do it 'defines the client module class methods on the model' do - expect(DummyClientModel.client).to be_a(Elasticsearch::Transport::Client) + expect(DummyClientModel.client).to be_a(Elasticsearch::Client) end end context 'when a class includes the client module instance methods' do it 'defines the client module class methods on the model' do - expect(DummyClientModel.new.client).to be_a(Elasticsearch::Transport::Client) + expect(DummyClientModel.new.client).to be_a(Elasticsearch::Client) end end @@ -77,7 +77,7 @@ class ::DummyClientModel end it 'does not set the client on the class' do - expect(DummyClientModel.client).to be_a(Elasticsearch::Transport::Client) + expect(DummyClientModel.client).to be_a(Elasticsearch::Client) end end end diff --git a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb index efda997c8..eb9651a73 100644 --- a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb @@ -676,15 +676,13 @@ class ::DummyIndexingModelForRecreate end context 'when the index is not found' do + let(:logger) { nil } + let(:transport) do + Elasticsearch::Transport::Client.new(logger: logger) + end + let(:client) do - double( - 'client', - indices: indices, - transport: double( - 'transport', - double('transport', { logger: nil }) - ) - ) + double('client', indices: indices, transport: transport) end let(:indices) do @@ -698,19 +696,17 @@ class ::DummyIndexingModelForRecreate end context 'when the force option is true' do - it 'deletes the index without raising an exception' do expect(DummyIndexingModelForRecreate.delete_index!(force: true)).to be_nil end context 'when the client has a logger' do - let(:logger) do Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG } end let(:client) do - double('client', indices: indices, transport: double('transport', { logger: logger })) + double('client', indices: indices, transport: transport) end it 'deletes the index without raising an exception' do @@ -918,7 +914,11 @@ class ::DummyIndexingModelForRefresh end let(:client) do - double('client', indices: indices, transport: double('transport', { logger: nil })) + double('client', indices: indices, transport: transport) + end + + let(:transport) do + Elasticsearch::Transport::Client.new(logger: nil) end let(:indices) do @@ -930,9 +930,7 @@ class ::DummyIndexingModelForRefresh end context 'when the force option is true' do - context 'when the operation raises a NotFound exception' do - before do expect(indices).to receive(:refresh).and_raise(NotFound) end @@ -942,13 +940,16 @@ class ::DummyIndexingModelForRefresh end context 'when the client has a logger' do - let(:logger) do Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG } end let(:client) do - double('client', indices: indices, transport: double('transport', { logger: logger })) + double('client', indices: indices, transport: transport) + end + + let(:transport) do + Elasticsearch::Transport::Client.new(logger: logger) end it 'does not raise an exception' do @@ -963,7 +964,6 @@ class ::DummyIndexingModelForRefresh end context 'when the operation raises another type of exception' do - before do expect(indices).to receive(:refresh).and_raise(Exception) end @@ -977,7 +977,6 @@ class ::DummyIndexingModelForRefresh end context 'when an index name is provided in the options' do - before do expect(indices).to receive(:refresh).with(index: 'custom-foo') end diff --git a/elasticsearch-model/spec/elasticsearch/model/module_spec.rb b/elasticsearch-model/spec/elasticsearch/model/module_spec.rb index 2712318c5..ed7a58297 100644 --- a/elasticsearch-model/spec/elasticsearch/model/module_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/module_spec.rb @@ -22,7 +22,7 @@ describe '#client' do it 'should have a default' do - expect(Elasticsearch::Model.client).to be_a(Elasticsearch::Transport::Client) + expect(Elasticsearch::Model.client).to be_a(Elasticsearch::Client) end end From 6a0b594cbfe71368fcd8452b1025f618c17a3431 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 9 Aug 2021 10:02:08 +0100 Subject: [PATCH 044/113] [MODEL][STORE] Updates transport references --- elasticsearch-model/examples/activerecord_associations.rb | 2 +- elasticsearch-model/examples/activerecord_custom_analyzer.rb | 4 ++-- elasticsearch-persistence/README.md | 4 ++-- elasticsearch-persistence/examples/notes/test.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/elasticsearch-model/examples/activerecord_associations.rb b/elasticsearch-model/examples/activerecord_associations.rb index b8100b33b..17d521cbf 100644 --- a/elasticsearch-model/examples/activerecord_associations.rb +++ b/elasticsearch-model/examples/activerecord_associations.rb @@ -81,7 +81,7 @@ # ----- Elasticsearch client setup ---------------------------------------------------------------- Elasticsearch::Model.client = Elasticsearch::Client.new log: true -Elasticsearch::Model.client.transport.logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" } +Elasticsearch::Model.client.transport.transport.logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" } # ----- Search integration ------------------------------------------------------------------------ diff --git a/elasticsearch-model/examples/activerecord_custom_analyzer.rb b/elasticsearch-model/examples/activerecord_custom_analyzer.rb index 886eaab91..d16ddbd11 100644 --- a/elasticsearch-model/examples/activerecord_custom_analyzer.rb +++ b/elasticsearch-model/examples/activerecord_custom_analyzer.rb @@ -37,8 +37,8 @@ end end -Elasticsearch::Model.client.transport.logger = ActiveSupport::Logger.new(STDOUT) -Elasticsearch::Model.client.transport.logger.formatter = lambda { |s, d, p, m| "#{m.ansi(:faint)}\n" } +Elasticsearch::Model.client.transport.transport.logger = ActiveSupport::Logger.new(STDOUT) +Elasticsearch::Model.client.transport.transport.logger.formatter = lambda { |s, d, p, m| "#{m.ansi(:faint)}\n" } class Article < ActiveRecord::Base include Elasticsearch::Model diff --git a/elasticsearch-persistence/README.md b/elasticsearch-persistence/README.md index 1d4fac551..c196c2f95 100644 --- a/elasticsearch-persistence/README.md +++ b/elasticsearch-persistence/README.md @@ -236,7 +236,7 @@ You can also override the default configuration with options passed to the initi ```ruby client = Elasticsearch::Client.new(url: 'http://localhost:9250', log: true) -client.transport.logger.formatter = proc { |s, d, p, m| "\e[2m# #{m}\n\e[0m" } +client.transport.transport.logger.formatter = proc { |s, d, p, m| "\e[2m# #{m}\n\e[0m" } repository = NoteRepository.new(client: client, index_name: 'notes_development') repository.create_index!(force: true) @@ -267,7 +267,7 @@ The repository uses the standard Elasticsearch [client](https://github.com/elast ```ruby client = Elasticsearch::Client.new(url: 'http://search.server.org') repository = NoteRepository.new(client: client) -repository.client.transport.logger = Logger.new(STDERR) +repository.client.transport.transport.logger = Logger.new(STDERR) repository.client # => Elasticsearch::Client diff --git a/elasticsearch-persistence/examples/notes/test.rb b/elasticsearch-persistence/examples/notes/test.rb index b57105341..27922933b 100644 --- a/elasticsearch-persistence/examples/notes/test.rb +++ b/elasticsearch-persistence/examples/notes/test.rb @@ -90,7 +90,7 @@ def app app.settings.repository.client = Elasticsearch::Client.new \ hosts: [{ host: 'localhost', port: ENV.fetch('TEST_CLUSTER_PORT', 9250)}], log: true - app.settings.repository.client.transport.logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" } + app.settings.repository.client.transport.transport.logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" } app.settings.repository.create_index! force: true app.settings.repository.client.cluster.health wait_for_status: 'yellow' end From f965acc84ff11fcf480340e7f4182d697f652416 Mon Sep 17 00:00:00 2001 From: NoharaMasato Date: Thu, 4 Feb 2021 12:42:04 +0900 Subject: [PATCH 045/113] [#966] Adds alias for Elasticsearch::Model::Response::Results#records By @NoharaMasato in #976 --- .../lib/elasticsearch/model/response/results.rb | 1 + .../elasticsearch/model/response/results_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/elasticsearch-model/lib/elasticsearch/model/response/results.rb b/elasticsearch-model/lib/elasticsearch/model/response/results.rb index cf7e5aaf5..564a684a3 100644 --- a/elasticsearch-model/lib/elasticsearch/model/response/results.rb +++ b/elasticsearch-model/lib/elasticsearch/model/response/results.rb @@ -42,6 +42,7 @@ def results response.response['hits']['hits'].map { |hit| Result.new(hit) } end + alias records results end end end diff --git a/elasticsearch-model/spec/elasticsearch/model/response/results_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/results_spec.rb index 946043a9f..f69db2c01 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/results_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/results_spec.rb @@ -48,6 +48,10 @@ def self.document_type; 'bar'; end response.results end + let(:records) do + response.records + end + describe '#results' do it 'provides access to the results' do @@ -70,4 +74,12 @@ def self.document_type; 'bar'; end expect(response.raw_response).to eq(response_document) end end + + describe '#records' do + + it 'provides access to the records' do + expect(results.records.size).to be(results.results.size) + expect(results.records.first.foo).to eq(results.results.first.foo) + end + end end From bd626568eafeed4ee0242e605e70b313332a6b81 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 11 Aug 2021 10:21:03 +0100 Subject: [PATCH 046/113] Fixes some styling in Rakefile --- Rakefile | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Rakefile b/Rakefile index a2dd17e69..9b3347f86 100644 --- a/Rakefile +++ b/Rakefile @@ -54,12 +54,13 @@ task :default do system 'rake --tasks' end +desc 'Show subprojects information' task :subprojects do - puts '-'*80 + puts '-' * 80 subprojects.each do |project| commit = `git log --pretty=format:'%h %ar: %s' -1 #{project}` - version = Gem::Specification::load(__current__.join(project, "#{project}.gemspec").to_s).version.to_s - puts "[#{version}] \e[1m#{project.ljust(subprojects.map {|s| s.length}.max)}\e[0m | #{commit[ 0..80]}..." + version = Gem::Specification.load(__current__.join(project, "#{project}.gemspec").to_s).version.to_s + puts "[#{version}] \e[1m#{project.ljust(subprojects.map(&:length).max)}\e[0m | #{commit[0..80]}..." end end @@ -87,7 +88,7 @@ namespace :bundle do end namespace :test do - task :bundle => 'bundle:install' + task bundle: 'bundle:install' desc "Run unit tests in all subprojects" task :unit do @@ -114,7 +115,7 @@ namespace :test do end desc "Run integration tests in all subprojects" - task :integration => :setup_elasticsearch do + task integration: :setup_elasticsearch do # 1/ elasticsearch-model # puts '-'*80 @@ -139,7 +140,7 @@ namespace :test do end desc "Run all tests in all subprojects" - task :all => :wait_for_green do + task all: :wait_for_green do subprojects.each do |project| puts '-'*80 sh "cd #{project} && " + @@ -150,7 +151,6 @@ namespace :test do end end - desc "Wait for elasticsearch cluster to be in green state" task :wait_for_green do require 'elasticsearch' @@ -176,7 +176,7 @@ task :wait_for_green do end end -desc "Generate documentation for all subprojects" +desc 'Generate documentation for all subprojects' task :doc do subprojects.each do |project| sh "cd #{__current__.join(project)} && rake doc" @@ -184,11 +184,11 @@ task :doc do end end -desc "Release all subprojects to Rubygems" +desc 'Release all subprojects to Rubygems' task :release do subprojects.each do |project| sh "cd #{__current__.join(project)} && rake release" - puts '-'*80 + puts '-' * 80 end end @@ -199,17 +199,17 @@ desc <<-DESC $ rake update_version[5.0.0,5.0.1] DESC -task :update_version, :old, :new do |task, args| +task :update_version, :old, :new do |_, args| require 'ansi' - puts "[!!!] Required argument [old] missing".ansi(:red) unless args[:old] - puts "[!!!] Required argument [new] missing".ansi(:red) unless args[:new] + puts '[!!!] Required argument [old] missing'.ansi(:red) unless args[:old] + puts '[!!!] Required argument [new] missing'.ansi(:red) unless args[:new] - files = Dir['**/**/version.rb','**/**/*.gemspec'] + files = Dir['**/**/version.rb', '**/**/*.gemspec'] - longest_line = files.map { |f| f.size }.max + longest_line = files.map(&:size).max - puts "\n", "= FILES ".ansi(:faint) + ('='*92).ansi(:faint), "\n" + puts "\n", '= FILES '.ansi(:faint) + ('=' * 92).ansi(:faint), "\n" files.each do |file| begin @@ -217,7 +217,7 @@ task :update_version, :old, :new do |task, args| content = f.read if content.match Regexp.new(args[:old]) content.gsub! Regexp.new(args[:old]), args[:new] - puts "+ [#{file}]".ansi(:green).ljust(longest_line+20) + " [#{args[:old]}] -> [#{args[:new]}]".ansi(:green,:bold) + puts "+ [#{file}]".ansi(:green).ljust(longest_line + 20) + " [#{args[:old]}] -> [#{args[:new]}]".ansi(:green, :bold) f.rewind f.write content else @@ -300,8 +300,8 @@ task :update_version, :old, :new do |task, args| puts "\n\n", "= COMMIT ".ansi(:faint) + ('='*91).ansi(:faint), "\n" - puts "git add CHANGELOG.md elasticsearch-*", + puts 'git add CHANGELOG.md elasticsearch-*', "git commit --verbose --message='Release #{args[:new]}' --edit", - "rake release" + 'rake release' "\n" end From 78ee91f30f761fbebf8cda7f08099aae649ce510 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 11 Aug 2021 10:45:01 +0100 Subject: [PATCH 047/113] Bumps version to 7.2.0 --- elasticsearch-model/lib/elasticsearch/model/version.rb | 2 +- elasticsearch-persistence/elasticsearch-persistence.gemspec | 2 +- .../lib/elasticsearch/persistence/version.rb | 2 +- elasticsearch-rails/lib/elasticsearch/rails/version.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/version.rb b/elasticsearch-model/lib/elasticsearch/model/version.rb index ce56f7798..fe79283ab 100644 --- a/elasticsearch-model/lib/elasticsearch/model/version.rb +++ b/elasticsearch-model/lib/elasticsearch/model/version.rb @@ -17,6 +17,6 @@ module Elasticsearch module Model - VERSION = "7.1.0" + VERSION = "7.2.0" end end diff --git a/elasticsearch-persistence/elasticsearch-persistence.gemspec b/elasticsearch-persistence/elasticsearch-persistence.gemspec index 4d01500db..6e7970e8e 100644 --- a/elasticsearch-persistence/elasticsearch-persistence.gemspec +++ b/elasticsearch-persistence/elasticsearch-persistence.gemspec @@ -41,7 +41,7 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 1.9.3" s.add_dependency "elasticsearch", '~> 7' - s.add_dependency "elasticsearch-model", '7.1.0' + s.add_dependency "elasticsearch-model", '7.2.0' s.add_dependency "activesupport", '> 4' s.add_dependency "activemodel", '> 4' s.add_dependency "hashie" diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb index b66194776..4c6ad62d9 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb @@ -17,6 +17,6 @@ module Elasticsearch module Persistence - VERSION = '7.1.0' + VERSION = '7.2.0' end end diff --git a/elasticsearch-rails/lib/elasticsearch/rails/version.rb b/elasticsearch-rails/lib/elasticsearch/rails/version.rb index ab125b547..9be1f1045 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/version.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/version.rb @@ -17,6 +17,6 @@ module Elasticsearch module Rails - VERSION = "7.1.0" + VERSION = "7.2.0" end end From 2e33f226789c612599850dc5728f6bddcfa9fee7 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 11 Aug 2021 10:45:12 +0100 Subject: [PATCH 048/113] [DOCS] Updates Changelog to 7.2.0 --- CHANGELOG.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7af564d7..02e595151 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,30 @@ +## 7.2.0 + +* Updates specs and dependency to use with `elasticsearch` v7.14.0. +* Update README, remove Virtus (unmaintained) +* Updates `Bundler.with_clean_dev` (deprecated) to `with_unbundled_env` [commit](https://github.com/elastic/elasticsearch-rails/commit/e4545e4fe2a1ce80009206c831d5740360bad6c2) +* Deal with `nil` document types in Multimodel [commit](https://github.com/elastic/elasticsearch-rails/commit/cd9c309b78de443d2e37760998418616ba34276d) +* Update dependency to explicitly support version 7 [commit](https://github.com/elastic/elasticsearch-rails/commit/65942e3da9cabad2f6965e69c8ef6a0994da9408) +* Stop emitting FATAL log when checking existence of indices [commit](https://github.com/elastic/elasticsearch-rails/commit/5db9207ca398c5d77f671109360ca7f63e3f2112) +* Remove unnecessary exception test on index checking [commit](https://github.com/elastic/elasticsearch-rails/commit/ce57cc17e304b0a4af123c1599f37fb892a5d93a) +* Removes dependency on extensions [commit](https://github.com/elastic/elasticsearch-rails/commit/ed070b8329ca48b4cb12b513ac81ed78c88acc61) +* Fixes basic template elasticsearch dependency [commit](https://github.com/elastic/elasticsearch-rails/commit/a4ec07b2d097545ca41c13686c9cbfc9eab9e639) + +### ActiveModel + +* Fixes indexing to use right logger in client +* Updates ES client spec for client 7.14.0 +* Updates transport references + +## 7.1.1 + +* Fix: Ruby 2.7 deprecation warning on `find_in_batches` +* Updates README for generating app with template. Related: #938 + +### ActiveModel + +* Do not override existing methods (#936) + ## 7.1.0 * Tested with elasticsearch Ruby client version 7.6.0 From 8404aaacad7d6826f5daed4f006837c6f65b725e Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Sun, 25 Apr 2021 22:21:39 -0700 Subject: [PATCH 049/113] create failing spec for keyword args proxy when the proxy fails to forward keywoard arguments, the error for methods that only accept keyword arguments looks like this: ArgumentError: wrong number of arguments (given 1, expected 0) --- .../spec/elasticsearch/model/proxy_spec.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb b/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb index e9d9712c8..f21baad3d 100644 --- a/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb @@ -31,6 +31,10 @@ def bar 'insta barr' end + def keyword_method(foo: 'default value') + foo + end + def as_json(options) {foo: 'bar'} end @@ -98,7 +102,6 @@ def changes_to_save end context 'when instances are cloned' do - let!(:model) do DummyProxyModel.new end @@ -121,4 +124,9 @@ def changes_to_save expect(duplicate).to eq(duplicate_target) end end + + it 'forwards keyword arguments to target methods' do + expect(DummyProxyModel.new.__elasticsearch__.keyword_method(foo: 'bar')).to eq('bar') + end + end From 224c0b660b23ccfb393189df94f9a32592e5ae88 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Sun, 25 Apr 2021 22:26:44 -0700 Subject: [PATCH 050/113] fix proxying keyword arguments this resolves a bug with Rails 6.1 on Ruby 3, where keyword arguments are not forwarded and this causes an ArgumentError --- elasticsearch-model/lib/elasticsearch/model/proxy.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/proxy.rb b/elasticsearch-model/lib/elasticsearch/model/proxy.rb index 955280fba..969593e46 100644 --- a/elasticsearch-model/lib/elasticsearch/model/proxy.rb +++ b/elasticsearch-model/lib/elasticsearch/model/proxy.rb @@ -117,8 +117,8 @@ def initialize(target) # Delegate methods to `@target` # - def method_missing(method_name, *arguments, &block) - target.respond_to?(method_name) ? target.__send__(method_name, *arguments, &block) : super + def method_missing(method_name, *args, **kwargs, &block) + target.respond_to?(method_name) ? target.__send__(method_name, *args, **kwargs, &block) : super end # Respond to methods from `@target` From 4030e6d563ab95b5a54a314bbeebac5688fa0ea8 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Sun, 25 Apr 2021 22:28:06 -0700 Subject: [PATCH 051/113] use respond_to_missing? not respond_to? since Ruby 1.9.2, about 12 years ago, you're supposed to define respond_to_missing? if you also define method_missing. there's more explanation in this blog post by a ruby committer in 2010: http://blog.marc-andre.ca/2010/11/15/methodmissing-politely/ --- elasticsearch-model/lib/elasticsearch/model/proxy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/proxy.rb b/elasticsearch-model/lib/elasticsearch/model/proxy.rb index 969593e46..f26cda899 100644 --- a/elasticsearch-model/lib/elasticsearch/model/proxy.rb +++ b/elasticsearch-model/lib/elasticsearch/model/proxy.rb @@ -123,7 +123,7 @@ def method_missing(method_name, *args, **kwargs, &block) # Respond to methods from `@target` # - def respond_to?(method_name, include_private = false) + def respond_to_missing?(method_name, include_private = false) target.respond_to?(method_name) || super end From d12d812c3f52ac484cf73805ef41986dd95ba5a0 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Mon, 26 Apr 2021 15:33:14 -0700 Subject: [PATCH 052/113] update method missing for Ruby 2.x-3.0 all at once --- elasticsearch-model/lib/elasticsearch/model/proxy.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/proxy.rb b/elasticsearch-model/lib/elasticsearch/model/proxy.rb index f26cda899..6fdf66322 100644 --- a/elasticsearch-model/lib/elasticsearch/model/proxy.rb +++ b/elasticsearch-model/lib/elasticsearch/model/proxy.rb @@ -115,10 +115,13 @@ def initialize(target) @target = target end - # Delegate methods to `@target` + def ruby2_keywords(*) # :nodoc: + end if RUBY_VERSION < "2.7" + + # Delegate methods to `@target`. As per [the Ruby 3.0 explanation for keyword arguments](https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/), the only way to work on Ruby <2.7, and 2.7, and 3.0+ is to use `ruby2_keywords`. # - def method_missing(method_name, *args, **kwargs, &block) - target.respond_to?(method_name) ? target.__send__(method_name, *args, **kwargs, &block) : super + ruby2_keywords def method_missing(method_name, *arguments, &block) + target.respond_to?(method_name) ? target.__send__(method_name, *arguments, &block) : super end # Respond to methods from `@target` From 835ea07643011544f9a6f0866557cc5f27ad1e51 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 9 Sep 2021 11:02:41 +0100 Subject: [PATCH 053/113] Renames master to main --- .github/workflows/2.4.yml | 4 +-- .github/workflows/2.5.yml | 4 +-- .github/workflows/2.6.yml | 4 +-- .github/workflows/2.7.yml | 4 +-- .github/workflows/jruby.yml | 4 +-- README.md | 26 +++++++++---------- elasticsearch-model/README.md | 12 ++++----- elasticsearch-persistence/README.md | 4 +-- elasticsearch-rails/README.md | 18 ++++++------- .../elasticsearch-rails.gemspec | 2 +- .../lib/rails/templates/01-basic.rb | 4 +-- .../lib/rails/templates/02-pretty.rb | 2 +- .../lib/rails/templates/03-expert.rb | 16 ++++++------ .../lib/rails/templates/04-dsl.rb | 6 ++--- .../lib/rails/templates/05-settings-files.rb | 4 +-- 15 files changed, 57 insertions(+), 57 deletions(-) diff --git a/.github/workflows/2.4.yml b/.github/workflows/2.4.yml index b16804be3..890c78613 100644 --- a/.github/workflows/2.4.yml +++ b/.github/workflows/2.4.yml @@ -2,10 +2,10 @@ name: Ruby 2.4 on: push: branches: - - master + - main pull_request: branches: - - master + - main workflow_dispatch: branches: - '*' diff --git a/.github/workflows/2.5.yml b/.github/workflows/2.5.yml index 8d6352206..68f8294fe 100644 --- a/.github/workflows/2.5.yml +++ b/.github/workflows/2.5.yml @@ -2,10 +2,10 @@ name: Ruby 2.5 on: push: branches: - - master + - main pull_request: branches: - - master + - main workflow_dispatch: branches: - '*' diff --git a/.github/workflows/2.6.yml b/.github/workflows/2.6.yml index a5c709e2d..c003a58e5 100644 --- a/.github/workflows/2.6.yml +++ b/.github/workflows/2.6.yml @@ -2,10 +2,10 @@ name: Ruby 2.6 on: push: branches: - - master + - main pull_request: branches: - - master + - main workflow_dispatch: branches: - '*' diff --git a/.github/workflows/2.7.yml b/.github/workflows/2.7.yml index 7a03199bb..8bfd9b66f 100644 --- a/.github/workflows/2.7.yml +++ b/.github/workflows/2.7.yml @@ -2,10 +2,10 @@ name: Ruby 2.7 on: push: branches: - - master + - main pull_request: branches: - - master + - main workflow_dispatch: branches: - '*' diff --git a/.github/workflows/jruby.yml b/.github/workflows/jruby.yml index 7175cbfb2..3a397ebc0 100644 --- a/.github/workflows/jruby.yml +++ b/.github/workflows/jruby.yml @@ -2,10 +2,10 @@ name: JRuby on: push: branches: - - master + - main pull_request: branches: - - master + - main workflow_dispatch: branches: - '*' diff --git a/README.md b/README.md index 96c958674..8a6a745fe 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ gem 'elasticsearch-rails', github: 'elastic/elasticsearch-rails', branch: '5.x' The libraries are compatible with Ruby 2.4 and higher. -The version numbers follow the Elasticsearch major versions. The `master` branch is compatible with the latest Elasticsearch stack stable release. +The version numbers follow the Elasticsearch major versions. The `main` branch is compatible with the latest Elasticsearch stack stable release. | Rubygem | | Elasticsearch | |:-------------:|:-:| :-----------: | @@ -48,7 +48,7 @@ The version numbers follow the Elasticsearch major versions. The `master` branch | 2.x | → | 2.x | | 5.x | → | 5.x | | 6.x | → | 6.x | -| master | → | 7.x | +| main | → | 7.x | Use a release that matches the major version of Elasticsearch in your stack. Each client version is backwards compatible with all minor versions of the same major version. @@ -58,13 +58,13 @@ Check out [Elastic product end of life dates](https://www.elastic.co/support/eol This project is split into three separate gems: -* [**`elasticsearch-model`**](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-model), +* [**`elasticsearch-model`**](https://github.com/elastic/elasticsearch-rails/tree/main/elasticsearch-model), which contains search integration for Ruby/Rails models such as ActiveRecord::Base and Mongoid, -* [**`elasticsearch-persistence`**](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-persistence), +* [**`elasticsearch-persistence`**](https://github.com/elastic/elasticsearch-rails/tree/main/elasticsearch-persistence), which provides a standalone persistence layer for Ruby/Rails objects and models -* [**`elasticsearch-rails`**](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-rails), +* [**`elasticsearch-rails`**](https://github.com/elastic/elasticsearch-rails/tree/main/elasticsearch-rails), which contains various features for Ruby on Rails applications Example of a basic integration into an ActiveRecord-based model: @@ -87,7 +87,7 @@ Article.import ``` You can generate a simple Ruby on Rails application with a single command -(see the [other available templates](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-rails#rails-application-templates)). You'll need to have an Elasticsearch cluster running on your system before generating the app. The easiest way of getting this set up is by running it with Docker with this command: +(see the [other available templates](https://github.com/elastic/elasticsearch-rails/tree/main/elasticsearch-rails#rails-application-templates)). You'll need to have an Elasticsearch cluster running on your system before generating the app. The easiest way of getting this set up is by running it with Docker with this command: ```bash docker run \ @@ -103,7 +103,7 @@ You can generate a simple Ruby on Rails application with a single command Once Elasticsearch is running, you can generate the simple app with this command: ```bash -rails new searchapp --skip --skip-bundle --template https://raw.github.com/elasticsearch/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/01-basic.rb +rails new searchapp --skip --skip-bundle --template https://raw.github.com/elasticsearch/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/01-basic.rb ``` Example of using Elasticsearch as a repository for a Ruby domain object: @@ -125,21 +125,21 @@ repository.save Article.new(title: 'Test') ### Model -* [[README]](https://github.com/elastic/elasticsearch-rails/blob/master/elasticsearch-model/README.md) +* [[README]](https://github.com/elastic/elasticsearch-rails/blob/main/elasticsearch-model/README.md) * [[Documentation]](http://rubydoc.info/gems/elasticsearch-model/) -* [[Test Suite]](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-model/spec/elasticsearch/model) +* [[Test Suite]](https://github.com/elastic/elasticsearch-rails/tree/main/elasticsearch-model/spec/elasticsearch/model) ### Persistence -* [[README]](https://github.com/elastic/elasticsearch-rails/blob/master/elasticsearch-persistence/README.md) +* [[README]](https://github.com/elastic/elasticsearch-rails/blob/main/elasticsearch-persistence/README.md) * [[Documentation]](http://rubydoc.info/gems/elasticsearch-persistence/) -* [[Test Suite]](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-persistence/spec) +* [[Test Suite]](https://github.com/elastic/elasticsearch-rails/tree/main/elasticsearch-persistence/spec) ### Rails -* [[README]](https://github.com/elastic/elasticsearch-rails/blob/master/elasticsearch-rails/README.md) +* [[README]](https://github.com/elastic/elasticsearch-rails/blob/main/elasticsearch-rails/README.md) * [[Documentation]](http://rubydoc.info/gems/elasticsearch-rails) -* [[Test Suite]](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-rails/spec) +* [[Test Suite]](https://github.com/elastic/elasticsearch-rails/tree/main/elasticsearch-rails/spec) ## Development diff --git a/elasticsearch-model/README.md b/elasticsearch-model/README.md index bd1b3927b..a5345b4b9 100644 --- a/elasticsearch-model/README.md +++ b/elasticsearch-model/README.md @@ -8,7 +8,7 @@ It aims to simplify integration of Ruby classes ("models"), commonly found e.g. This library is compatible with Ruby 2.4 and higher. -The library version numbers follow the Elasticsearch major versions. The `master` branch is compatible with the latest Elasticsearch stack stable release. +The library version numbers follow the Elasticsearch major versions. The `main` branch is compatible with the latest Elasticsearch stack stable release. | Rubygem | | Elasticsearch | |:-------------:|:-:| :-----------: | @@ -16,7 +16,7 @@ The library version numbers follow the Elasticsearch major versions. The `master | 2.x | → | 2.x | | 5.x | → | 5.x | | 6.x | → | 6.x | -| master | → | 7.x | +| main | → | 7.x | ## Installation @@ -116,7 +116,7 @@ See the `Elasticsearch::Model` module documentation for technical information. ### The Elasticsearch client -The module will set up a [client](https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch), +The module will set up a [client](https://github.com/elastic/elasticsearch-ruby/tree/main/elasticsearch), connected to `localhost:9200`, by default. You can access and use it as any other `Elasticsearch::Client`: ```ruby @@ -139,7 +139,7 @@ Elasticsearch::Model.client = Elasticsearch::Client.new log: true You might want to do this during your application bootstrap process, e.g. in a Rails initializer. Please refer to the -[`elasticsearch-transport`](https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch-transport) +[`elasticsearch-transport`](https://github.com/elastic/elasticsearch-ruby/tree/main/elasticsearch-transport) library documentation for all the configuration options, and to the [`elasticsearch-api`](http://rubydoc.info/gems/elasticsearch-api) library documentation for information about the Ruby client API. @@ -248,7 +248,7 @@ response.records.order(:title).to_a The `records` method returns the real instances of your model, which is useful when you want to access your model methods -- at the expense of slowing down your application, of course. In most cases, working with `results` coming from Elasticsearch is sufficient, and much faster. See the -[`elasticsearch-rails`](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-rails) +[`elasticsearch-rails`](https://github.com/elastic/elasticsearch-rails/tree/main/elasticsearch-rails) library for more information about compatibility with the Ruby on Rails framework. When you want to access both the database `records` and search `results`, use the `each_with_hit` @@ -343,7 +343,7 @@ response.results.first.title # => "Quick brown fox" ``` -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 the Elasticsearch Query DSL: +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: ```ruby require 'elasticsearch/dsl' diff --git a/elasticsearch-persistence/README.md b/elasticsearch-persistence/README.md index c196c2f95..6b905f593 100644 --- a/elasticsearch-persistence/README.md +++ b/elasticsearch-persistence/README.md @@ -6,7 +6,7 @@ Persistence layer for Ruby domain objects in Elasticsearch, using the Repository This library is compatible with Ruby 2.4 and higher. -The library version numbers follow the Elasticsearch major versions. The `master` branch is compatible with the latest Elasticsearch stack stable release. +The library version numbers follow the Elasticsearch major versions. The `main` branch is compatible with the latest Elasticsearch stack stable release. | Rubygem | | Elasticsearch | |:-------------:|:-:| :-----------: | @@ -14,7 +14,7 @@ The library version numbers follow the Elasticsearch major versions. The `master | 2.x | → | 2.x | | 5.x | → | 5.x | | 6.x | → | 6.x | -| master | → | 7.x | +| main | → | 7.x | ## Installation diff --git a/elasticsearch-rails/README.md b/elasticsearch-rails/README.md index 687d016ae..375f379f5 100644 --- a/elasticsearch-rails/README.md +++ b/elasticsearch-rails/README.md @@ -1,14 +1,14 @@ # Elasticsearch::Rails The `elasticsearch-rails` library is a companion for the -the [`elasticsearch-model`](https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-model) +the [`elasticsearch-model`](https://github.com/elastic/elasticsearch-rails/tree/main/elasticsearch-model) library, providing features suitable for Ruby on Rails applications. ## Compatibility This library is compatible with Ruby 1.9.3 and higher. -The library version numbers follow the Elasticsearch major versions, and the `master` branch +The library version numbers follow the Elasticsearch major versions, and the `main` branch is compatible with the Elasticsearch `master` branch, therefore, with the next major version. | Rubygem | | Elasticsearch | @@ -18,7 +18,7 @@ is compatible with the Elasticsearch `master` branch, therefore, with the next m | 5.x | → | 5.x | | 6.x | → | 6.x | | 7.x | → | 7.x | -| master | → | master | +| main | → | master | ## Installation @@ -101,22 +101,22 @@ You should see the duration of the request to Elasticsearch as part of each log You can generate a fully working example Ruby on Rails application, with an `Article` model and a search form, to play with (it generates the application skeleton and leaves you with a _Git_ repository to explore the steps and the code) with the -[`01-basic.rb`](https://github.com/elastic/elasticsearch-rails/blob/master/elasticsearch-rails/lib/rails/templates/01-basic.rb) template: +[`01-basic.rb`](https://github.com/elastic/elasticsearch-rails/blob/main/elasticsearch-rails/lib/rails/templates/01-basic.rb) template: ```bash -rails new searchapp --skip --skip-bundle --template https://raw.github.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/01-basic.rb +rails new searchapp --skip --skip-bundle --template https://raw.github.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/01-basic.rb ``` Run the same command again, in the same folder, with the -[`02-pretty`](https://github.com/elastic/elasticsearch-rails/blob/master/elasticsearch-rails/lib/rails/templates/02-pretty.rb) +[`02-pretty`](https://github.com/elastic/elasticsearch-rails/blob/main/elasticsearch-rails/lib/rails/templates/02-pretty.rb) template to add features such as a custom `Article.search` method, result highlighting and [_Bootstrap_](http://getbootstrap.com) integration: ```bash -rails new searchapp --skip --skip-bundle --template https://raw.github.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/02-pretty.rb +rails new searchapp --skip --skip-bundle --template https://raw.github.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/02-pretty.rb ``` -Run the same command with the [`03-expert.rb`](https://github.com/elastic/elasticsearch-rails/blob/master/elasticsearch-rails/lib/rails/templates/03-expert.rb) +Run the same command with the [`03-expert.rb`](https://github.com/elastic/elasticsearch-rails/blob/main/elasticsearch-rails/lib/rails/templates/03-expert.rb) template to refactor the application into a more complex use case, with couple of hundreds of The New York Times articles as the example content. The template will extract the Elasticsearch integration into a `Searchable` "concern" module, @@ -124,7 +124,7 @@ define complex mapping, custom serialization, implement faceted navigation and s a complex query, and add a _Sidekiq_-based worker for updating the index in the background. ```bash -rails new searchapp --skip --skip-bundle --template https://raw.github.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/03-expert.rb +rails new searchapp --skip --skip-bundle --template https://raw.github.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/03-expert.rb ``` ## License diff --git a/elasticsearch-rails/elasticsearch-rails.gemspec b/elasticsearch-rails/elasticsearch-rails.gemspec index 55951bbaf..9b2b34781 100644 --- a/elasticsearch-rails/elasticsearch-rails.gemspec +++ b/elasticsearch-rails/elasticsearch-rails.gemspec @@ -31,7 +31,7 @@ Gem::Specification.new do |s| s.license = 'Apache 2' s.metadata = { 'homepage_uri' => 'https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/ruby_on_rails.html', - 'changelog_uri' => 'https://github.com/elastic/elasticsearch-rails/blob/master/CHANGELOG.md', + 'changelog_uri' => 'https://github.com/elastic/elasticsearch-rails/blob/main/CHANGELOG.md', 'source_code_uri' => 'https://github.com/elastic/elasticsearch-rails/', 'bug_tracker_uri' => 'https://github.com/elastic/elasticsearch-rails/issues' } diff --git a/elasticsearch-rails/lib/rails/templates/01-basic.rb b/elasticsearch-rails/lib/rails/templates/01-basic.rb index c517a0f3f..5e07e14a4 100644 --- a/elasticsearch-rails/lib/rails/templates/01-basic.rb +++ b/elasticsearch-rails/lib/rails/templates/01-basic.rb @@ -32,7 +32,7 @@ # Usage: # ------ # -# $ rails new searchapp --skip --skip-bundle --template https://raw.github.com/elasticsearch/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/01-basic.rb +# $ rails new searchapp --skip --skip-bundle --template https://raw.github.com/elasticsearch/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/01-basic.rb # # ===================================================================================================== @@ -112,7 +112,7 @@ search engine with the {Ruby On Rails}[http://rubyonrails.org] web framework. It has been generated by application templates available at -https://github.com/elasticsearch/elasticsearch-rails/tree/master/elasticsearch-rails/lib/rails/templates. +https://github.com/elasticsearch/elasticsearch-rails/tree/main/elasticsearch-rails/lib/rails/templates. ## [1] Basic diff --git a/elasticsearch-rails/lib/rails/templates/02-pretty.rb b/elasticsearch-rails/lib/rails/templates/02-pretty.rb index 3be42b481..fb88e0c47 100644 --- a/elasticsearch-rails/lib/rails/templates/02-pretty.rb +++ b/elasticsearch-rails/lib/rails/templates/02-pretty.rb @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -# $ rails new searchapp --skip --skip-bundle --template https://raw.github.com/elasticsearch/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/02-pretty.rb +# $ rails new searchapp --skip --skip-bundle --template https://raw.github.com/elasticsearch/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/02-pretty.rb unless File.read('README.md').include? '## [1] Basic' say_status "ERROR", "You have to run the 01-basic.rb template first.", :red diff --git a/elasticsearch-rails/lib/rails/templates/03-expert.rb b/elasticsearch-rails/lib/rails/templates/03-expert.rb index aa7635531..5715eb0d6 100644 --- a/elasticsearch-rails/lib/rails/templates/03-expert.rb +++ b/elasticsearch-rails/lib/rails/templates/03-expert.rb @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -# $ rails new searchapp --skip --skip-bundle --template https://raw.github.com/elasticsearch/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/03-expert.rb +# $ rails new searchapp --skip --skip-bundle --template https://raw.github.com/elasticsearch/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/03-expert.rb unless File.read('README.md').include? '## [2] Pretty' say_status "ERROR", "You have to run the 01-basic.rb and 02-pretty.rb templates first.", :red @@ -181,7 +181,7 @@ class Article < ActiveRecord::Base gsub_file "test/models/article_test.rb", %r{assert_equal 'foo', definition\[:query\]\[:multi_match\]\[:query\]}, "assert_equal 'foo', definition.to_hash[:query][:bool][:should][0][:multi_match][:query]" # copy_file File.expand_path('../searchable.rb', __FILE__), 'app/models/concerns/searchable.rb' -get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/searchable.rb', 'app/models/concerns/searchable.rb' +get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/searchable.rb', 'app/models/concerns/searchable.rb' insert_into_file "app/models/article.rb", after: "ActiveRecord::Base" do <<-CODE @@ -209,7 +209,7 @@ class Article < ActiveRecord::Base run "bundle install" # copy_file File.expand_path('../indexer.rb', __FILE__), 'app/workers/indexer.rb' -get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/indexer.rb', 'app/workers/indexer.rb' +get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/indexer.rb', 'app/workers/indexer.rb' insert_into_file "test/test_helper.rb", "require 'sidekiq/testing'\n\n", @@ -244,16 +244,16 @@ def index end # copy_file File.expand_path('../search_controller_test.rb', __FILE__), 'test/controllers/search_controller_test.rb' -get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/search_controller_test.rb', 'test/controllers/search_controller_test.rb' +get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/search_controller_test.rb', 'test/controllers/search_controller_test.rb' route "get '/search', to: 'search#index', as: 'search'" gsub_file 'config/routes.rb', %r{root to: 'articles#index'$}, "root to: 'search#index'" # copy_file File.expand_path('../index.html.erb', __FILE__), 'app/views/search/index.html.erb' -get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/index.html.erb', 'app/views/search/index.html.erb' +get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/index.html.erb', 'app/views/search/index.html.erb' # copy_file File.expand_path('../search.css', __FILE__), 'app/assets/stylesheets/search.css' -get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/search.css', 'app/assets/stylesheets/search.css' +get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/search.css', 'app/assets/stylesheets/search.css' git add: "app/controllers/ test/controllers/ config/routes.rb" git add: "app/views/search/ app/assets/stylesheets/search.css" @@ -315,11 +315,11 @@ def index puts '-'*80, ''; sleep 0.25 # copy_file File.expand_path('../articles.yml.gz', __FILE__), 'db/articles.yml.gz' -get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/articles.yml.gz', 'db/articles.yml.gz' +get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/articles.yml.gz', 'db/articles.yml.gz' remove_file 'db/seeds.rb' # copy_file File.expand_path('../seeds.rb', __FILE__), 'db/seeds.rb' -get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/seeds.rb', 'db/seeds.rb' +get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/seeds.rb', 'db/seeds.rb' rake "db:reset" rake "environment elasticsearch:import:model CLASS='Article' BATCH=100 FORCE=y" diff --git a/elasticsearch-rails/lib/rails/templates/04-dsl.rb b/elasticsearch-rails/lib/rails/templates/04-dsl.rb index b6eb6f893..d4bd598a0 100644 --- a/elasticsearch-rails/lib/rails/templates/04-dsl.rb +++ b/elasticsearch-rails/lib/rails/templates/04-dsl.rb @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -# $ rails new searchapp --skip --skip-bundle --template https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/04-dsl.rb +# $ rails new searchapp --skip --skip-bundle --template https://raw.githubusercontent.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/04-dsl.rb unless File.read('README.md').include? '## [3] Expert' say_status "ERROR", "You have to run the 01-basic.rb, 02-pretty.rb and 03-expert.rb templates first.", :red @@ -56,10 +56,10 @@ # ----- Change the search definition implementation and associated views and tests ---------------- # copy_file File.expand_path('../searchable.dsl.rb', __FILE__), 'app/models/concerns/searchable.rb', force: true -get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/searchable.dsl.rb', 'app/models/concerns/searchable.rb', force: true +get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/searchable.dsl.rb', 'app/models/concerns/searchable.rb', force: true # copy_file File.expand_path('../index.html.dsl.erb', __FILE__), 'app/views/search/index.html.erb', force: true -get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/index.html.dsl.erb', 'app/views/search/index.html.erb', force: true +get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/index.html.dsl.erb', 'app/views/search/index.html.erb', force: true gsub_file "test/controllers/search_controller_test.rb", %r{test "should return facets" do.*?end}m, <<-CODE test "should return aggregations" do diff --git a/elasticsearch-rails/lib/rails/templates/05-settings-files.rb b/elasticsearch-rails/lib/rails/templates/05-settings-files.rb index cf84213ce..989895445 100644 --- a/elasticsearch-rails/lib/rails/templates/05-settings-files.rb +++ b/elasticsearch-rails/lib/rails/templates/05-settings-files.rb @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -# $ rails new searchapp --skip --skip-bundle --template https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/05-settings-files.rb +# $ rails new searchapp --skip --skip-bundle --template https://raw.githubusercontent.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/05-settings-files.rb # (See: 01-basic.rb, 02-pretty.rb, 03-expert.rb, 04-dsl.rb) @@ -43,7 +43,7 @@ # ----- Copy the articles_settings.json file ------------------------------------------------------- # copy_file File.expand_path('../articles_settings.json', __FILE__), 'config/elasticsearch/articles_settings.json' -get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/articles_settings.json', +get 'https://raw.githubusercontent.com/elastic/elasticsearch-rails/main/elasticsearch-rails/lib/rails/templates/articles_settings.json', 'config/elasticsearch/articles_settings.json', force: true git add: "config/elasticsearch/articles_settings.json" From b2f95ba961b6dc4a3399b6b996a7ba0ca39bf29a Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 23 Feb 2022 08:36:48 +0000 Subject: [PATCH 054/113] [CI] Updates JRuby version in GitHub Actions --- .github/workflows/jruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jruby.yml b/.github/workflows/jruby.yml index 3a397ebc0..7a3ec1be7 100644 --- a/.github/workflows/jruby.yml +++ b/.github/workflows/jruby.yml @@ -30,7 +30,7 @@ jobs: stack-version: 7.x-SNAPSHOT - uses: ruby/setup-ruby@v1 with: - ruby-version: jruby-9.2 + ruby-version: jruby-9.3 - name: Bundle run: | sudo apt-get install libsqlite3-dev From a0cef1b3e90d22b4648e6869836cc3536dad8ff1 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 23 Feb 2022 08:20:45 +0000 Subject: [PATCH 055/113] [DOCS] Updates CHANGELOG for 7.2.1 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02e595151..c3405dea7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 7.2.1 + +* The default git branch `master` has been renamed to `main` +* Adds compatibility with Ruby 3 [Pull Request](https://github.com/elastic/elasticsearch-rails/pull/992) + ## 7.2.0 * Updates specs and dependency to use with `elasticsearch` v7.14.0. From 97ac1ff417d13a240552fc202a53c263019d478a Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 23 Feb 2022 08:34:45 +0000 Subject: [PATCH 056/113] [DOCS] Updates README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8a6a745fe..615c7a01e 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,9 @@ gem 'elasticsearch-rails', github: 'elastic/elasticsearch-rails', branch: '5.x' The libraries are compatible with Ruby 2.4 and higher. -The version numbers follow the Elasticsearch major versions. The `main` branch is compatible with the latest Elasticsearch stack stable release. +We follow Ruby’s own maintenance policy and officially support all currently maintained versions per [Ruby Maintenance Branches](https://www.ruby-lang.org/en/downloads/branches/). + +The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `7.x` of the Elasticsearch stack. **We haven't tested and updated the code for Elasticsearch `8.0` yet**. | Rubygem | | Elasticsearch | |:-------------:|:-:| :-----------: | @@ -50,8 +52,6 @@ The version numbers follow the Elasticsearch major versions. The `main` branch i | 6.x | → | 6.x | | main | → | 7.x | -Use a release that matches the major version of Elasticsearch in your stack. Each client version is backwards compatible with all minor versions of the same major version. - Check out [Elastic product end of life dates](https://www.elastic.co/support/eol) to learn which releases are still actively supported and tested. ## Usage From 03fa16b2774988c59978abb13aae962c9580ec57 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 23 Feb 2022 08:35:39 +0000 Subject: [PATCH 057/113] Bumps version to 7.2.1 --- elasticsearch-model/lib/elasticsearch/model/version.rb | 2 +- elasticsearch-persistence/elasticsearch-persistence.gemspec | 2 +- .../lib/elasticsearch/persistence/version.rb | 2 +- elasticsearch-rails/lib/elasticsearch/rails/version.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/version.rb b/elasticsearch-model/lib/elasticsearch/model/version.rb index fe79283ab..cdd631896 100644 --- a/elasticsearch-model/lib/elasticsearch/model/version.rb +++ b/elasticsearch-model/lib/elasticsearch/model/version.rb @@ -17,6 +17,6 @@ module Elasticsearch module Model - VERSION = "7.2.0" + VERSION = "7.2.1" end end diff --git a/elasticsearch-persistence/elasticsearch-persistence.gemspec b/elasticsearch-persistence/elasticsearch-persistence.gemspec index 6e7970e8e..f1a736127 100644 --- a/elasticsearch-persistence/elasticsearch-persistence.gemspec +++ b/elasticsearch-persistence/elasticsearch-persistence.gemspec @@ -41,7 +41,7 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 1.9.3" s.add_dependency "elasticsearch", '~> 7' - s.add_dependency "elasticsearch-model", '7.2.0' + s.add_dependency "elasticsearch-model", '7.2.1' s.add_dependency "activesupport", '> 4' s.add_dependency "activemodel", '> 4' s.add_dependency "hashie" diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb index 4c6ad62d9..18fe2466d 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb @@ -17,6 +17,6 @@ module Elasticsearch module Persistence - VERSION = '7.2.0' + VERSION = '7.2.1' end end diff --git a/elasticsearch-rails/lib/elasticsearch/rails/version.rb b/elasticsearch-rails/lib/elasticsearch/rails/version.rb index 9be1f1045..07d084dae 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/version.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/version.rb @@ -17,6 +17,6 @@ module Elasticsearch module Rails - VERSION = "7.2.0" + VERSION = "7.2.1" end end From b66fe71cc4b9b10069bf6d39dbbfcc0b117a08a5 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 19 Apr 2022 08:38:48 +0100 Subject: [PATCH 058/113] [DOCS] Updates README and links to elasticsearch-dsl Closes #1026 --- README.md | 2 +- elasticsearch-model/README.md | 2 +- elasticsearch-rails/lib/rails/templates/04-dsl.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 615c7a01e..df4d71db8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Elasticsearch +# Elasticsearch Rails [![Ruby 2.7](https://github.com/elastic/elasticsearch-rails/workflows/Ruby%202.7/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) [![Ruby 2.6](https://github.com/elastic/elasticsearch-rails/workflows/Ruby%202.6/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) diff --git a/elasticsearch-model/README.md b/elasticsearch-model/README.md index a5345b4b9..2a0135960 100644 --- a/elasticsearch-model/README.md +++ b/elasticsearch-model/README.md @@ -343,7 +343,7 @@ response.results.first.title # => "Quick brown fox" ``` -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: +Also, you can use the [**`elasticsearch-dsl`**](https://github.com/elastic/elasticsearch-dsl-ruby) library, which provides a specialized Ruby API for the Elasticsearch Query DSL: ```ruby require 'elasticsearch/dsl' diff --git a/elasticsearch-rails/lib/rails/templates/04-dsl.rb b/elasticsearch-rails/lib/rails/templates/04-dsl.rb index d4bd598a0..6e0d265fd 100644 --- a/elasticsearch-rails/lib/rails/templates/04-dsl.rb +++ b/elasticsearch-rails/lib/rails/templates/04-dsl.rb @@ -27,7 +27,7 @@ ## [4] DSL The `dsl` template refactors the search definition in SearchController#index -to use the [`elasticsearch-dsl`](https://github.com/elastic/elasticsearch-ruby/tree/dsl/elasticsearch-dsl) +to use the [`elasticsearch-dsl`](https://github.com/elastic/elasticsearch-dsl-ruby) Rubygem for better expresivity and readability of the code. README @@ -44,7 +44,7 @@ say_status "Rubygems", "Adding Rubygems into Gemfile...\n", :yellow puts '-'*80, ''; sleep 0.25 -gem "elasticsearch-dsl", git: "git://github.com/elastic/elasticsearch-ruby.git" +gem "elasticsearch-dsl", git: "git://github.com/elastic/elasticsearch-dsl-ruby.git" git add: "Gemfile*" git commit: "-m 'Added the `elasticsearch-dsl` gem'" From 2b30cbade674ea89ed08d2a1124bd82336f27fd0 Mon Sep 17 00:00:00 2001 From: Doug Tabuchi Date: Tue, 17 May 2022 12:43:48 -0400 Subject: [PATCH 059/113] Template installs deps using main branch --- elasticsearch-rails/lib/rails/templates/01-basic.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch-rails/lib/rails/templates/01-basic.rb b/elasticsearch-rails/lib/rails/templates/01-basic.rb index 5e07e14a4..faf67489a 100644 --- a/elasticsearch-rails/lib/rails/templates/01-basic.rb +++ b/elasticsearch-rails/lib/rails/templates/01-basic.rb @@ -157,8 +157,8 @@ puts '-'*80, ''; sleep 0.75 gem 'elasticsearch' -gem 'elasticsearch-model', git: 'https://github.com/elasticsearch/elasticsearch-rails.git' -gem 'elasticsearch-rails', git: 'https://github.com/elasticsearch/elasticsearch-rails.git' +gem 'elasticsearch-model', git: 'https://github.com/elasticsearch/elasticsearch-rails.git', branch: 'main' +gem 'elasticsearch-rails', git: 'https://github.com/elasticsearch/elasticsearch-rails.git', branch: 'main' git add: "Gemfile*" From dc0efc4d020f41712c190b94b755e600319b0450 Mon Sep 17 00:00:00 2001 From: Hannes Moser Date: Sun, 16 Oct 2022 16:06:55 +0200 Subject: [PATCH 060/113] Fix missing environment dependency for import tasks --- elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb b/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb index 91f4441ea..b43d67163 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb @@ -57,7 +57,7 @@ $ rake environment elasticsearch:import:model CLASS='Article' SCOPE='published' DESC desc import_model_desc - task :model do + task model: :environment do if ENV['CLASS'].to_s == '' puts '='*90, 'USAGE', '='*90, import_model_desc, "" exit(1) @@ -97,7 +97,7 @@ $ rake environment elasticsearch:import:all DIR=app/models DESC - task :all do + task all: :environment do dir = ENV['DIR'].to_s != '' ? ENV['DIR'] : Rails.root.join("app/models") puts "[IMPORT] Loading models from: #{dir}" From 37b7897e5090db18977ccfeac4db20ccce579b35 Mon Sep 17 00:00:00 2001 From: Yoshinori Tokuno Date: Sat, 29 Oct 2022 22:34:35 +0900 Subject: [PATCH 061/113] renamed docker image name in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index df4d71db8..26ee3860e 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ You can generate a simple Ruby on Rails application with a single command --env "cluster.name=elasticsearch-rails" \ --env "cluster.routing.allocation.disk.threshold_enabled=false" \ --rm \ - docker.elastic.co/elasticsearch/elasticsearch-oss:7.6.0 + docker.elastic.co/elasticsearch/elasticsearch:7.6.0 ``` Once Elasticsearch is running, you can generate the simple app with this command: From 8e0526cc9bf9c3c41a4e989222a19a1f5318d3b6 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Fri, 4 Nov 2022 10:37:01 +0000 Subject: [PATCH 062/113] Updates README files --- elasticsearch-model/README.md | 2 +- elasticsearch-persistence/README.md | 3 ++- elasticsearch-rails/README.md | 5 ++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/elasticsearch-model/README.md b/elasticsearch-model/README.md index 2a0135960..c7d90150a 100644 --- a/elasticsearch-model/README.md +++ b/elasticsearch-model/README.md @@ -8,7 +8,7 @@ It aims to simplify integration of Ruby classes ("models"), commonly found e.g. This library is compatible with Ruby 2.4 and higher. -The library version numbers follow the Elasticsearch major versions. The `main` branch is compatible with the latest Elasticsearch stack stable release. +The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `7.x` of the Elasticsearch stack. **We haven't tested and updated the code for Elasticsearch `8.0` yet**. | Rubygem | | Elasticsearch | |:-------------:|:-:| :-----------: | diff --git a/elasticsearch-persistence/README.md b/elasticsearch-persistence/README.md index 6b905f593..e8cb0aa8a 100644 --- a/elasticsearch-persistence/README.md +++ b/elasticsearch-persistence/README.md @@ -6,7 +6,7 @@ Persistence layer for Ruby domain objects in Elasticsearch, using the Repository This library is compatible with Ruby 2.4 and higher. -The library version numbers follow the Elasticsearch major versions. The `main` branch is compatible with the latest Elasticsearch stack stable release. +The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `7.x` of the Elasticsearch stack. **We haven't tested and updated the code for Elasticsearch `8.0` yet**. | Rubygem | | Elasticsearch | |:-------------:|:-:| :-----------: | @@ -14,6 +14,7 @@ The library version numbers follow the Elasticsearch major versions. The `main` | 2.x | → | 2.x | | 5.x | → | 5.x | | 6.x | → | 6.x | +| 7.x | → | 7.x | | main | → | 7.x | ## Installation diff --git a/elasticsearch-rails/README.md b/elasticsearch-rails/README.md index 375f379f5..12e7d7d59 100644 --- a/elasticsearch-rails/README.md +++ b/elasticsearch-rails/README.md @@ -8,8 +8,7 @@ library, providing features suitable for Ruby on Rails applications. This library is compatible with Ruby 1.9.3 and higher. -The library version numbers follow the Elasticsearch major versions, and the `main` branch -is compatible with the Elasticsearch `master` branch, therefore, with the next major version. +The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `7.x` of the Elasticsearch stack. **We haven't tested and updated the code for Elasticsearch `8.0` yet**. | Rubygem | | Elasticsearch | |:-------------:|:-:| :-----------: | @@ -18,7 +17,7 @@ is compatible with the Elasticsearch `master` branch, therefore, with the next m | 5.x | → | 5.x | | 6.x | → | 6.x | | 7.x | → | 7.x | -| main | → | master | +| main | → | 7.x | ## Installation From b887b63ad9117bbb84ca9bce4929b37a8b57b4e8 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 16 Jan 2023 09:19:02 +0000 Subject: [PATCH 063/113] Minor updates --- Gemfile | 12 ++-- elasticsearch-model/Rakefile | 6 +- .../elasticsearch-model.gemspec | 2 +- elasticsearch-model/gemfiles/6.0.gemfile | 5 +- .../elasticsearch/model/adapters/mongoid.rb | 20 +++--- elasticsearch-model/spec/spec_helper.rb | 6 +- elasticsearch-persistence/Rakefile | 15 +++-- .../elasticsearch-persistence.gemspec | 67 +++++++++---------- elasticsearch-rails/Rakefile | 2 + .../elasticsearch-rails.gemspec | 2 +- 10 files changed, 68 insertions(+), 69 deletions(-) diff --git a/Gemfile b/Gemfile index 255f70850..0edd2dd95 100644 --- a/Gemfile +++ b/Gemfile @@ -17,13 +17,13 @@ source 'https://rubygems.org' -gem "rake", "~> 12" -gem "elasticsearch" -gem "pry" -gem "ansi" -gem "cane" +gem 'ansi' +gem 'cane' +gem 'elasticsearch', '~> 7' +gem 'pry' +gem 'rake', '~> 12' group :development do - gem 'yard' gem 'rspec' + gem 'yard' end diff --git a/elasticsearch-model/Rakefile b/elasticsearch-model/Rakefile index ab1d6cab7..6e03532b0 100644 --- a/elasticsearch-model/Rakefile +++ b/elasticsearch-model/Rakefile @@ -48,12 +48,12 @@ require 'rake/testtask' namespace :test do desc 'Run all tests. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0' task :all, [:rails_versions] do |task, args| - gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map {|v| "#{v}.gemfile"} : GEMFILES + gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map { |v| "#{v}.gemfile" } : GEMFILES puts '-' * 80 gemfiles.each do |gemfile| puts "GEMFILE: #{gemfile}" - sh "BUNDLE_GEMFILE='#{File.expand_path("../gemfiles/#{gemfile}", __FILE__)}' " + - " bundle exec rspec" + sh "BUNDLE_GEMFILE='#{File.expand_path("../gemfiles/#{gemfile}", __FILE__)}' " \ + ' bundle exec rspec' puts '-' * 80 end end diff --git a/elasticsearch-model/elasticsearch-model.gemspec b/elasticsearch-model/elasticsearch-model.gemspec index 083938d51..b8f16c902 100644 --- a/elasticsearch-model/elasticsearch-model.gemspec +++ b/elasticsearch-model/elasticsearch-model.gemspec @@ -25,7 +25,7 @@ Gem::Specification.new do |s| s.name = 'elasticsearch-model' s.version = Elasticsearch::Model::VERSION s.authors = ['Karel Minarik'] - s.email = ['karel.minarik@elasticsearch.org'] + s.email = ['support@elastic.co'] s.description = 'ActiveModel/Record integrations for Elasticsearch.' s.summary = 'ActiveModel/Record integrations for Elasticsearch.' s.homepage = 'https://github.com/elasticsearch/elasticsearch-rails/' diff --git a/elasticsearch-model/gemfiles/6.0.gemfile b/elasticsearch-model/gemfiles/6.0.gemfile index dd859f68b..2461d66f0 100644 --- a/elasticsearch-model/gemfiles/6.0.gemfile +++ b/elasticsearch-model/gemfiles/6.0.gemfile @@ -20,7 +20,6 @@ # $ BUNDLE_GEMFILE=./gemfiles/6.0.gemfile bundle install # $ BUNDLE_GEMFILE=./gemfiles/6.0.gemfile bundle exec rake test:integration - source 'https://rubygems.org' gemspec path: '../' @@ -28,9 +27,9 @@ gemspec path: '../' gem 'activemodel', '6.0.0' gem 'activerecord', '6.0.0' gem 'sqlite3' unless defined?(JRUBY_VERSION) -#gem 'mongoid', '~> 6' +# gem 'mongoid', '~> 6' group :development, :testing do - gem 'rspec' gem 'pry-nav' + gem 'rspec' end diff --git a/elasticsearch-model/lib/elasticsearch/model/adapters/mongoid.rb b/elasticsearch-model/lib/elasticsearch/model/adapters/mongoid.rb index 8626d743c..850ea50ea 100644 --- a/elasticsearch-model/lib/elasticsearch/model/adapters/mongoid.rb +++ b/elasticsearch-model/lib/elasticsearch/model/adapters/mongoid.rb @@ -18,18 +18,21 @@ module Elasticsearch module Model module Adapter - # An adapter for Mongoid-based models # # @see http://mongoid.org # module Mongoid - - Adapter.register self, - lambda { |klass| !!defined?(::Mongoid::Document) && klass.respond_to?(:ancestors) && klass.ancestors.include?(::Mongoid::Document) } + Adapter.register( + self, + lambda do |klass| + !!defined?(::Mongoid::Document) && + klass.respond_to?(:ancestors) && + klass.ancestors.include?(::Mongoid::Document) + end + ) module Records - # Return a `Mongoid::Criteria` instance # def records @@ -59,7 +62,6 @@ def records end module Callbacks - # Handle index updates (creating, updating or deleting documents) # when the model changes, by hooking into the lifecycle # @@ -73,7 +75,6 @@ def self.included(base) end module Importing - # Fetch batches of records from the database # # @see https://github.com/mongoid/mongoid/issues/1334 @@ -88,19 +89,16 @@ def __find_in_batches(options={}, &block) scope = all scope = scope.send(named_scope) if named_scope scope = query.is_a?(Proc) ? scope.class_exec(&query) : scope.where(query) if query - scope.no_timeout.each_slice(batch_size) do |items| yield (preprocess ? self.__send__(preprocess, items) : items) end end def __transform - lambda {|a| { index: { _id: a.id.to_s, data: a.as_indexed_json } }} + lambda { |a| { index: { _id: a.id.to_s, data: a.as_indexed_json } } } end end - end - end end end diff --git a/elasticsearch-model/spec/spec_helper.rb b/elasticsearch-model/spec/spec_helper.rb index 3bb7f8742..413b5f03e 100644 --- a/elasticsearch-model/spec/spec_helper.rb +++ b/elasticsearch-model/spec/spec_helper.rb @@ -43,8 +43,10 @@ require 'ansi' tracer = ::Logger.new(STDERR) tracer.formatter = lambda { |s, d, p, m| "#{m.gsub(/^.*$/) { |n| ' ' + n }.ansi(:faint)}\n" } - Elasticsearch::Model.client = Elasticsearch::Client.new host: ELASTICSEARCH_URL, - tracer: (ENV['QUIET'] ? nil : tracer) + Elasticsearch::Model.client = Elasticsearch::Client.new( + host: ELASTICSEARCH_URL, + tracer: (ENV['QUIET'] ? nil : tracer) + ) puts "Elasticsearch Version: #{Elasticsearch::Model.client.info['version']}" unless ActiveRecord::Base.connected? diff --git a/elasticsearch-persistence/Rakefile b/elasticsearch-persistence/Rakefile index 6d53d4c22..07ba8c2a2 100644 --- a/elasticsearch-persistence/Rakefile +++ b/elasticsearch-persistence/Rakefile @@ -15,11 +15,11 @@ # specific language governing permissions and limitations # under the License. -require "bundler/gem_tasks" +require 'bundler/gem_tasks' -desc "Run unit tests" -task :default => 'test:unit' -task :test => 'test:unit' +desc 'Run unit tests' +task default: 'test:unit' +task test: 'test:unit' # ----- Test tasks ------------------------------------------------------------ @@ -27,14 +27,15 @@ require 'rake/testtask' require 'rspec/core/rake_task' namespace :test do - RSpec::Core::RakeTask.new(:spec) Rake::TestTask.new(:all) do |test| test.verbose = false test.warning = false - test.deps = [ :spec ] + test.deps = [:spec] end + + task unit: :spec end namespace :bundle do @@ -65,6 +66,6 @@ if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9' cane.style_measure = 120 end rescue LoadError - warn "cane not available, quality task not provided." + warn 'cane not available, quality task not provided.' end end diff --git a/elasticsearch-persistence/elasticsearch-persistence.gemspec b/elasticsearch-persistence/elasticsearch-persistence.gemspec index f1a736127..a37232c93 100644 --- a/elasticsearch-persistence/elasticsearch-persistence.gemspec +++ b/elasticsearch-persistence/elasticsearch-persistence.gemspec @@ -16,52 +16,49 @@ # under the License. # coding: utf-8 -lib = File.expand_path('../lib', __FILE__) + +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'elasticsearch/persistence/version' Gem::Specification.new do |s| - s.name = "elasticsearch-persistence" + s.name = 'elasticsearch-persistence' s.version = Elasticsearch::Persistence::VERSION - s.authors = ["Karel Minarik"] - s.email = ["karel.minarik@elasticsearch.org"] - s.description = "Persistence layer for Ruby models and Elasticsearch." - s.summary = "Persistence layer for Ruby models and Elasticsearch." - s.homepage = "https://github.com/elasticsearch/elasticsearch-rails/" - s.license = "Apache 2" + s.authors = ['Karel Minarik'] + s.email = ['support@elastic.co'] + s.description = 'Persistence layer for Ruby models and Elasticsearch.' + s.summary = 'Persistence layer for Ruby models and Elasticsearch.' + s.homepage = 'https://github.com/elasticsearch/elasticsearch-rails/' + s.license = 'Apache 2' s.files = `git ls-files -z`.split("\x0") s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } s.test_files = s.files.grep(%r{^(test|spec|features)/}) - s.require_paths = ["lib"] - - s.extra_rdoc_files = [ "README.md", "LICENSE.txt" ] - s.rdoc_options = [ "--charset=UTF-8" ] - - s.required_ruby_version = ">= 1.9.3" - - s.add_dependency "elasticsearch", '~> 7' - s.add_dependency "elasticsearch-model", '7.2.1' - s.add_dependency "activesupport", '> 4' - s.add_dependency "activemodel", '> 4' - s.add_dependency "hashie" - - s.add_development_dependency "bundler" - s.add_development_dependency "rake", "~> 12" + s.require_paths = ['lib'] - s.add_development_dependency "oj" unless defined?(JRUBY_VERSION) + s.extra_rdoc_files = ['README.md', 'LICENSE.txt'] + s.rdoc_options = ['--charset=UTF-8'] - s.add_development_dependency "rails", '> 4' + s.required_ruby_version = '>= 1.9.3' - s.add_development_dependency "minitest" - s.add_development_dependency "test-unit" - s.add_development_dependency "shoulda-context" - s.add_development_dependency "mocha" - s.add_development_dependency "turn" - s.add_development_dependency "yard" - s.add_development_dependency "ruby-prof" unless defined?(JRUBY_VERSION) - s.add_development_dependency "pry" + s.add_dependency 'activemodel', '> 4' + s.add_dependency 'activesupport', '> 4' + s.add_dependency 'elasticsearch', '~> 7' + s.add_dependency 'elasticsearch-model', '7.2.1' + s.add_dependency 'hashie' - s.add_development_dependency "simplecov" - s.add_development_dependency "cane" + s.add_development_dependency 'bundler' + s.add_development_dependency 'cane' + s.add_development_dependency 'minitest' + s.add_development_dependency 'mocha' + s.add_development_dependency 'oj' unless defined?(JRUBY_VERSION) + s.add_development_dependency 'pry' + s.add_development_dependency 'rails', '> 4' + s.add_development_dependency 'rake', '~> 12' + s.add_development_dependency 'ruby-prof' unless defined?(JRUBY_VERSION) + s.add_development_dependency 'shoulda-context' + s.add_development_dependency 'simplecov' + s.add_development_dependency 'test-unit' + s.add_development_dependency 'turn' + s.add_development_dependency 'yard' end diff --git a/elasticsearch-rails/Rakefile b/elasticsearch-rails/Rakefile index 20c7d1616..bbd245469 100644 --- a/elasticsearch-rails/Rakefile +++ b/elasticsearch-rails/Rakefile @@ -34,6 +34,8 @@ namespace :test do test.warning = false test.deps = [:spec] unless defined?(JRUBY_VERSION) end + + task unit: :spec end namespace :bundle do diff --git a/elasticsearch-rails/elasticsearch-rails.gemspec b/elasticsearch-rails/elasticsearch-rails.gemspec index 9b2b34781..0ba3f2b22 100644 --- a/elasticsearch-rails/elasticsearch-rails.gemspec +++ b/elasticsearch-rails/elasticsearch-rails.gemspec @@ -24,7 +24,7 @@ Gem::Specification.new do |s| s.name = 'elasticsearch-rails' s.version = Elasticsearch::Rails::VERSION s.authors = ['Karel Minarik'] - s.email = ['karel.minarik@elasticsearch.org'] + s.email = ['support@elastic.co'] s.description = 'Ruby on Rails integrations for Elasticsearch.' s.summary = 'Ruby on Rails integrations for Elasticsearch.' s.homepage = 'https://github.com/elasticsearch/elasticsearch-rails/' From 5605d1fe69d3727bf1d0c703d5510583e8acc96b Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 16 Jan 2023 10:22:52 +0000 Subject: [PATCH 064/113] [CI] Removing 2.4 and 2.5 tests in CI --- .github/workflows/2.4.yml | 46 -------------------------------------- .github/workflows/2.5.yml | 47 --------------------------------------- 2 files changed, 93 deletions(-) delete mode 100644 .github/workflows/2.4.yml delete mode 100644 .github/workflows/2.5.yml diff --git a/.github/workflows/2.4.yml b/.github/workflows/2.4.yml deleted file mode 100644 index 890c78613..000000000 --- a/.github/workflows/2.4.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Ruby 2.4 -on: - push: - branches: - - main - pull_request: - branches: - - main - workflow_dispatch: - branches: - - '*' -jobs: - tests: - env: - TEST_ES_SERVER: http://localhost:9200 - RAILS_VERSIONS: '5.0' - strategy: - fail-fast: false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Increase system limits - run: | - sudo swapoff -a - sudo sysctl -w vm.swappiness=1 - sudo sysctl -w fs.file-max=262144 - sudo sysctl -w vm.max_map_count=262144 - - uses: elastic/elastic-github-actions/elasticsearch@master - with: - stack-version: 7.x-SNAPSHOT - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.4 - - name: Bundle - run: | - sudo apt-get install libsqlite3-dev - gem install bundler - bundle install - bundle exec rake bundle:clean - bundle exec rake bundle:install - - name: Test elasticsearch-rails - run: cd elasticsearch-rails && bundle exec rake test:all - - name: Test elasticsearch-persistence - run: cd elasticsearch-persistence && bundle exec rake test:all - - name: Test elasticsearch-model - run: cd elasticsearch-model && bundle exec rake test:all diff --git a/.github/workflows/2.5.yml b/.github/workflows/2.5.yml deleted file mode 100644 index 68f8294fe..000000000 --- a/.github/workflows/2.5.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Ruby 2.5 -on: - push: - branches: - - main - pull_request: - branches: - - main - workflow_dispatch: - branches: - - '*' -jobs: - tests: - env: - TEST_ES_SERVER: http://localhost:9200 - RAILS_VERSIONS: '5.0,6.0' - strategy: - fail-fast: false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Increase system limits - run: | - sudo swapoff -a - sudo sysctl -w vm.swappiness=1 - sudo sysctl -w fs.file-max=262144 - sudo sysctl -w vm.max_map_count=262144 - - uses: elastic/elastic-github-actions/elasticsearch@master - with: - stack-version: 7.x-SNAPSHOT - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.5 - - name: Bundle - run: | - sudo apt-get install libsqlite3-dev - gem install bundler - bundle install - bundle exec rake bundle:clean - bundle exec rake bundle:install - - name: Test elasticsearch-rails - run: cd elasticsearch-rails && bundle exec rake test:all - - name: Test elasticsearch-persistence - run: cd elasticsearch-persistence && bundle exec rake test:all - - name: Test elasticsearch-model - run: cd elasticsearch-model && bundle exec rake test:all - From f0ca114689a73522d004805da21da1a31fdf72f0 Mon Sep 17 00:00:00 2001 From: done <23427957+sensuikan1973@users.noreply.github.com> Date: Fri, 2 Jun 2023 14:48:20 +0900 Subject: [PATCH 065/113] Update README.md --- elasticsearch-model/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/elasticsearch-model/README.md b/elasticsearch-model/README.md index c7d90150a..0e120c349 100644 --- a/elasticsearch-model/README.md +++ b/elasticsearch-model/README.md @@ -16,6 +16,7 @@ The version numbers follow the Elasticsearch major versions. Currently the `main | 2.x | → | 2.x | | 5.x | → | 5.x | | 6.x | → | 6.x | +| 7.x | → | 7.x | | main | → | 7.x | ## Installation From 55096833b7771a3ce4443931c8da0afcc6bbade2 Mon Sep 17 00:00:00 2001 From: Nigel Small Date: Mon, 21 Aug 2023 14:16:56 +0100 Subject: [PATCH 066/113] Updated project metadata to use group email address --- elasticsearch-persistence/elasticsearch-persistence.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch-persistence/elasticsearch-persistence.gemspec b/elasticsearch-persistence/elasticsearch-persistence.gemspec index a37232c93..893103d4b 100644 --- a/elasticsearch-persistence/elasticsearch-persistence.gemspec +++ b/elasticsearch-persistence/elasticsearch-persistence.gemspec @@ -24,8 +24,8 @@ require 'elasticsearch/persistence/version' Gem::Specification.new do |s| s.name = 'elasticsearch-persistence' s.version = Elasticsearch::Persistence::VERSION - s.authors = ['Karel Minarik'] - s.email = ['support@elastic.co'] + s.authors = ['Elastic Client Library Maintainers'] + s.email = ['client-libs@elastic.co'] s.description = 'Persistence layer for Ruby models and Elasticsearch.' s.summary = 'Persistence layer for Ruby models and Elasticsearch.' s.homepage = 'https://github.com/elasticsearch/elasticsearch-rails/' From 8fe0a555083d16d9d64dea7b0ae8a8695c1d4211 Mon Sep 17 00:00:00 2001 From: Nigel Small Date: Mon, 21 Aug 2023 14:19:10 +0100 Subject: [PATCH 067/113] Added other files --- elasticsearch-model/elasticsearch-model.gemspec | 4 ++-- elasticsearch-rails/elasticsearch-rails.gemspec | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/elasticsearch-model/elasticsearch-model.gemspec b/elasticsearch-model/elasticsearch-model.gemspec index b8f16c902..0dc71775c 100644 --- a/elasticsearch-model/elasticsearch-model.gemspec +++ b/elasticsearch-model/elasticsearch-model.gemspec @@ -24,8 +24,8 @@ require 'elasticsearch/model/version' Gem::Specification.new do |s| s.name = 'elasticsearch-model' s.version = Elasticsearch::Model::VERSION - s.authors = ['Karel Minarik'] - s.email = ['support@elastic.co'] + s.authors = ['Elastic Client Library Maintainers'] + s.email = ['client-libs@elastic.co'] s.description = 'ActiveModel/Record integrations for Elasticsearch.' s.summary = 'ActiveModel/Record integrations for Elasticsearch.' s.homepage = 'https://github.com/elasticsearch/elasticsearch-rails/' diff --git a/elasticsearch-rails/elasticsearch-rails.gemspec b/elasticsearch-rails/elasticsearch-rails.gemspec index 0ba3f2b22..ac9375233 100644 --- a/elasticsearch-rails/elasticsearch-rails.gemspec +++ b/elasticsearch-rails/elasticsearch-rails.gemspec @@ -23,8 +23,8 @@ require 'elasticsearch/rails/version' Gem::Specification.new do |s| s.name = 'elasticsearch-rails' s.version = Elasticsearch::Rails::VERSION - s.authors = ['Karel Minarik'] - s.email = ['support@elastic.co'] + s.authors = ['Elastic Client Library Maintainers'] + s.email = ['client-libs@elastic.co'] s.description = 'Ruby on Rails integrations for Elasticsearch.' s.summary = 'Ruby on Rails integrations for Elasticsearch.' s.homepage = 'https://github.com/elasticsearch/elasticsearch-rails/' From d9c494e8a930639918135688ad98ead769acc188 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Tue, 28 Nov 2023 15:59:16 +0900 Subject: [PATCH 068/113] `ruby2_keywords` is not an instance method --- elasticsearch-model/lib/elasticsearch/model/proxy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/proxy.rb b/elasticsearch-model/lib/elasticsearch/model/proxy.rb index 6fdf66322..69a6059d2 100644 --- a/elasticsearch-model/lib/elasticsearch/model/proxy.rb +++ b/elasticsearch-model/lib/elasticsearch/model/proxy.rb @@ -115,7 +115,7 @@ def initialize(target) @target = target end - def ruby2_keywords(*) # :nodoc: + def self.ruby2_keywords(*) # :nodoc: end if RUBY_VERSION < "2.7" # Delegate methods to `@target`. As per [the Ruby 3.0 explanation for keyword arguments](https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/), the only way to work on Ruby <2.7, and 2.7, and 3.0+ is to use `ruby2_keywords`. From 110b07bfea9fd504cbac08ce6c2e1a9da1ef094c Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 19 Jan 2023 11:24:41 +0000 Subject: [PATCH 069/113] Initial work on gemfiles --- elasticsearch-model/Rakefile | 3 +- .../elasticsearch-model.gemspec | 2 +- elasticsearch-model/gemfiles/3.0.gemfile | 35 ------------------ elasticsearch-model/gemfiles/4.0.gemfile | 36 ------------------- .../gemfiles/{6.0.gemfile => 6.1.gemfile} | 5 +-- .../gemfiles/{5.0.gemfile => 7.0.gemfile} | 13 +++---- .../elasticsearch-persistence.gemspec | 2 +- .../elasticsearch-rails.gemspec | 2 +- 8 files changed, 14 insertions(+), 84 deletions(-) delete mode 100644 elasticsearch-model/gemfiles/3.0.gemfile delete mode 100644 elasticsearch-model/gemfiles/4.0.gemfile rename elasticsearch-model/gemfiles/{6.0.gemfile => 6.1.gemfile} (94%) rename elasticsearch-model/gemfiles/{5.0.gemfile => 7.0.gemfile} (82%) diff --git a/elasticsearch-model/Rakefile b/elasticsearch-model/Rakefile index 6e03532b0..a57680a9a 100644 --- a/elasticsearch-model/Rakefile +++ b/elasticsearch-model/Rakefile @@ -21,8 +21,7 @@ desc 'Run unit tests' task default: 'test:all' task test: 'test:all' -gemfiles = ['5.0.gemfile', '6.0.gemfile'] -gemfiles << '4.0.gemfile' if RUBY_VERSION < '2.7' +gemfiles = ['6.1.gemfile', '7.0.gemfile'] GEMFILES = gemfiles.freeze namespace :bundle do diff --git a/elasticsearch-model/elasticsearch-model.gemspec b/elasticsearch-model/elasticsearch-model.gemspec index 0dc71775c..66712701f 100644 --- a/elasticsearch-model/elasticsearch-model.gemspec +++ b/elasticsearch-model/elasticsearch-model.gemspec @@ -39,7 +39,7 @@ Gem::Specification.new do |s| s.extra_rdoc_files = ['README.md', 'LICENSE.txt'] s.rdoc_options = ['--charset=UTF-8'] - s.required_ruby_version = '>= 2.4' + s.required_ruby_version = '>= 3' s.add_dependency 'activesupport', '> 3' s.add_dependency 'elasticsearch', '~> 7' diff --git a/elasticsearch-model/gemfiles/3.0.gemfile b/elasticsearch-model/gemfiles/3.0.gemfile deleted file mode 100644 index 1641023d7..000000000 --- a/elasticsearch-model/gemfiles/3.0.gemfile +++ /dev/null @@ -1,35 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# Usage: -# -# $ BUNDLE_GEMFILE=./gemfiles/3.0.gemfile bundle install -# $ BUNDLE_GEMFILE=./gemfiles/3.0.gemfile bundle exec rake test:integration - -source 'https://rubygems.org' - -gemspec path: '../' - -gem 'activemodel', '>= 3.0' -gem 'activerecord', '~> 3.2' -gem 'mongoid', '>= 3.0' -gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION) - -group :development, :testing do - gem 'rspec' - gem 'pry-nav' -end \ No newline at end of file diff --git a/elasticsearch-model/gemfiles/4.0.gemfile b/elasticsearch-model/gemfiles/4.0.gemfile deleted file mode 100644 index 944568fce..000000000 --- a/elasticsearch-model/gemfiles/4.0.gemfile +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# Usage: -# -# $ BUNDLE_GEMFILE=./gemfiles/4.0.gemfile bundle install -# $ BUNDLE_GEMFILE=./gemfiles/4.0.gemfile bundle exec rake test:integration - -source 'https://rubygems.org' - -gemspec path: '../' - -gem 'activemodel', '~> 4' -gem 'activerecord', '~> 4' -gem 'mongoid', '~> 5' -gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION) - -group :development, :testing do - gem 'bigdecimal', '~> 1' - gem 'pry-nav' - gem 'rspec' -end diff --git a/elasticsearch-model/gemfiles/6.0.gemfile b/elasticsearch-model/gemfiles/6.1.gemfile similarity index 94% rename from elasticsearch-model/gemfiles/6.0.gemfile rename to elasticsearch-model/gemfiles/6.1.gemfile index 2461d66f0..5e5be171f 100644 --- a/elasticsearch-model/gemfiles/6.0.gemfile +++ b/elasticsearch-model/gemfiles/6.1.gemfile @@ -24,12 +24,13 @@ source 'https://rubygems.org' gemspec path: '../' -gem 'activemodel', '6.0.0' -gem 'activerecord', '6.0.0' +gem 'activemodel', '6.1' +gem 'activerecord', '6.1' gem 'sqlite3' unless defined?(JRUBY_VERSION) # gem 'mongoid', '~> 6' group :development, :testing do + gem 'byebug' gem 'pry-nav' gem 'rspec' end diff --git a/elasticsearch-model/gemfiles/5.0.gemfile b/elasticsearch-model/gemfiles/7.0.gemfile similarity index 82% rename from elasticsearch-model/gemfiles/5.0.gemfile rename to elasticsearch-model/gemfiles/7.0.gemfile index 8b1930961..4479207e1 100644 --- a/elasticsearch-model/gemfiles/5.0.gemfile +++ b/elasticsearch-model/gemfiles/7.0.gemfile @@ -17,19 +17,20 @@ # Usage: # -# $ BUNDLE_GEMFILE=./gemfiles/5.0.gemfile bundle install -# $ BUNDLE_GEMFILE=./gemfiles/5.0.gemfile bundle exec rake test:integration +# $ BUNDLE_GEMFILE=./gemfiles/7.0.gemfile bundle install +# $ BUNDLE_GEMFILE=./gemfiles/7.0.gemfile bundle exec rake test:integration source 'https://rubygems.org' gemspec path: '../' -gem 'activemodel', '~> 5' -gem 'activerecord', '~> 5' +gem 'activemodel', '7' +gem 'activerecord', '7' gem 'sqlite3' unless defined?(JRUBY_VERSION) -gem 'mongoid', '~> 6' +# gem 'mongoid', '~> 6' group :development, :testing do - gem 'rspec' + gem 'byebug' gem 'pry-nav' + gem 'rspec' end diff --git a/elasticsearch-persistence/elasticsearch-persistence.gemspec b/elasticsearch-persistence/elasticsearch-persistence.gemspec index 893103d4b..c8f5d0fa2 100644 --- a/elasticsearch-persistence/elasticsearch-persistence.gemspec +++ b/elasticsearch-persistence/elasticsearch-persistence.gemspec @@ -39,7 +39,7 @@ Gem::Specification.new do |s| s.extra_rdoc_files = ['README.md', 'LICENSE.txt'] s.rdoc_options = ['--charset=UTF-8'] - s.required_ruby_version = '>= 1.9.3' + s.required_ruby_version = '>= 3' s.add_dependency 'activemodel', '> 4' s.add_dependency 'activesupport', '> 4' diff --git a/elasticsearch-rails/elasticsearch-rails.gemspec b/elasticsearch-rails/elasticsearch-rails.gemspec index ac9375233..f7f2f5077 100644 --- a/elasticsearch-rails/elasticsearch-rails.gemspec +++ b/elasticsearch-rails/elasticsearch-rails.gemspec @@ -44,7 +44,7 @@ Gem::Specification.new do |s| s.extra_rdoc_files = ['README.md', 'LICENSE.txt'] s.rdoc_options = ['--charset=UTF-8'] - s.required_ruby_version = '>= 2.4' + s.required_ruby_version = '>= 3' s.add_development_dependency 'bundler' s.add_development_dependency 'cane' From 99d906f8e7b6fb90090c74ac51d7df589a780087 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 19 Jan 2023 11:25:22 +0000 Subject: [PATCH 070/113] Rubocoping: whitespace and styling --- .../lib/elasticsearch/model/adapter.rb | 2 -- .../lib/elasticsearch/model/importing.rb | 5 +---- .../lib/elasticsearch/model/proxy.rb | 4 ---- .../spec/elasticsearch/model/adapter_spec.rb | 11 ---------- .../adapters/active_record/import_spec.rb | 4 ++-- .../elasticsearch/model/importing_spec.rb | 21 ++----------------- 6 files changed, 5 insertions(+), 42 deletions(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/adapter.rb b/elasticsearch-model/lib/elasticsearch/model/adapter.rb index cdb0c7d0e..3283112e9 100644 --- a/elasticsearch-model/lib/elasticsearch/model/adapter.rb +++ b/elasticsearch-model/lib/elasticsearch/model/adapter.rb @@ -17,7 +17,6 @@ module Elasticsearch module Model - # Contains an adapter which provides OxM-specific implementations for common behaviour: # # * {Adapter::Adapter#records_mixin Fetching records from the database} @@ -29,7 +28,6 @@ module Model # @see Elasticsearch::Model::Adapter::Mongoid # module Adapter - # Returns an adapter based on the Ruby class passed # # @example Create an adapter for an ActiveRecord-based model diff --git a/elasticsearch-model/lib/elasticsearch/model/importing.rb b/elasticsearch-model/lib/elasticsearch/model/importing.rb index 927dd16ee..8655f9ac4 100644 --- a/elasticsearch-model/lib/elasticsearch/model/importing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/importing.rb @@ -17,14 +17,12 @@ module Elasticsearch module Model - # Provides support for easily and efficiently importing large amounts of # records from the including class into the index. # # @see ClassMethods#import # module Importing - # When included in a model, adds the importing methods. # # @example Import all records from the `Article` model @@ -42,13 +40,12 @@ def self.included(base) end module ClassMethods - # Import all model records into the index # # The method will pick up correct strategy based on the `Importing` module # defined in the corresponding adapter. # - # @param options [Hash] Options passed to the underlying `__find_in_batches`method + # @param options [Hash] Options passed to the underlying `__find_in_batches` method # @param block [Proc] Optional block to evaluate for each batch # # @yield [Hash] Gives the Hash with the Elasticsearch response to the block diff --git a/elasticsearch-model/lib/elasticsearch/model/proxy.rb b/elasticsearch-model/lib/elasticsearch/model/proxy.rb index 69a6059d2..8a93bc359 100644 --- a/elasticsearch-model/lib/elasticsearch/model/proxy.rb +++ b/elasticsearch-model/lib/elasticsearch/model/proxy.rb @@ -17,7 +17,6 @@ module Elasticsearch module Model - # This module provides a proxy interfacing between the including class and # `Elasticsearch::Model`, preventing the pollution of the including class namespace. # @@ -45,7 +44,6 @@ module Model # # => true # module Proxy - # Define the `__elasticsearch__` class and instance methods in the including class # and register a callback for intercepting changes in the model. # @@ -53,9 +51,7 @@ module Proxy # module and the functionality is accessible via the proxy. # def self.included(base) - base.class_eval do - # `ClassMethodsProxy` instance, accessed as `MyModel.__elasticsearch__` def self.__elasticsearch__ &block @__elasticsearch__ ||= ClassMethodsProxy.new(self) diff --git a/elasticsearch-model/spec/elasticsearch/model/adapter_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapter_spec.rb index 33dd62590..a2f2f850a 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapter_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapter_spec.rb @@ -18,7 +18,6 @@ require 'spec_helper' describe Elasticsearch::Model::Adapter do - before(:all) do class ::DummyAdapterClass; end class ::DummyAdapterClassWithAdapter; end @@ -37,14 +36,12 @@ class ::DummyAdapter end describe '#from_class' do - it 'should return an Adapter instance' do expect(Elasticsearch::Model::Adapter.from_class(DummyAdapterClass)).to be_a(Elasticsearch::Model::Adapter::Adapter) end end describe 'register' do - before do expect(Elasticsearch::Model::Adapter::Adapter).to receive(:register).and_call_original Elasticsearch::Model::Adapter.register(:foo, lambda { |c| false }) @@ -55,7 +52,6 @@ class ::DummyAdapter end context 'when a specific adapter class is set' do - before do expect(Elasticsearch::Model::Adapter::Adapter).to receive(:register).and_call_original Elasticsearch::Model::Adapter::Adapter.register(DummyAdapter, @@ -73,7 +69,6 @@ class ::DummyAdapter end describe 'default adapter' do - let(:adapter) do Elasticsearch::Model::Adapter::Adapter.new(DummyAdapterClass) end @@ -84,11 +79,9 @@ class ::DummyAdapter end describe '#records_mixin' do - before do Elasticsearch::Model::Adapter::Adapter.register(DummyAdapter, lambda { |c| c == DummyAdapterClassWithAdapter }) - end let(:adapter) do @@ -101,11 +94,9 @@ class ::DummyAdapter end describe '#callbacks_mixin' do - before do Elasticsearch::Model::Adapter::Adapter.register(DummyAdapter, lambda { |c| c == DummyAdapterClassWithAdapter }) - end let(:adapter) do @@ -118,11 +109,9 @@ class ::DummyAdapter end describe '#importing_mixin' do - before do Elasticsearch::Model::Adapter::Adapter.register(DummyAdapter, lambda { |c| c == DummyAdapterClassWithAdapter }) - end let(:adapter) do diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb index 1f5fe0847..a23e58c37 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb @@ -19,12 +19,12 @@ describe 'Elasticsearch::Model::Adapter::ActiveRecord Importing' do before(:all) do - ActiveRecord::Schema.define(:version => 1) do + ActiveRecord::Schema.define(version: 1) do create_table :import_articles do |t| t.string :title t.integer :views t.string :numeric # For the sake of invalid data sent to Elasticsearch - t.datetime :created_at, :default => 'NOW()' + t.datetime :created_at, default: 'NOW()' end end diff --git a/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb index 02cde6d6c..343e04d00 100644 --- a/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb @@ -18,18 +18,17 @@ require 'spec_helper' describe Elasticsearch::Model::Importing do - before(:all) do class DummyImportingModel end module DummyImportingAdapter module ImportingMixin - def __find_in_batches(options={}, &block) + def __find_in_batches( options = {}, &block) yield if block_given? end def __transform - lambda {|a|} + lambda { |a| } end end @@ -49,7 +48,6 @@ def importing_mixin end context 'when a model includes the Importing module' do - it 'provides importing methods' do expect(DummyImportingModel.respond_to?(:import)).to be(true) expect(DummyImportingModel.respond_to?(:__find_in_batches)).to be(true) @@ -57,7 +55,6 @@ def importing_mixin end describe '#import' do - before do allow(DummyImportingModel).to receive(:index_name).and_return('foo') allow(DummyImportingModel).to receive(:document_type).and_return('foo') @@ -75,7 +72,6 @@ def importing_mixin end context 'when no options are provided' do - before do expect(DummyImportingModel).to receive(:client).and_return(client) allow(DummyImportingModel).to receive(:index_exists?).and_return(true) @@ -87,7 +83,6 @@ def importing_mixin end context 'when there is an error' do - before do expect(DummyImportingModel).to receive(:client).and_return(client) allow(DummyImportingModel).to receive(:index_exists?).and_return(true) @@ -102,14 +97,12 @@ def importing_mixin end context 'when the method is called with the option to return the errors' do - it 'returns the errors' do expect(DummyImportingModel.import(return: 'errors')).to eq([{ 'index' => { 'error' => 'FAILED' } }]) end end context 'when the method is called with a block' do - it 'yields the response to the block' do DummyImportingModel.import do |response| expect(response['items'].size).to eq(2) @@ -119,7 +112,6 @@ def importing_mixin end context 'when the index does not exist' do - before do allow(DummyImportingModel).to receive(:index_exists?).and_return(false) end @@ -132,7 +124,6 @@ def importing_mixin end context 'when the method is called with the force option' do - before do expect(DummyImportingModel).to receive(:create_index!).with(force: true, index: 'foo').and_return(true) expect(DummyImportingModel).to receive(:__find_in_batches).with(foo: 'bar').and_return(true) @@ -144,7 +135,6 @@ def importing_mixin end context 'when the method is called with the refresh option' do - before do expect(DummyImportingModel).to receive(:refresh_index!).with(index: 'foo').and_return(true) expect(DummyImportingModel).to receive(:__find_in_batches).with(foo: 'bar').and_return(true) @@ -156,7 +146,6 @@ def importing_mixin end context 'when a different index name is provided' do - before do expect(DummyImportingModel).to receive(:client).and_return(client) expect(client).to receive(:bulk).with(body: nil, index: 'my-new-index', type: 'foo').and_return(response) @@ -168,7 +157,6 @@ def importing_mixin end context 'when a different document type is provided' do - before do expect(DummyImportingModel).to receive(:client).and_return(client) expect(client).to receive(:bulk).with(body: nil, index: 'foo', type: 'my-new-type').and_return(response) @@ -180,7 +168,6 @@ def importing_mixin end context 'the transform method' do - before do expect(DummyImportingModel).to receive(:client).and_return(client) expect(DummyImportingModel).to receive(:__transform).and_return(transform) @@ -197,9 +184,7 @@ def importing_mixin end context 'when a transform is provided as an option' do - context 'when the transform option is not a lambda' do - let(:transform) do 'not_callable' end @@ -212,7 +197,6 @@ def importing_mixin end context 'when the transform option is a lambda' do - before do expect(DummyImportingModel).to receive(:client).and_return(client) expect(DummyImportingModel).to receive(:__batch_to_bulk).with(anything, transform) @@ -229,7 +213,6 @@ def importing_mixin end context 'when a pipeline is provided as an options' do - before do expect(DummyImportingModel).to receive(:client).and_return(client) expect(client).to receive(:bulk).with(body: nil, index: 'foo', type: 'foo', pipeline: 'my-pipeline').and_return(response) From bec2e7776e1247433947191905f86885c0f2fc7a Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 19 Jan 2023 11:25:58 +0000 Subject: [PATCH 071/113] Updates gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 43ddc2e30..e3359ace9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ coverage/ rdoc/ doc/ Gemfile.lock +.byebug_history \ No newline at end of file From a2132ac79c6fa7f470edceced6c75802a56f553e Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 20 Jun 2023 16:04:41 +0100 Subject: [PATCH 072/113] Updates dependency on elasticsearch gem to 8 Replaces Elasticsearch::Transport with Elastic::Transport --- Gemfile | 2 +- Rakefile | 2 +- elasticsearch-model/README.md | 21 ++++++++++--------- .../elasticsearch-model.gemspec | 2 +- .../lib/elasticsearch/model/importing.rb | 2 -- .../lib/elasticsearch/model/multimodel.rb | 2 +- .../adapters/active_record/basic_spec.rb | 1 - .../spec/elasticsearch/model/indexing_spec.rb | 6 +++--- .../model/response/result_spec.rb | 1 - .../persistence/repository/find.rb | 2 +- .../spec/repository/store_spec.rb | 6 +++--- .../spec/repository_spec.rb | 2 +- 12 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Gemfile b/Gemfile index 0edd2dd95..b6cb7cca7 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ source 'https://rubygems.org' gem 'ansi' gem 'cane' -gem 'elasticsearch', '~> 7' +gem 'elasticsearch', '~> 8' gem 'pry' gem 'rake', '~> 12' diff --git a/Rakefile b/Rakefile index 9b3347f86..4d49a8f34 100644 --- a/Rakefile +++ b/Rakefile @@ -163,7 +163,7 @@ task :wait_for_green do ready = true break end - rescue Elasticsearch::Transport::Transport::Errors::RequestTimeout => ex + rescue Elastic::Transport::Transport::Errors::RequestTimeout => ex puts "Couldn't confirm green status.\n#{ex.inspect}." rescue Faraday::ConnectionFailed => ex puts "Couldn't connect to Elasticsearch.\n#{ex.inspect}." diff --git a/elasticsearch-model/README.md b/elasticsearch-model/README.md index 0e120c349..655485495 100644 --- a/elasticsearch-model/README.md +++ b/elasticsearch-model/README.md @@ -6,18 +6,19 @@ It aims to simplify integration of Ruby classes ("models"), commonly found e.g. ## Compatibility -This library is compatible with Ruby 2.4 and higher. +This library is compatible with Ruby 3 and higher. The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `7.x` of the Elasticsearch stack. **We haven't tested and updated the code for Elasticsearch `8.0` yet**. -| Rubygem | | Elasticsearch | -|:-------------:|:-:| :-----------: | -| 0.1 | → | 1.x | -| 2.x | → | 2.x | -| 5.x | → | 5.x | -| 6.x | → | 6.x | -| 7.x | → | 7.x | -| main | → | 7.x | +| Rubygem | | Elasticsearch | +|:-------:|:-:|:-------------:| +| 0.1 | → | 1.x | +| 2.x | → | 2.x | +| 5.x | → | 5.x | +| 6.x | → | 6.x | +| 7.x | → | 7.x | +| 8.x | → | 8.x | +| main | → | 8.x | ## Installation @@ -532,7 +533,7 @@ class Indexer when /delete/ begin Client.delete index: 'articles', type: 'article', id: record_id - rescue Elasticsearch::Transport::Transport::Errors::NotFound + rescue Elastic::Transport::Transport::Errors::NotFound logger.debug "Article not found, ID: #{record_id}" end else raise ArgumentError, "Unknown operation '#{operation}'" diff --git a/elasticsearch-model/elasticsearch-model.gemspec b/elasticsearch-model/elasticsearch-model.gemspec index 66712701f..c00b5c87a 100644 --- a/elasticsearch-model/elasticsearch-model.gemspec +++ b/elasticsearch-model/elasticsearch-model.gemspec @@ -42,7 +42,7 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 3' s.add_dependency 'activesupport', '> 3' - s.add_dependency 'elasticsearch', '~> 7' + s.add_dependency 'elasticsearch', '~> 8' s.add_dependency 'hashie' s.add_development_dependency 'activemodel', '> 3' diff --git a/elasticsearch-model/lib/elasticsearch/model/importing.rb b/elasticsearch-model/lib/elasticsearch/model/importing.rb index 8655f9ac4..b9f9ea392 100644 --- a/elasticsearch-model/lib/elasticsearch/model/importing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/importing.rb @@ -185,8 +185,6 @@ def __batch_to_bulk(batch, transform) batch.map { |model| transform.call(model) } end end - end - end end diff --git a/elasticsearch-model/lib/elasticsearch/model/multimodel.rb b/elasticsearch-model/lib/elasticsearch/model/multimodel.rb index 6b5fc2a81..b8c415cad 100644 --- a/elasticsearch-model/lib/elasticsearch/model/multimodel.rb +++ b/elasticsearch-model/lib/elasticsearch/model/multimodel.rb @@ -90,7 +90,7 @@ def document_type # Get the client common for all models # - # @return Elasticsearch::Transport::Client + # @return Elastic::Transport::Client # def client Elasticsearch::Model.client diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb index a769b38f6..9c62a03a6 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb @@ -20,7 +20,6 @@ describe Elasticsearch::Model::Adapter::ActiveRecord do context 'when a document_type is not defined for the Model' do - before do ActiveRecord::Schema.define(:version => 1) do create_table :article_no_types do |t| diff --git a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb index eb9651a73..b4d5777da 100644 --- a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb @@ -678,7 +678,7 @@ class ::DummyIndexingModelForRecreate context 'when the index is not found' do let(:logger) { nil } let(:transport) do - Elasticsearch::Transport::Client.new(logger: logger) + Elastic::Transport::Client.new(logger: logger) end let(:client) do @@ -918,7 +918,7 @@ class ::DummyIndexingModelForRefresh end let(:transport) do - Elasticsearch::Transport::Client.new(logger: nil) + Elastic::Transport::Client.new(logger: nil) end let(:indices) do @@ -949,7 +949,7 @@ class ::DummyIndexingModelForRefresh end let(:transport) do - Elasticsearch::Transport::Client.new(logger: logger) + Elastic::Transport::Client.new(logger: logger) end it 'does not raise an exception' do diff --git a/elasticsearch-model/spec/elasticsearch/model/response/result_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/result_spec.rb index 5aa7c8f4f..c3c73fec6 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/result_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/result_spec.rb @@ -19,7 +19,6 @@ require 'active_support/json/encoding' describe Elasticsearch::Model::Response::Result do - let(:result) do described_class.new(foo: 'bar', bar: { bam: 'baz' }) end diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/find.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/find.rb index cdd50c042..fad2593e8 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/find.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/find.rb @@ -87,7 +87,7 @@ def __find_one(id, options={}) request[:type] = document_type if document_type document = client.get(request.merge(options)) deserialize(document) - rescue Elasticsearch::Transport::Transport::Errors::NotFound => e + rescue Elastic::Transport::Transport::Errors::NotFound => e raise DocumentNotFound, e.message, caller end diff --git a/elasticsearch-persistence/spec/repository/store_spec.rb b/elasticsearch-persistence/spec/repository/store_spec.rb index bebf810aa..92b7035e7 100644 --- a/elasticsearch-persistence/spec/repository/store_spec.rb +++ b/elasticsearch-persistence/spec/repository/store_spec.rb @@ -242,7 +242,7 @@ def to_hash it 'raises an exception' do expect { repository.update(1, doc: { text: 'testing_2' }) - }.to raise_exception(Elasticsearch::Transport::Transport::Errors::NotFound) + }.to raise_exception(Elastic::Transport::Transport::Errors::NotFound) end context 'when upsert is provided' do @@ -262,7 +262,7 @@ def to_hash it 'raises an exception' do expect { repository.update(id: 1, text: 'testing_2') - }.to raise_exception(Elasticsearch::Transport::Transport::Errors::NotFound) + }.to raise_exception(Elastic::Transport::Transport::Errors::NotFound) end context 'when upsert is provided' do @@ -337,7 +337,7 @@ def to_hash it 'raises an exception' do expect { repository.delete(1) - }.to raise_exception(Elasticsearch::Transport::Transport::Errors::NotFound) + }.to raise_exception(Elastic::Transport::Transport::Errors::NotFound) end end end diff --git a/elasticsearch-persistence/spec/repository_spec.rb b/elasticsearch-persistence/spec/repository_spec.rb index 05aeb1f53..ef9f0575d 100644 --- a/elasticsearch-persistence/spec/repository_spec.rb +++ b/elasticsearch-persistence/spec/repository_spec.rb @@ -562,7 +562,7 @@ class RepositoryWithoutDSL it 'raises an error' do expect { repository.create_index! - }.to raise_exception(Elasticsearch::Transport::Transport::Errors::BadRequest) + }.to raise_exception(Elastic::Transport::Transport::Errors::BadRequest) end end end From 99fcb362ef7b3e9a7cf924ba76c8689863b120b7 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 20 Jun 2023 16:05:43 +0100 Subject: [PATCH 073/113] Adds debug gem to development/testing --- elasticsearch-model/Gemfile | 1 + elasticsearch-persistence/Gemfile | 1 + elasticsearch-rails/Gemfile | 1 + 3 files changed, 3 insertions(+) diff --git a/elasticsearch-model/Gemfile b/elasticsearch-model/Gemfile index 5a31c3095..72fae31be 100644 --- a/elasticsearch-model/Gemfile +++ b/elasticsearch-model/Gemfile @@ -21,6 +21,7 @@ source 'https://rubygems.org' gemspec group :development, :testing do + gem 'debug' gem 'pry-nav' gem 'rspec' end diff --git a/elasticsearch-persistence/Gemfile b/elasticsearch-persistence/Gemfile index 17e92d051..2afccf280 100644 --- a/elasticsearch-persistence/Gemfile +++ b/elasticsearch-persistence/Gemfile @@ -25,6 +25,7 @@ gem 'elasticsearch-model', require: false group :development, :testing do + gem 'debug' gem 'pry-nav' gem 'rspec' end diff --git a/elasticsearch-rails/Gemfile b/elasticsearch-rails/Gemfile index 90572cba1..2f333c4b5 100644 --- a/elasticsearch-rails/Gemfile +++ b/elasticsearch-rails/Gemfile @@ -29,6 +29,7 @@ gem 'elasticsearch-persistence', require: false group :development, :testing do + gem 'debug' gem 'pry-nav' gem 'rspec' gem 'sqlite3' unless defined?(JRUBY_VERSION) From b71d5a9dfb1a5212cbad8b6f9321a1e0a6726579 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 20 Jun 2023 16:29:00 +0100 Subject: [PATCH 074/113] Removing type related code --- .../lib/elasticsearch/model.rb | 2 +- .../lib/elasticsearch/model/importing.rb | 3 - .../lib/elasticsearch/model/indexing.rb | 11 +-- .../elasticsearch/model/response/result.rb | 6 -- .../lib/elasticsearch/model/searching.rb | 5 +- .../adapters/active_record/basic_spec.rb | 14 +--- .../active_record/namespaced_model_spec.rb | 6 +- .../elasticsearch/model/importing_spec.rb | 16 +---- .../spec/elasticsearch/model/indexing_spec.rb | 1 - .../spec/elasticsearch/model/naming_spec.rb | 68 ------------------- .../elasticsearch/model/response/base_spec.rb | 1 - .../response/pagination/kaminari_spec.rb | 7 +- .../model/response/response_spec.rb | 1 - .../model/response/result_spec.rb | 16 ----- .../model/searching_search_request_spec.rb | 11 ++- .../spec/support/app/answer.rb | 1 - .../spec/support/app/article.rb | 2 - .../spec/support/app/article_no_type.rb | 2 +- .../spec/support/app/namespaced_book.rb | 2 - .../spec/support/app/question.rb | 1 - .../spec/repository/store_spec.rb | 6 +- 21 files changed, 22 insertions(+), 160 deletions(-) diff --git a/elasticsearch-model/lib/elasticsearch/model.rb b/elasticsearch-model/lib/elasticsearch/model.rb index af2f34cb6..7efc5caa9 100644 --- a/elasticsearch-model/lib/elasticsearch/model.rb +++ b/elasticsearch-model/lib/elasticsearch/model.rb @@ -85,7 +85,7 @@ module Elasticsearch # # ... # module Model - METHODS = [:search, :mapping, :mappings, :settings, :index_name, :document_type, :import] + METHODS = [:search, :mapping, :mappings, :settings, :index_name, :import] # Adds the `Elasticsearch::Model` functionality to the including class. # diff --git a/elasticsearch-model/lib/elasticsearch/model/importing.rb b/elasticsearch-model/lib/elasticsearch/model/importing.rb index b9f9ea392..3060e178a 100644 --- a/elasticsearch-model/lib/elasticsearch/model/importing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/importing.rb @@ -59,7 +59,6 @@ module ClassMethods # "index" => { # "error" => 'FAILED', # "_index" => "test", - # "_type" => "_doc", # "_id" => '1', # "_version" => 1, # "result" => "foo", @@ -138,7 +137,6 @@ def import(options={}, &block) errors = [] refresh = options.delete(:refresh) || false target_index = options.delete(:index) || index_name - target_type = options.delete(:type) || document_type transform = options.delete(:transform) || __transform pipeline = options.delete(:pipeline) return_value = options.delete(:return) || 'count' @@ -158,7 +156,6 @@ def import(options={}, &block) __find_in_batches(options) do |batch| params = { index: target_index, - type: target_type, body: __batch_to_bulk(batch, transform) } diff --git a/elasticsearch-model/lib/elasticsearch/model/indexing.rb b/elasticsearch-model/lib/elasticsearch/model/indexing.rb index 3ebd8cfb4..f270a26b4 100644 --- a/elasticsearch-model/lib/elasticsearch/model/indexing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/indexing.rb @@ -51,13 +51,12 @@ def as_json(options={}) # Wraps the [index mappings](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html) # class Mappings - attr_accessor :options, :type + attr_accessor :options # @private TYPES_WITH_EMBEDDED_PROPERTIES = %w(object nested) - def initialize(type = nil, options={}) - @type = type + def initialize(options={}) @options = options @mapping = {} end @@ -152,7 +151,7 @@ module ClassMethods # when it doesn't already define them. Use the `__elasticsearch__` proxy otherwise. # def mapping(options={}, &block) - @mapping ||= Mappings.new(document_type, options) + @mapping ||= Mappings.new(options) @mapping.options.update(options) unless options.empty? @@ -372,7 +371,6 @@ def index_document(options={}) request = { index: index_name, id: id, body: document } - request.merge!(type: document_type) if document_type client.index(request.merge!(options)) end @@ -393,7 +391,6 @@ def index_document(options={}) def delete_document(options={}) request = { index: index_name, id: self.id } - request.merge!(type: document_type) if document_type client.delete(request.merge!(options)) end @@ -434,7 +431,6 @@ def update_document(options={}) request = { index: index_name, id: self.id, body: { doc: attributes } } - request.merge!(type: document_type) if document_type client.update(request.merge!(options)) end @@ -461,7 +457,6 @@ def update_document_attributes(attributes, options={}) request = { index: index_name, id: self.id, body: { doc: attributes } } - request.merge!(type: document_type) if document_type client.update(request.merge!(options)) end diff --git a/elasticsearch-model/lib/elasticsearch/model/response/result.rb b/elasticsearch-model/lib/elasticsearch/model/response/result.rb index 5e102c2b3..d293e6efa 100644 --- a/elasticsearch-model/lib/elasticsearch/model/response/result.rb +++ b/elasticsearch-model/lib/elasticsearch/model/response/result.rb @@ -40,12 +40,6 @@ def id @result['_id'] end - # Return document `_type` as `_type` - # - def type - @result['_type'] - end - # Delegate methods to `@result` or `@result._source` # def method_missing(name, *arguments) diff --git a/elasticsearch-model/lib/elasticsearch/model/searching.rb b/elasticsearch-model/lib/elasticsearch/model/searching.rb index 714f98a22..e913444dd 100644 --- a/elasticsearch-model/lib/elasticsearch/model/searching.rb +++ b/elasticsearch-model/lib/elasticsearch/model/searching.rb @@ -37,7 +37,6 @@ def initialize(klass, query_or_payload, options={}) @options = options __index_name = options[:index] || klass.index_name - __document_type = options[:type] || klass.document_type case # search query: ... @@ -54,9 +53,9 @@ def initialize(klass, query_or_payload, options={}) end if body - @definition = { index: __index_name, type: __document_type, body: body }.update options + @definition = { index: __index_name, body: body }.update options else - @definition = { index: __index_name, type: __document_type, q: q }.update options + @definition = { index: __index_name, q: q }.update options end end diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb index 9c62a03a6..5dc91da9e 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb @@ -66,7 +66,7 @@ end Article.delete_all - Article.__elasticsearch__.create_index!(force: true, include_type_name: true) + Article.__elasticsearch__.create_index!(force: true) Article.create!(title: 'Test', body: '', clicks: 1) Article.create!(title: 'Testing Coding', body: '', clicks: 2) @@ -159,19 +159,7 @@ end end - describe '#id' do - - let(:search_result) do - Article.search('title:test') - end - - it 'returns the type' do - expect(search_result.results.first.type).to eq('article') - end - end - describe '#each_with_hit' do - let(:search_result) do Article.search('title:test') end diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/namespaced_model_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/namespaced_model_spec.rb index 730dad0e0..09f4670a6 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/namespaced_model_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/namespaced_model_spec.rb @@ -27,7 +27,7 @@ end MyNamespace::Book.delete_all - MyNamespace::Book.__elasticsearch__.create_index!(force: true, include_type_name: true) + MyNamespace::Book.__elasticsearch__.create_index!(force: true) MyNamespace::Book.create!(title: 'Test') MyNamespace::Book.__elasticsearch__.refresh_index! end @@ -43,10 +43,6 @@ expect(MyNamespace::Book.index_name).to eq('my_namespace-books') end - it 'has the proper document type' do - expect(MyNamespace::Book.document_type).to eq('book') - end - it 'saves the document into the index' do expect(MyNamespace::Book.search('title:test').results.size).to eq(1) expect(MyNamespace::Book.search('title:test').results.first.title).to eq('Test') diff --git a/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb index 343e04d00..438d0c9e9 100644 --- a/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb @@ -57,7 +57,6 @@ def importing_mixin describe '#import' do before do allow(DummyImportingModel).to receive(:index_name).and_return('foo') - allow(DummyImportingModel).to receive(:document_type).and_return('foo') allow(DummyImportingModel).to receive(:index_exists?).and_return(true) allow(DummyImportingModel).to receive(:__batch_to_bulk) allow(client).to receive(:bulk).and_return(response) @@ -148,7 +147,7 @@ def importing_mixin context 'when a different index name is provided' do before do expect(DummyImportingModel).to receive(:client).and_return(client) - expect(client).to receive(:bulk).with(body: nil, index: 'my-new-index', type: 'foo').and_return(response) + expect(client).to receive(:bulk).with(body: nil, index: 'my-new-index').and_return(response) end it 'uses the alternate index name' do @@ -156,17 +155,6 @@ def importing_mixin end end - context 'when a different document type is provided' do - before do - expect(DummyImportingModel).to receive(:client).and_return(client) - expect(client).to receive(:bulk).with(body: nil, index: 'foo', type: 'my-new-type').and_return(response) - end - - it 'uses the alternate index name' do - expect(DummyImportingModel.import(type: 'my-new-type')).to eq(0) - end - end - context 'the transform method' do before do expect(DummyImportingModel).to receive(:client).and_return(client) @@ -215,7 +203,7 @@ def importing_mixin context 'when a pipeline is provided as an options' do before do expect(DummyImportingModel).to receive(:client).and_return(client) - expect(client).to receive(:bulk).with(body: nil, index: 'foo', type: 'foo', pipeline: 'my-pipeline').and_return(response) + expect(client).to receive(:bulk).with(body: nil, index: 'foo', pipeline: 'my-pipeline').and_return(response) end it 'uses the pipeline option' do diff --git a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb index b4d5777da..5836bd2a6 100644 --- a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb @@ -38,7 +38,6 @@ class NotFound < Exception; end end describe 'the Settings class' do - it 'should be convertible to a hash' do expect(Elasticsearch::Model::Indexing::Settings.new(foo: 'bar').to_hash).to eq(foo: 'bar') end diff --git a/elasticsearch-model/spec/elasticsearch/model/naming_spec.rb b/elasticsearch-model/spec/elasticsearch/model/naming_spec.rb index 57a53b8d7..917bc099c 100644 --- a/elasticsearch-model/spec/elasticsearch/model/naming_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/naming_spec.rb @@ -51,13 +51,7 @@ class DummyNamingModelInNamespace expect(::MyNamespace::DummyNamingModelInNamespace.new.index_name).to eq('my_namespace-dummy_naming_model_in_namespaces') end - it 'returns nil' do - expect(DummyNamingModel.document_type).to be_nil - expect(DummyNamingModel.new.document_type).to be_nil - end - describe '#index_name' do - context 'when the index name is set on the class' do before do @@ -138,66 +132,4 @@ class DummyNamingModelInNamespace end end end - - describe '#document_type' do - - it 'returns nil' do - expect(DummyNamingModel.document_type).to be_nil - end - - context 'when the method is called with an argument' do - - before do - DummyNamingModel.document_type 'foo' - end - - it 'changes the document type' do - expect(DummyNamingModel.document_type).to eq('foo') - end - end - - context 'when the method is called on an instance' do - - let(:instance) do - DummyNamingModel.new - end - - before do - instance.document_type 'foobar_d' - end - - it 'changes the document type' do - expect(instance.document_type).to eq('foobar_d') - end - end - end - - describe '#document_type=' do - - context 'when the method is called on the class' do - - before do - DummyNamingModel.document_type = 'foo_z' - end - - it 'changes the document type' do - expect(DummyNamingModel.document_type).to eq('foo_z') - end - end - - context 'when the method is called on an instance' do - - let(:instance) do - DummyNamingModel.new - end - - before do - instance.document_type = 'foobar_b' - end - - it 'changes the document type' do - expect(instance.document_type).to eq('foobar_b') - end - end - end end diff --git a/elasticsearch-model/spec/elasticsearch/model/response/base_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/base_spec.rb index d3459b93b..dd5ff2d26 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/base_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/base_spec.rb @@ -26,7 +26,6 @@ class DummyBaseClass class OriginClass def self.index_name; 'foo'; end - def self.document_type; 'bar'; end end end diff --git a/elasticsearch-model/spec/elasticsearch/model/response/pagination/kaminari_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/pagination/kaminari_spec.rb index 15ee6113c..cb01c86cb 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/pagination/kaminari_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/pagination/kaminari_spec.rb @@ -23,7 +23,6 @@ class ModelClass include ::Kaminari::ConfigurationMethods def self.index_name; 'foo'; end - def self.document_type; 'bar'; end end end @@ -58,7 +57,7 @@ def self.document_type; 'bar'; end context 'when page is called once' do let(:search_request) do - { index: index_field, from: 25, size: 25, q: '*', type: type_field} + { index: index_field, from: 25, size: 25, q: '*' } end before do @@ -75,11 +74,11 @@ def self.document_type; 'bar'; end context 'when page is called more than once' do let(:search_request_one) do - { index: index_field, from: 25, size: 25, q: '*', type: type_field} + { index: index_field, from: 25, size: 25, q: '*' } end let(:search_request_two) do - { index: index_field, from: 75, size: 25, q: '*', type: type_field} + { index: index_field, from: 75, size: 25, q: '*' } end before do diff --git a/elasticsearch-model/spec/elasticsearch/model/response/response_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/response_spec.rb index e9a423812..7186b4710 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/response_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/response_spec.rb @@ -22,7 +22,6 @@ before(:all) do class OriginClass def self.index_name; 'foo'; end - def self.document_type; 'bar'; end end end diff --git a/elasticsearch-model/spec/elasticsearch/model/response/result_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/result_spec.rb index c3c73fec6..cf5abd38f 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/result_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/result_spec.rb @@ -44,23 +44,7 @@ end end - describe '#type' do - - let(:result) do - described_class.new(foo: 'bar', _type: 'baz', _source: { type: 'BAM' }) - end - - it 'returns the _type field' do - expect(result.type).to eq('baz') - end - - it 'provides access to the source type field' do - expect(result._source.type).to eq('BAM') - end - end - describe 'method delegation' do - let(:result) do described_class.new(foo: 'bar', _source: { bar: { bam: 'baz' } }) end diff --git a/elasticsearch-model/spec/elasticsearch/model/searching_search_request_spec.rb b/elasticsearch-model/spec/elasticsearch/model/searching_search_request_spec.rb index 1f5e72bf2..1a7b4e413 100644 --- a/elasticsearch-model/spec/elasticsearch/model/searching_search_request_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/searching_search_request_spec.rb @@ -23,7 +23,6 @@ class ::DummySearchingModel extend Elasticsearch::Model::Searching::ClassMethods def self.index_name; 'foo'; end - def self.document_type; 'bar'; end end end @@ -44,7 +43,7 @@ def self.document_type; 'bar'; end context 'when the search definition is a simple query' do before do - expect(client).to receive(:search).with(index: 'foo', type: 'bar', q: 'foo').and_return({}) + expect(client).to receive(:search).with(index: 'foo', q: 'foo').and_return({}) end let(:search) do @@ -59,7 +58,7 @@ def self.document_type; 'bar'; end context 'when the search definition is a hash' do before do - expect(client).to receive(:search).with(index: 'foo', type: 'bar', body: { foo: 'bar' }).and_return({}) + expect(client).to receive(:search).with(index: 'foo', body: { foo: 'bar' }).and_return({}) end let(:search) do @@ -74,7 +73,7 @@ def self.document_type; 'bar'; end context 'when the search definition is a json string' do before do - expect(client).to receive(:search).with(index: 'foo', type: 'bar', body: '{"foo":"bar"}').and_return({}) + expect(client).to receive(:search).with(index: 'foo', body: '{"foo":"bar"}').and_return({}) end let(:search) do @@ -99,7 +98,7 @@ def to_hash; {foo: 'bar'}; end end before do - expect(client).to receive(:search).with(index: 'foo', type: 'bar', body: {foo: 'bar'}).and_return({}) + expect(client).to receive(:search).with(index: 'foo', body: {foo: 'bar'}).and_return({}) end let(:search) do @@ -114,7 +113,7 @@ def to_hash; {foo: 'bar'}; end context 'when extra options are specified' do before do - expect(client).to receive(:search).with(index: 'foo', type: 'bar', q: 'foo', size: 15).and_return({}) + expect(client).to receive(:search).with(index: 'foo', q: 'foo', size: 15).and_return({}) end let(:search) do diff --git a/elasticsearch-model/spec/support/app/answer.rb b/elasticsearch-model/spec/support/app/answer.rb index 9c58cc991..ec010e3d2 100644 --- a/elasticsearch-model/spec/support/app/answer.rb +++ b/elasticsearch-model/spec/support/app/answer.rb @@ -23,7 +23,6 @@ class Answer < ActiveRecord::Base JOIN_TYPE = 'answer'.freeze index_name 'questions_and_answers'.freeze - document_type 'doc'.freeze before_create :randomize_id diff --git a/elasticsearch-model/spec/support/app/article.rb b/elasticsearch-model/spec/support/app/article.rb index 2c122dd77..659d16cec 100644 --- a/elasticsearch-model/spec/support/app/article.rb +++ b/elasticsearch-model/spec/support/app/article.rb @@ -19,8 +19,6 @@ class ::Article < ActiveRecord::Base include Elasticsearch::Model include Elasticsearch::Model::Callbacks - document_type 'article' - settings index: {number_of_shards: 1, number_of_replicas: 0} do mapping do indexes :title, type: 'text', analyzer: 'snowball' diff --git a/elasticsearch-model/spec/support/app/article_no_type.rb b/elasticsearch-model/spec/support/app/article_no_type.rb index d3cb6b4e3..9e6b8443f 100644 --- a/elasticsearch-model/spec/support/app/article_no_type.rb +++ b/elasticsearch-model/spec/support/app/article_no_type.rb @@ -21,7 +21,7 @@ class ::ArticleNoType < ActiveRecord::Base settings index: {number_of_shards: 1, number_of_replicas: 0} do mapping do - indexes :title, type: 'text', analyzer: 'snowball' + indexes :title, analyzer: 'snowball' indexes :body, type: 'text' indexes :clicks, type: 'integer' indexes :created_at, type: 'date' diff --git a/elasticsearch-model/spec/support/app/namespaced_book.rb b/elasticsearch-model/spec/support/app/namespaced_book.rb index f6d9c838c..29949772a 100644 --- a/elasticsearch-model/spec/support/app/namespaced_book.rb +++ b/elasticsearch-model/spec/support/app/namespaced_book.rb @@ -20,8 +20,6 @@ class Book < ActiveRecord::Base include Elasticsearch::Model include Elasticsearch::Model::Callbacks - document_type 'book' - mapping { indexes :title } end end diff --git a/elasticsearch-model/spec/support/app/question.rb b/elasticsearch-model/spec/support/app/question.rb index 62a7d4550..fce543139 100644 --- a/elasticsearch-model/spec/support/app/question.rb +++ b/elasticsearch-model/spec/support/app/question.rb @@ -24,7 +24,6 @@ class Question < ActiveRecord::Base JOIN_METADATA = { join_field: JOIN_TYPE}.freeze index_name 'questions_and_answers'.freeze - document_type 'doc'.freeze mapping do indexes :title diff --git a/elasticsearch-persistence/spec/repository/store_spec.rb b/elasticsearch-persistence/spec/repository/store_spec.rb index 92b7035e7..82e1d3b01 100644 --- a/elasticsearch-persistence/spec/repository/store_spec.rb +++ b/elasticsearch-persistence/spec/repository/store_spec.rb @@ -74,14 +74,14 @@ def serialize(document) context 'when options are provided' do let!(:response) do - repository.save(document, type: 'other_note') + repository.save(document) end it 'saves the document using the options' do expect { repository.find(response['_id']) }.to raise_exception(Elasticsearch::Persistence::Repository::DocumentNotFound) - expect(repository.find(response['_id'], type: 'other_note')).to eq('a' => 1) + expect(repository.find(response['_id'])).to eq('a' => 1) end end end @@ -331,7 +331,7 @@ def to_hash context 'when the document does not exist' do before do - repository.create_index!(include_type_name: true) + repository.create_index! end it 'raises an exception' do From 272789878118b3170c92f34999b03cf0d4d124af Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 21 Jun 2023 16:41:20 +0100 Subject: [PATCH 075/113] Updates elasticsearch-model rake task, fixes dependencies --- elasticsearch-model/Rakefile | 2 +- elasticsearch-model/gemfiles/7.0.gemfile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/elasticsearch-model/Rakefile b/elasticsearch-model/Rakefile index a57680a9a..bbcf9ad41 100644 --- a/elasticsearch-model/Rakefile +++ b/elasticsearch-model/Rakefile @@ -46,7 +46,7 @@ end require 'rake/testtask' namespace :test do desc 'Run all tests. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0' - task :all, [:rails_versions] do |task, args| + task :all do |task, args| gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map { |v| "#{v}.gemfile" } : GEMFILES puts '-' * 80 gemfiles.each do |gemfile| diff --git a/elasticsearch-model/gemfiles/7.0.gemfile b/elasticsearch-model/gemfiles/7.0.gemfile index 4479207e1..bc3bd63a5 100644 --- a/elasticsearch-model/gemfiles/7.0.gemfile +++ b/elasticsearch-model/gemfiles/7.0.gemfile @@ -24,8 +24,8 @@ source 'https://rubygems.org' gemspec path: '../' -gem 'activemodel', '7' -gem 'activerecord', '7' +gem 'activemodel', '~> 7' +gem 'activerecord', '~> 7' gem 'sqlite3' unless defined?(JRUBY_VERSION) # gem 'mongoid', '~> 6' From 157a7b38a861311b5903e9319788c415de3c5a3b Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 22 Jun 2023 08:32:48 +0100 Subject: [PATCH 076/113] Updates indexing spec Removes type Updates option hash/keyword argument expectations --- .../spec/elasticsearch/model/indexing_spec.rb | 131 ++++++------------ 1 file changed, 41 insertions(+), 90 deletions(-) diff --git a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb index 5836bd2a6..d82570910 100644 --- a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb @@ -18,7 +18,6 @@ require 'spec_helper' describe Elasticsearch::Model::Indexing do - before(:all) do class ::DummyIndexingModel extend ActiveModel::Naming @@ -48,13 +47,11 @@ class NotFound < Exception; end end describe '#settings' do - it 'returns an instance of the Settings class' do expect(DummyIndexingModel.settings).to be_a(Elasticsearch::Model::Indexing::Settings) end context 'when the settings are updated' do - before do DummyIndexingModel.settings(foo: 'boo') DummyIndexingModel.settings(bar: 'bam') @@ -66,7 +63,6 @@ class NotFound < Exception; end end context 'when the settings are updated with a yml file' do - before do DummyIndexingModel.settings File.open('spec/support/model.yml') DummyIndexingModel.settings bar: 'bam' @@ -78,7 +74,6 @@ class NotFound < Exception; end end context 'when the settings are updated with a json file' do - before do DummyIndexingModel.settings File.open('spec/support/model.json') DummyIndexingModel.settings bar: 'bam' @@ -91,9 +86,8 @@ class NotFound < Exception; end end describe '#mappings' do - let(:expected_mapping_hash) do - { :mytype => { foo: 'bar', :properties => {} } } + { foo: 'bar', :properties => {} } end it 'returns an instance of the Mappings class' do @@ -105,17 +99,16 @@ class NotFound < Exception; end end it 'should be convertible to a hash' do - expect(Elasticsearch::Model::Indexing::Mappings.new(:mytype, { foo: 'bar' }).to_hash).to eq(expected_mapping_hash) + expect(Elasticsearch::Model::Indexing::Mappings.new({ foo: 'bar' }).to_hash).to eq(expected_mapping_hash) end it 'should be convertible to json' do - expect(Elasticsearch::Model::Indexing::Mappings.new(:mytype, { foo: 'bar' }).as_json).to eq(expected_mapping_hash) + expect(Elasticsearch::Model::Indexing::Mappings.new({ foo: 'bar' }).as_json).to eq(expected_mapping_hash) end context 'when a type is specified' do - let(:mappings) do - Elasticsearch::Model::Indexing::Mappings.new(:mytype) + Elasticsearch::Model::Indexing::Mappings.new end before do @@ -124,17 +117,17 @@ class NotFound < Exception; end end it 'creates the correct mapping definition' do - expect(mappings.to_hash[:mytype][:properties][:foo][:type]).to eq('boolean') + expect(mappings.to_hash[:properties][:foo][:type]).to eq('boolean') end it 'uses text as the default field type' do - expect(mappings.to_hash[:mytype][:properties][:bar][:type]).to eq('text') + expect(mappings.to_hash[:properties][:bar][:type]).to eq('text') end context 'when the \'include_type_name\' option is specified' do let(:mappings) do - Elasticsearch::Model::Indexing::Mappings.new(:mytype, include_type_name: true) + Elasticsearch::Model::Indexing::Mappings.new(include_type_name: true) end before do @@ -142,17 +135,16 @@ class NotFound < Exception; end end it 'creates the correct mapping definition' do - expect(mappings.to_hash[:mytype][:properties][:foo][:type]).to eq('boolean') + expect(mappings.to_hash[:properties][:foo][:type]).to eq('boolean') end it 'sets the \'include_type_name\' option' do - expect(mappings.to_hash[:mytype][:include_type_name]).to eq(true) + expect(mappings.to_hash[:include_type_name]).to eq(true) end end end context 'when a type is not specified' do - let(:mappings) do Elasticsearch::Model::Indexing::Mappings.new end @@ -174,7 +166,7 @@ class NotFound < Exception; end context 'when specific mappings are defined' do let(:mappings) do - Elasticsearch::Model::Indexing::Mappings.new(:mytype, include_type_name: true) + Elasticsearch::Model::Indexing::Mappings.new(include_type_name: true) end before do @@ -183,15 +175,14 @@ class NotFound < Exception; end end it 'creates the correct mapping definition' do - expect(mappings.to_hash[:mytype][:properties][:foo][:type]).to eq('boolean') + expect(mappings.to_hash[:properties][:foo][:type]).to eq('boolean') end it 'uses text as the default type' do - expect(mappings.to_hash[:mytype][:properties][:bar][:type]).to eq('text') + expect(mappings.to_hash[:properties][:bar][:type]).to eq('text') end context 'when mappings are defined for multiple fields' do - before do mappings.indexes :my_field, type: 'text' do indexes :raw, type: 'keyword' @@ -199,14 +190,13 @@ class NotFound < Exception; end end it 'defines the mapping for all the fields' do - expect(mappings.to_hash[:mytype][:properties][:my_field][:type]).to eq('text') - expect(mappings.to_hash[:mytype][:properties][:my_field][:fields][:raw][:type]).to eq('keyword') - expect(mappings.to_hash[:mytype][:properties][:my_field][:fields][:raw][:properties]).to be_nil + expect(mappings.to_hash[:properties][:my_field][:type]).to eq('text') + expect(mappings.to_hash[:properties][:my_field][:fields][:raw][:type]).to eq('keyword') + expect(mappings.to_hash[:properties][:my_field][:fields][:raw][:properties]).to be_nil end end context 'when embedded properties are defined' do - before do mappings.indexes :foo do indexes :bar @@ -226,31 +216,30 @@ class NotFound < Exception; end end it 'defines mappings for the embedded properties' do - expect(mappings.to_hash[:mytype][:properties][:foo][:type]).to eq('object') - expect(mappings.to_hash[:mytype][:properties][:foo][:properties][:bar][:type]).to eq('text') - expect(mappings.to_hash[:mytype][:properties][:foo][:fields]).to be_nil + expect(mappings.to_hash[:properties][:foo][:type]).to eq('object') + expect(mappings.to_hash[:properties][:foo][:properties][:bar][:type]).to eq('text') + expect(mappings.to_hash[:properties][:foo][:fields]).to be_nil - expect(mappings.to_hash[:mytype][:properties][:foo_object][:type]).to eq('object') - expect(mappings.to_hash[:mytype][:properties][:foo_object][:properties][:bar][:type]).to eq('text') - expect(mappings.to_hash[:mytype][:properties][:foo_object][:fields]).to be_nil + expect(mappings.to_hash[:properties][:foo_object][:type]).to eq('object') + expect(mappings.to_hash[:properties][:foo_object][:properties][:bar][:type]).to eq('text') + expect(mappings.to_hash[:properties][:foo_object][:fields]).to be_nil - expect(mappings.to_hash[:mytype][:properties][:foo_nested][:type]).to eq('nested') - expect(mappings.to_hash[:mytype][:properties][:foo_nested][:properties][:bar][:type]).to eq('text') - expect(mappings.to_hash[:mytype][:properties][:foo_nested][:fields]).to be_nil + expect(mappings.to_hash[:properties][:foo_nested][:type]).to eq('nested') + expect(mappings.to_hash[:properties][:foo_nested][:properties][:bar][:type]).to eq('text') + expect(mappings.to_hash[:properties][:foo_nested][:fields]).to be_nil - expect(mappings.to_hash[:mytype][:properties][:foo_nested_as_symbol][:type]).to eq(:nested) - expect(mappings.to_hash[:mytype][:properties][:foo_nested_as_symbol][:properties]).not_to be_nil - expect(mappings.to_hash[:mytype][:properties][:foo_nested_as_symbol][:fields]).to be_nil + expect(mappings.to_hash[:properties][:foo_nested_as_symbol][:type]).to eq(:nested) + expect(mappings.to_hash[:properties][:foo_nested_as_symbol][:properties]).not_to be_nil + expect(mappings.to_hash[:properties][:foo_nested_as_symbol][:fields]).to be_nil end it 'defines the settings' do - expect(mappings.to_hash[:mytype][:include_type_name]).to be(true) + expect(mappings.to_hash[:include_type_name]).to be(true) end end end context 'when the method is called on a class' do - before do DummyIndexingModel.mappings(foo: 'boo') DummyIndexingModel.mappings(bar: 'bam') @@ -265,7 +254,6 @@ class NotFound < Exception; end end context 'when the method is called with a block' do - before do DummyIndexingModel.mapping do indexes :foo, type: 'boolean' @@ -278,16 +266,14 @@ class NotFound < Exception; end end context 'when the class has a document_type' do - before do DummyIndexingModel.instance_variable_set(:@mapping, nil) - DummyIndexingModel.document_type(:mytype) DummyIndexingModel.mappings(foo: 'boo') DummyIndexingModel.mappings(bar: 'bam') end let(:expected_mappings_hash) do - { mytype: { foo: "boo", bar: "bam", properties: {} } } + { foo: "boo", bar: "bam", properties: {} } end it 'sets the mappings' do @@ -298,7 +284,6 @@ class NotFound < Exception; end end describe 'instance methods' do - before(:all) do class ::DummyIndexingModelWithCallbacks extend Elasticsearch::Model::Indexing::ClassMethods @@ -365,9 +350,7 @@ def changes end context 'when the module is included' do - context 'when the model uses the old ActiveModel::Dirty' do - before do DummyIndexingModelWithOldDirty.__send__ :include, Elasticsearch::Model::Indexing::InstanceMethods end @@ -389,7 +372,6 @@ def changes end context 'when the model users the current ActiveModel::Dirty' do - before do DummyIndexingModelWithCallbacks.__send__ :include, Elasticsearch::Model::Indexing::InstanceMethods end @@ -412,12 +394,10 @@ def changes end describe '#index_document' do - before do expect(instance).to receive(:client).and_return(client) expect(instance).to receive(:as_indexed_json).and_return('JSON') expect(instance).to receive(:index_name).and_return('foo') - expect(instance).to receive(:document_type).twice.and_return('bar') expect(instance).to receive(:id).and_return('1') end @@ -430,9 +410,8 @@ def changes end context 'when no options are passed to the method' do - before do - expect(client).to receive(:index).with(index: 'foo', type: 'bar', id: '1', body: 'JSON').and_return(true) + expect(client).to receive(:index).with({ index: 'foo', id: '1', body: 'JSON' }).and_return(true) end it 'provides the method on an instance' do @@ -441,9 +420,8 @@ def changes end context 'when extra options are passed to the method' do - before do - expect(client).to receive(:index).with(index: 'foo', type: 'bar', id: '1', body: 'JSON', parent: 'A').and_return(true) + expect(client).to receive(:index).with({ index: 'foo', id: '1', body: 'JSON', parent: 'A' }).and_return(true) end it 'passes the extra options to the method call on the client' do @@ -453,11 +431,9 @@ def changes end describe '#delete_document' do - before do expect(instance).to receive(:client).and_return(client) expect(instance).to receive(:index_name).and_return('foo') - expect(instance).to receive(:document_type).twice.and_return('bar') expect(instance).to receive(:id).and_return('1') end @@ -470,9 +446,8 @@ def changes end context 'when no options are passed to the method' do - before do - expect(client).to receive(:delete).with(index: 'foo', type: 'bar', id: '1').and_return(true) + expect(client).to receive(:delete).with({ index: 'foo', id: '1' }).and_return(true) end it 'provides the method on an instance' do @@ -481,9 +456,8 @@ def changes end context 'when extra options are passed to the method' do - before do - expect(client).to receive(:delete).with(index: 'foo', type: 'bar', id: '1', parent: 'A').and_return(true) + expect(client).to receive(:delete).with({ index: 'foo', id: '1', parent: 'A' }).and_return(true) end it 'passes the extra options to the method call on the client' do @@ -493,7 +467,6 @@ def changes end describe '#update_document' do - let(:client) do double('client') end @@ -503,7 +476,6 @@ def changes end context 'when no changes are present' do - before do expect(instance).to receive(:index_document).and_return(true) expect(client).to receive(:update).never @@ -516,19 +488,16 @@ def changes end context 'when changes are present' do - before do allow(instance).to receive(:client).and_return(client) allow(instance).to receive(:index_name).and_return('foo') - allow(instance).to receive(:document_type).and_return('bar') allow(instance).to receive(:id).and_return('1') end context 'when the changes are included in the as_indexed_json representation' do - before do instance.instance_variable_set(:@__changed_model_attributes, { foo: 'bar' }) - expect(client).to receive(:update).with(index: 'foo', type: 'bar', id: '1', body: { doc: { foo: 'bar' } }).and_return(true) + expect(client).to receive(:update).with({ index: 'foo', id: '1', body: { doc: { foo: 'bar' } } }).and_return(true) end it 'updates the document' do @@ -537,14 +506,13 @@ def changes end context 'when the changes are not all included in the as_indexed_json representation' do - let(:instance) do DummyIndexingModelWithCallbacksAndCustomAsIndexedJson.new end before do instance.instance_variable_set(:@__changed_model_attributes, {'foo' => 'B', 'bar' => 'D' }) - expect(client).to receive(:update).with(index: 'foo', type: 'bar', id: '1', body: { doc: { foo: 'B' } }).and_return(true) + expect(client).to receive(:update).with({ index: 'foo', id: '1', body: { doc: { foo: 'B' } } }).and_return(true) end it 'updates the document' do @@ -553,7 +521,6 @@ def changes end context 'when none of the changes are included in the as_indexed_json representation' do - let(:instance) do DummyIndexingModelWithCallbacksAndCustomAsIndexedJson.new end @@ -568,7 +535,6 @@ def changes end context 'when there are partial updates' do - let(:instance) do DummyIndexingModelWithCallbacksAndCustomAsIndexedJson.new end @@ -576,7 +542,7 @@ def changes before do instance.instance_variable_set(:@__changed_model_attributes, { 'foo' => { 'bar' => 'BAR'} }) expect(instance).to receive(:as_indexed_json).and_return('foo' => 'BAR') - expect(client).to receive(:update).with(index: 'foo', type: 'bar', id: '1', body: { doc: { 'foo' => 'BAR' } }).and_return(true) + expect(client).to receive(:update).with({ index: 'foo', id: '1', body: { doc: { 'foo' => 'BAR' } } }).and_return(true) end it 'updates the document' do @@ -587,7 +553,6 @@ def changes end describe '#update_document_attributes' do - let(:client) do double('client') end @@ -597,19 +562,16 @@ def changes end context 'when changes are present' do - before do expect(instance).to receive(:client).and_return(client) expect(instance).to receive(:index_name).and_return('foo') - expect(instance).to receive(:document_type).twice.and_return('bar') expect(instance).to receive(:id).and_return('1') instance.instance_variable_set(:@__changed_model_attributes, { author: 'john' }) end context 'when no options are specified' do - before do - expect(client).to receive(:update).with(index: 'foo', type: 'bar', id: '1', body: { doc: { title: 'green' } }).and_return(true) + expect(client).to receive(:update).with({ index: 'foo', id: '1', body: { doc: { title: 'green' } } }).and_return(true) end it 'updates the document' do @@ -618,9 +580,8 @@ def changes end context 'when extra options are provided' do - before do - expect(client).to receive(:update).with(index: 'foo', type: 'bar', id: '1', body: { doc: { title: 'green' } }, refresh: true).and_return(true) + expect(client).to receive(:update).with({ index: 'foo', id: '1', body: { doc: { title: 'green' } }, refresh: true }).and_return(true) end it 'updates the document' do @@ -632,7 +593,6 @@ def changes end describe '#index_exists?' do - before do expect(DummyIndexingModel).to receive(:client).and_return(client) end @@ -649,7 +609,6 @@ def changes end context 'when the index does not exists' do - let(:client) do double('client', indices: double('indices', exists: false)) end @@ -661,7 +620,6 @@ def changes end describe '#delete_index!' do - before(:all) do class ::DummyIndexingModelForRecreate extend ActiveModel::Naming @@ -720,7 +678,6 @@ class ::DummyIndexingModelForRecreate end context 'when the force option is not provided' do - it 'raises an exception' do expect { DummyIndexingModelForRecreate.delete_index! @@ -729,7 +686,6 @@ class ::DummyIndexingModelForRecreate end context 'when the exception is not NotFound' do - let(:indices) do double('indices').tap do |ind| expect(ind).to receive(:delete).and_raise(Exception) @@ -745,7 +701,6 @@ class ::DummyIndexingModelForRecreate end context 'when an index name is provided in the options' do - before do expect(DummyIndexingModelForRecreate).to receive(:client).and_return(client) expect(indices).to receive(:delete).with(index: 'custom-foo') @@ -766,7 +721,6 @@ class ::DummyIndexingModelForRecreate end describe '#create_index' do - before(:all) do class ::DummyIndexingModelForCreate extend ActiveModel::Naming @@ -811,7 +765,7 @@ class ::DummyIndexingModelForCreate end before do - expect(indices).to receive(:create).with(index: 'foo', body: expected_body).and_return(true) + expect(indices).to receive(:create).with({ index: 'foo', body: expected_body }).and_return(true) end it 'creates the index' do @@ -827,7 +781,7 @@ class ::DummyIndexingModelForCreate end before do - expect(indices).to receive(:create).with(index: 'foobar', body: expected_body).and_return(true) + expect(indices).to receive(:create).with({ index: 'foobar', body: expected_body }).and_return(true) end it 'creates the index' do @@ -853,7 +807,6 @@ class ::DummyIndexingModelForCreate end context 'when creating the index raises an exception' do - before do expect(DummyIndexingModelForCreate).to receive(:client).and_return(client) expect(DummyIndexingModelForCreate).to receive(:delete_index!).and_return(true) @@ -869,11 +822,10 @@ class ::DummyIndexingModelForCreate end context 'when an index name is provided in the options' do - before do expect(DummyIndexingModelForCreate).to receive(:client).and_return(client).twice expect(indices).to receive(:exists).and_return(false) - expect(indices).to receive(:create).with(index: 'custom-foo', body: expected_body) + expect(indices).to receive(:create).with({ index: 'custom-foo', body: expected_body }) end let(:expected_body) do @@ -891,7 +843,6 @@ class ::DummyIndexingModelForCreate end describe '#refresh_index!' do - before(:all) do class ::DummyIndexingModelForRefresh extend ActiveModel::Naming From 4ac12367f4398695172fae036316ce8e9e118fa1 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 22 Jun 2023 09:24:26 +0100 Subject: [PATCH 077/113] Updates indexing spec Updates usage of client --- .../spec/elasticsearch/model/indexing_spec.rb | 52 ++++--------------- 1 file changed, 9 insertions(+), 43 deletions(-) diff --git a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb index d82570910..c8df409e5 100644 --- a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb @@ -125,7 +125,6 @@ class NotFound < Exception; end end context 'when the \'include_type_name\' option is specified' do - let(:mappings) do Elasticsearch::Model::Indexing::Mappings.new(include_type_name: true) end @@ -164,7 +163,6 @@ class NotFound < Exception; end end context 'when specific mappings are defined' do - let(:mappings) do Elasticsearch::Model::Indexing::Mappings.new(include_type_name: true) end @@ -608,7 +606,7 @@ def changes end end - context 'when the index does not exists' do + context 'when the index does not exist' do let(:client) do double('client', indices: double('indices', exists: false)) end @@ -634,19 +632,7 @@ class ::DummyIndexingModelForRecreate context 'when the index is not found' do let(:logger) { nil } - let(:transport) do - Elastic::Transport::Client.new(logger: logger) - end - - let(:client) do - double('client', indices: indices, transport: transport) - end - - let(:indices) do - double('indices').tap do |ind| - expect(ind).to receive(:delete).and_raise(NotFound) - end - end + let(:client) { Elasticsearch::Client.new(logger: logger) } before do expect(DummyIndexingModelForRecreate).to receive(:client).at_most(3).times.and_return(client) @@ -662,16 +648,12 @@ class ::DummyIndexingModelForRecreate Logger.new(STDOUT).tap { |l| l.level = Logger::DEBUG } end - let(:client) do - double('client', indices: indices, transport: transport) - end - it 'deletes the index without raising an exception' do expect(DummyIndexingModelForRecreate.delete_index!(force: true)).to be_nil end it 'logs the message that the index is not found' do - expect(logger).to receive(:debug) + expect(logger).to receive(:debug).at_least(:once) expect(DummyIndexingModelForRecreate.delete_index!(force: true)).to be_nil end end @@ -681,7 +663,7 @@ class ::DummyIndexingModelForRecreate it 'raises an exception' do expect { DummyIndexingModelForRecreate.delete_index! - }.to raise_exception(NotFound) + }.to raise_exception(Elastic::Transport::Transport::Errors::NotFound) end end @@ -750,14 +732,12 @@ class ::DummyIndexingModelForCreate end context 'when the index does not exist' do - before do expect(DummyIndexingModelForCreate).to receive(:client).and_return(client) expect(DummyIndexingModelForCreate).to receive(:index_exists?).and_return(false) end context 'when options are not provided' do - let(:expected_body) do { mappings: { properties: { foo: { analyzer: 'keyword', type: 'text' } } }, @@ -774,7 +754,6 @@ class ::DummyIndexingModelForCreate end context 'when options are provided' do - let(:expected_body) do { mappings: { foobar: { properties: { foo: { analyzer: 'bar' } } } }, settings: { index: { number_of_shards: 3 } } } @@ -795,7 +774,6 @@ class ::DummyIndexingModelForCreate end context 'when the index exists' do - before do expect(DummyIndexingModelForCreate).to receive(:index_exists?).and_return(true) expect(indices).to receive(:create).never @@ -864,15 +842,7 @@ class ::DummyIndexingModelForRefresh end let(:client) do - double('client', indices: indices, transport: transport) - end - - let(:transport) do - Elastic::Transport::Client.new(logger: nil) - end - - let(:indices) do - double('indices') + Elasticsearch::Client.new(logger: nil) end before do @@ -882,7 +852,7 @@ class ::DummyIndexingModelForRefresh context 'when the force option is true' do context 'when the operation raises a NotFound exception' do before do - expect(indices).to receive(:refresh).and_raise(NotFound) + expect(client).to receive_message_chain(:indices, :refresh).and_raise(NotFound) end it 'does not raise an exception' do @@ -895,11 +865,7 @@ class ::DummyIndexingModelForRefresh end let(:client) do - double('client', indices: indices, transport: transport) - end - - let(:transport) do - Elastic::Transport::Client.new(logger: logger) + Elasticsearch::Client.new(logger: logger) end it 'does not raise an exception' do @@ -915,7 +881,7 @@ class ::DummyIndexingModelForRefresh context 'when the operation raises another type of exception' do before do - expect(indices).to receive(:refresh).and_raise(Exception) + expect(client).to receive_message_chain(:indices, :refresh).and_raise(Exception) end it 'does not raise an exception' do @@ -928,7 +894,7 @@ class ::DummyIndexingModelForRefresh context 'when an index name is provided in the options' do before do - expect(indices).to receive(:refresh).with(index: 'custom-foo') + expect(client).to receive_message_chain(:indices, :refresh).with(index: 'custom-foo') end it 'uses the index name' do From aa0dfaae355d5fdacbd2db72a707a5e5aaaf4f97 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 22 Jun 2023 10:31:54 +0100 Subject: [PATCH 078/113] Updates module_spec --- elasticsearch-model/spec/elasticsearch/model/module_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/elasticsearch-model/spec/elasticsearch/model/module_spec.rb b/elasticsearch-model/spec/elasticsearch/model/module_spec.rb index ed7a58297..8808475ee 100644 --- a/elasticsearch-model/spec/elasticsearch/model/module_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/module_spec.rb @@ -65,7 +65,6 @@ def self.search(query, options={}) expect(DummyIncludingModel).to respond_to(:mapping) expect(DummyIncludingModel).to respond_to(:settings) expect(DummyIncludingModel).to respond_to(:index_name) - expect(DummyIncludingModel).to respond_to(:document_type) expect(DummyIncludingModel).to respond_to(:import) end From f9bcc23b8236bdc670332c5f9e68ce21fe31576a Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 22 Jun 2023 10:35:59 +0100 Subject: [PATCH 079/113] Updates mongoid spec --- .../spec/elasticsearch/model/adapters/mongoid_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid_spec.rb index 81a286c0d..88ffbd2a6 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/mongoid_spec.rb @@ -174,7 +174,7 @@ class DummyClassForMongoid; end context 'query criteria specified as a hash' do before do - expect(relation).to receive(:where).with(color: 'red').and_return(relation) + expect(relation).to receive(:where).with({ color: 'red' }).and_return(relation) end let(:query) do From 3ebd8da90b6052aa32dfe079a1e5a6dcb16464d4 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 22 Jun 2023 10:38:42 +0100 Subject: [PATCH 080/113] Updates adapters/active_record/serialization spec --- .../adapters/active_record/serialization_spec.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb index 3f01c348b..da9d3306a 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb @@ -41,9 +41,10 @@ context 'when a document is indexed' do let(:search_result) do - ArticleWithCustomSerialization.__elasticsearch__.client.get(index: 'article_with_custom_serializations', - type: '_doc', - id: '1') + ArticleWithCustomSerialization.__elasticsearch__.client.get( + index: 'article_with_custom_serializations', + id: '1' + ) end it 'applies the serialization when indexing' do @@ -54,7 +55,7 @@ context 'when a document is updated' do before do - article.update_attributes(title: 'UPDATED', status: 'yellow') + article.update(title: 'UPDATED', status: 'yellow') ArticleWithCustomSerialization.__elasticsearch__.refresh_index! end @@ -65,9 +66,10 @@ end let(:search_result) do - ArticleWithCustomSerialization.__elasticsearch__.client.get(index: 'article_with_custom_serializations', - type: '_doc', - id: article.id) + ArticleWithCustomSerialization.__elasticsearch__.client.get( + index: 'article_with_custom_serializations', + id: article.id + ) end it 'applies the serialization when updating' do From 5f88f9406d35ed07aaae5cf304c5a42b21bc014e Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 22 Jun 2023 10:46:04 +0100 Subject: [PATCH 081/113] Updates parent child specs --- .../model/adapters/active_record/parent_child_spec.rb | 2 +- .../spec/support/app/parent_and_child_searchable.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb index 5147943ee..06790f613 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb @@ -38,7 +38,7 @@ add_index(:answers, :question_id) unless index_exists?(:answers, :question_id) clear_tables(Question) - ParentChildSearchable.create_index!(force: true, include_type_name: true) + ParentChildSearchable.create_index!(force: true) q_1 = Question.create!(title: 'First Question', author: 'John') q_2 = Question.create!(title: 'Second Question', author: 'Jody') diff --git a/elasticsearch-model/spec/support/app/parent_and_child_searchable.rb b/elasticsearch-model/spec/support/app/parent_and_child_searchable.rb index 91693479f..210e44076 100644 --- a/elasticsearch-model/spec/support/app/parent_and_child_searchable.rb +++ b/elasticsearch-model/spec/support/app/parent_and_child_searchable.rb @@ -26,10 +26,12 @@ def create_index!(options={}) settings = Question.settings.to_hash.merge Answer.settings.to_hash mapping_properties = { join_field: { type: JOIN, relations: { Question::JOIN_TYPE => Answer::JOIN_TYPE } } } - - merged_properties = mapping_properties.merge(Question.mappings.to_hash[:doc][:properties]).merge( - Answer.mappings.to_hash[:doc][:properties]) - mappings = { doc: { properties: merged_properties }} + merged_properties = mapping_properties.merge( + Question.mappings.to_hash[:properties] + ).merge( + Answer.mappings.to_hash[:properties] + ) + mappings = { properties: merged_properties } client.indices.create({ index: INDEX_NAME, body: { From 2ef285abc06d3d04e60858fbf68dcae0386ba18f Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 22 Jun 2023 18:03:41 +0100 Subject: [PATCH 082/113] Updates elasticsearch-persistence repository spec --- .../spec/repository_spec.rb | 125 +++++------------- 1 file changed, 32 insertions(+), 93 deletions(-) diff --git a/elasticsearch-persistence/spec/repository_spec.rb b/elasticsearch-persistence/spec/repository_spec.rb index ef9f0575d..93fd19c16 100644 --- a/elasticsearch-persistence/spec/repository_spec.rb +++ b/elasticsearch-persistence/spec/repository_spec.rb @@ -18,9 +18,7 @@ require 'spec_helper' describe Elasticsearch::Persistence::Repository do - describe '#create' do - before(:all) do class RepositoryWithoutDSL include Elasticsearch::Persistence::Repository @@ -38,7 +36,6 @@ class RepositoryWithoutDSL end context 'when options are provided' do - let(:repository) do RepositoryWithoutDSL.create(document_type: 'note') end @@ -49,7 +46,6 @@ class RepositoryWithoutDSL end context 'when a block is passed' do - let(:repository) do RepositoryWithoutDSL.create(document_type: 'note') do mapping dynamic: 'strict' do @@ -59,11 +55,10 @@ class RepositoryWithoutDSL end it 'executes the block on the instance' do - expect(repository.mapping.to_hash).to eq(note: { dynamic: 'strict', properties: { foo: { type: 'text' } } }) + expect(repository.mapping.to_hash).to eq({ dynamic: 'strict', properties: { foo: { type: 'text' } } }) end context 'when options are provided in the args and set in the block' do - let(:repository) do RepositoryWithoutDSL.create(mapping: double('mapping', to_hash: {}), document_type: 'note') do mapping dynamic: 'strict' do @@ -80,7 +75,6 @@ class RepositoryWithoutDSL end describe '#initialize' do - before(:all) do class RepositoryWithoutDSL include Elasticsearch::Persistence::Repository @@ -98,7 +92,6 @@ class RepositoryWithoutDSL end context 'when options are not provided' do - let(:repository) do RepositoryWithoutDSL.new end @@ -118,7 +111,6 @@ class RepositoryWithoutDSL end context 'when options are provided' do - let(:client) do Elasticsearch::Client.new end @@ -146,13 +138,11 @@ class RepositoryWithoutDSL end context 'when the DSL module is included' do - before(:all) do class RepositoryWithDSL include Elasticsearch::Persistence::Repository include Elasticsearch::Persistence::Repository::DSL - document_type 'note' index_name 'notes_repo' klass Hash client DEFAULT_CLIENT @@ -179,7 +169,6 @@ class RepositoryWithDSL end context '#client' do - it 'allows the value to be set only once on the class' do RepositoryWithDSL.client(double('client', class: 'other_client')) expect(RepositoryWithDSL.client).to be(DEFAULT_CLIENT) @@ -199,7 +188,6 @@ class RepositoryWithDSL end context '#klass' do - it 'allows the value to be set only once on the class' do RepositoryWithDSL.klass(Array) expect(RepositoryWithDSL.klass).to eq(Hash) @@ -229,28 +217,7 @@ class RepositoryWithDSL end end - context '#document_type' do - - it 'allows the value to be set only once on the class' do - RepositoryWithDSL.document_type('other_note') - expect(RepositoryWithDSL.document_type).to eq('note') - end - - it 'sets the value at the class level' do - expect(RepositoryWithDSL.document_type).to eq('note') - end - - it 'sets the value as the default at the instance level' do - expect(RepositoryWithDSL.new.document_type).to eq('note') - end - - it 'allows the value to be overridden with options on the instance' do - expect(RepositoryWithDSL.new(document_type: 'other_note').document_type).to eq('other_note') - end - end - context '#index_name' do - it 'allows the value to be set only once on the class' do RepositoryWithDSL.index_name('other_name') expect(RepositoryWithDSL.index_name).to eq('notes_repo') @@ -270,16 +237,14 @@ class RepositoryWithDSL end describe '#create_index!' do - context 'when the method is called on an instance' do - let(:repository) do RepositoryWithDSL.new end before do begin; repository.delete_index!; rescue; end - repository.create_index!(include_type_name: true) + repository.create_index! end it 'creates the index' do @@ -288,7 +253,6 @@ class RepositoryWithDSL end context 'when the method is called on the class' do - it 'raises a NotImplementedError' do expect { RepositoryWithDSL.create_index! @@ -298,9 +262,7 @@ class RepositoryWithDSL end describe '#delete_index!' do - context 'when the method is called on an instance' do - let(:repository) do RepositoryWithDSL.new end @@ -316,7 +278,6 @@ class RepositoryWithDSL end context 'when the method is called on the class' do - it 'raises a NotImplementedError' do expect { RepositoryWithDSL.delete_index! @@ -326,15 +287,13 @@ class RepositoryWithDSL end describe '#refresh_index!' do - context 'when the method is called on an instance' do - let(:repository) do RepositoryWithDSL.new end before do - repository.create_index!(include_type_name: true) + repository.create_index! end it 'refreshes the index' do @@ -343,7 +302,6 @@ class RepositoryWithDSL end context 'when the method is called on the class' do - it 'raises a NotImplementedError' do expect { RepositoryWithDSL.refresh_index! @@ -353,15 +311,13 @@ class RepositoryWithDSL end describe '#index_exists?' do - context 'when the method is called on an instance' do - let(:repository) do RepositoryWithDSL.new end before do - repository.create_index!(include_type_name: true) + repository.create_index! end it 'determines if the index exists' do @@ -377,7 +333,6 @@ class RepositoryWithDSL end context 'when the method is called on the class' do - it 'raises a NotImplementedError' do expect { RepositoryWithDSL.index_exists? @@ -387,13 +342,15 @@ class RepositoryWithDSL end describe '#mapping' do - let(:expected_mapping) do - { note: { dynamic: 'strict', - properties: { foo: { type: 'object', - properties: { bar: { type: 'text' } } }, - baz: { type: 'text' } } - } + { + dynamic: 'strict', + properties: { + foo: { + type: 'object', + properties: { bar: { type: 'text' } } }, + baz: { type: 'text' } + } } end @@ -410,7 +367,6 @@ class RepositoryWithDSL end context 'when the instance has a different document type' do - let(:expected_mapping) do { other_note: { dynamic: 'strict', properties: { foo: { type: 'object', @@ -427,7 +383,6 @@ class RepositoryWithDSL end describe '#settings' do - it 'sets the value at the class level' do expect(RepositoryWithDSL.settings.to_hash).to eq(number_of_shards: 1, number_of_replicas: 0) end @@ -443,7 +398,6 @@ class RepositoryWithDSL end context 'when the DSL module is not included' do - before(:all) do class RepositoryWithoutDSL include Elasticsearch::Persistence::Repository @@ -546,26 +500,6 @@ class RepositoryWithoutDSL let(:repository) do RepositoryWithoutDSL.new(client: DEFAULT_CLIENT, document_type: 'mytype') end - - context 'when the server is version >= 7.0', if: server_version > '7.0' do - - context 'when the include_type_name option is specified' do - - it 'creates an index' do - repository.create_index!(include_type_name: true) - expect(repository.index_exists?).to eq(true) - end - end - - context 'when the include_type_name option is not specified' do - - it 'raises an error' do - expect { - repository.create_index! - }.to raise_exception(Elastic::Transport::Transport::Errors::BadRequest) - end - end - end end end @@ -582,7 +516,7 @@ class RepositoryWithoutDSL end it 'deletes an index' do - repository.create_index!(include_type_name: true) + repository.create_index! repository.delete_index! expect(repository.index_exists?).to eq(false) end @@ -605,7 +539,7 @@ class RepositoryWithoutDSL end it 'refreshes an index' do - repository.create_index!(include_type_name: true) + repository.create_index! expect(repository.refresh_index!['_shards']).to be_a(Hash) end end @@ -627,7 +561,7 @@ class RepositoryWithoutDSL end it 'returns whether the index exists' do - repository.create_index!(include_type_name: true) + repository.create_index! expect(repository.index_exists?).to be(true) end end @@ -651,10 +585,14 @@ class RepositoryWithoutDSL context 'when a block is passed to the create method' do let(:expected_mapping) do - { note: { dynamic: 'strict', - properties: { foo: { type: 'object', - properties: { bar: { type: 'text' } } }, - baz: { type: 'text' } } + { + dynamic: 'strict', + properties: { + foo: { + type: 'object', + properties: { bar: { type: 'text' } } + }, + baz: { type: 'text' } } } end @@ -695,7 +633,6 @@ class RepositoryWithoutDSL end describe '#settings' do - it 'does not define the method at the class level' do expect { RepositoryWithoutDSL.settings @@ -711,7 +648,6 @@ class RepositoryWithoutDSL end context 'when a block is passed to the #create method' do - let(:repository) do RepositoryWithoutDSL.create(document_type: 'note') do settings number_of_shards: 1, number_of_replicas: 0 @@ -723,13 +659,16 @@ class RepositoryWithoutDSL end context 'when a mapping is set in the block as well' do - let(:expected_mapping) do - { note: { dynamic: 'strict', - properties: { foo: { type: 'object', - properties: { bar: { type: 'text' } } }, - baz: { type: 'text' } } - } + { + dynamic: 'strict', + properties: { + foo: { + type: 'object', + properties: { bar: { type: 'text' } } + }, + baz: { type: 'text' } + } } end From 34a3aa843cdee9a9fae7512522a54a7ce3d1436d Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Fri, 23 Jun 2023 17:36:12 +0100 Subject: [PATCH 083/113] Removes _type, cleans whitespace in elasticsearch-model --- elasticsearch-model/README.md | 14 ++++++-------- elasticsearch-model/lib/elasticsearch/model.rb | 2 -- .../elasticsearch/model/adapters/active_record.rb | 4 ---- .../lib/elasticsearch/model/indexing.rb | 2 -- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/elasticsearch-model/README.md b/elasticsearch-model/README.md index 655485495..12add7e01 100644 --- a/elasticsearch-model/README.md +++ b/elasticsearch-model/README.md @@ -269,8 +269,8 @@ It is possible to search across multiple models with the module method: ```ruby Elasticsearch::Model.search('fox', [Article, Comment]).results.to_a.map(&:to_hash) # => [ -# {"_index"=>"articles", "_type"=>"article", "_id"=>"1", "_score"=>0.35136628, "_source"=>...}, -# {"_index"=>"comments", "_type"=>"comment", "_id"=>"1", "_score"=>0.35136628, "_source"=>...} +# {"_index"=>"articles", "_id"=>"1", "_score"=>0.35136628, "_source"=>...}, +# {"_index"=>"comments", "_id"=>"1", "_score"=>0.35136628, "_source"=>...} # ] Elasticsearch::Model.search('fox', [Article, Comment]).records.to_a @@ -415,13 +415,11 @@ Article.__elasticsearch__.create_index! force: true Article.__elasticsearch__.refresh_index! ``` -By default, index name and document type will be inferred from your class name, -you can set it explicitly, however: +By default, index name will be inferred from your class name, you can set it explicitly, however: ```ruby class Article index_name "articles-#{Rails.env}" - document_type "post" end ``` @@ -529,10 +527,10 @@ class Indexer case operation.to_s when /index/ record = Article.find(record_id) - Client.index index: 'articles', type: 'article', id: record.id, body: record.__elasticsearch__.as_indexed_json + Client.index index: 'articles', id: record.id, body: record.__elasticsearch__.as_indexed_json when /delete/ begin - Client.delete index: 'articles', type: 'article', id: record_id + Client.delete index: 'articles', id: record_id rescue Elastic::Transport::Transport::Errors::NotFound logger.debug "Article not found, ID: #{record_id}" end @@ -555,7 +553,7 @@ You'll see the job being processed in the console where you started the _Sidekiq Indexer JID-eb7e2daf389a1e5e83697128 DEBUG: ["index", "ID: 7"] Indexer JID-eb7e2daf389a1e5e83697128 INFO: PUT http://localhost:9200/articles/article/1 [status:200, request:0.004s, query:n/a] Indexer JID-eb7e2daf389a1e5e83697128 DEBUG: > {"id":1,"title":"Updated", ...} -Indexer JID-eb7e2daf389a1e5e83697128 DEBUG: < {"ok":true,"_index":"articles","_type":"article","_id":"1","_version":6} +Indexer JID-eb7e2daf389a1e5e83697128 DEBUG: < {"ok":true,"_index":"articles","_id":"1","_version":6} Indexer JID-eb7e2daf389a1e5e83697128 INFO: done: 0.006 sec ``` diff --git a/elasticsearch-model/lib/elasticsearch/model.rb b/elasticsearch-model/lib/elasticsearch/model.rb index 7efc5caa9..5b28726cb 100644 --- a/elasticsearch-model/lib/elasticsearch/model.rb +++ b/elasticsearch-model/lib/elasticsearch/model.rb @@ -62,7 +62,6 @@ end module Elasticsearch - # Elasticsearch integration for Ruby models # ========================================= # @@ -108,7 +107,6 @@ module Model def self.included(base) base.class_eval do include Elasticsearch::Model::Proxy - # Delegate common methods to the `__elasticsearch__` ClassMethodsProxy, unless they are defined already class << self METHODS.each do |method| diff --git a/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb b/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb index 64e0277d8..20dee0505 100644 --- a/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb +++ b/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb @@ -18,11 +18,9 @@ module Elasticsearch module Model module Adapter - # An adapter for ActiveRecord-based models # module ActiveRecord - Adapter.register self, lambda { |klass| !!defined?(::ActiveRecord::Base) && klass.respond_to?(:ancestors) && klass.ancestors.include?(::ActiveRecord::Base) } @@ -71,7 +69,6 @@ def load end module Callbacks - # Handle index updates (creating, updating or deleting documents) # when the model changes, by hooking into the lifecycle # @@ -87,7 +84,6 @@ def self.included(base) end module Importing - # Fetch batches of records from the database (used by the import method) # # diff --git a/elasticsearch-model/lib/elasticsearch/model/indexing.rb b/elasticsearch-model/lib/elasticsearch/model/indexing.rb index f270a26b4..30fe0b8ff 100644 --- a/elasticsearch-model/lib/elasticsearch/model/indexing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/indexing.rb @@ -17,7 +17,6 @@ module Elasticsearch module Model - # Provides the necessary support to set up index options (mappings, settings) # as well as instance methods to create, update or delete documents in the index. # @@ -29,7 +28,6 @@ module Model # @see InstanceMethods#delete_document # module Indexing - # Wraps the [index settings](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html) # class Settings From e800f0f0fd70679dfdd0eaca750f5616f43a9ce8 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Fri, 23 Jun 2023 17:38:37 +0100 Subject: [PATCH 084/113] elasticsearch-persistence: Updates to elasticsearch 8, removes type, whitespace cleanup --- .../elasticsearch-persistence.gemspec | 2 +- .../examples/notes/application.rb | 1 - .../elasticsearch/persistence/repository.rb | 18 +- .../persistence/repository/dsl.rb | 14 -- .../persistence/repository/find.rb | 3 - .../persistence/repository/search.rb | 6 +- .../persistence/repository/store.rb | 15 +- .../spec/repository/find_spec.rb | 105 ++-------- .../spec/repository/response/results_spec.rb | 35 ++-- .../spec/repository/search_spec.rb | 180 +++--------------- .../spec/repository/store_spec.rb | 48 +---- .../spec/repository_spec.rb | 70 ++----- elasticsearch-persistence/spec/spec_helper.rb | 2 +- 13 files changed, 92 insertions(+), 407 deletions(-) diff --git a/elasticsearch-persistence/elasticsearch-persistence.gemspec b/elasticsearch-persistence/elasticsearch-persistence.gemspec index c8f5d0fa2..b88c0a317 100644 --- a/elasticsearch-persistence/elasticsearch-persistence.gemspec +++ b/elasticsearch-persistence/elasticsearch-persistence.gemspec @@ -43,7 +43,7 @@ Gem::Specification.new do |s| s.add_dependency 'activemodel', '> 4' s.add_dependency 'activesupport', '> 4' - s.add_dependency 'elasticsearch', '~> 7' + s.add_dependency 'elasticsearch', '~> 8' s.add_dependency 'elasticsearch-model', '7.2.1' s.add_dependency 'hashie' diff --git a/elasticsearch-persistence/examples/notes/application.rb b/elasticsearch-persistence/examples/notes/application.rb index 0f1724476..9b7bc88ae 100644 --- a/elasticsearch-persistence/examples/notes/application.rb +++ b/elasticsearch-persistence/examples/notes/application.rb @@ -75,7 +75,6 @@ class NoteRepository client Elasticsearch::Client.new url: ENV['ELASTICSEARCH_URL'], log: true index_name :notes - document_type :note mapping do indexes :text, analyzer: 'snowball' diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/repository.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/repository.rb index 607de1769..e5fb23c13 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/repository.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/repository.rb @@ -58,7 +58,6 @@ module ClassMethods # @param [ Proc ] block A block to evaluate on the new repository instance. # # @option options [ Symbol, String ] :index_name The name of the index. - # @option options [ Symbol, String ] :document_type The type of documents persisted in this repository. # @option options [ Symbol, String ] :client The client used to handle requests to and from Elasticsearch. # @option options [ Symbol, String ] :klass The class used to instantiate an object when documents are # deserialized. The default is nil, in which case the raw document will be returned as a Hash. @@ -95,7 +94,6 @@ def create(options = {}, &block) # @param [ Hash ] options The options to use. # # @option options [ Symbol, String ] :index_name The name of the index. - # @option options [ Symbol, String ] :document_type The type of documents persisted in this repository. # @option options [ Symbol, String ] :client The client used to handle requests to and from Elasticsearch. # @option options [ Symbol, String ] :klass The class used to instantiate an object when documents are # deserialized. The default is nil, in which case the raw document will be returned as a Hash. @@ -121,19 +119,6 @@ def client Elasticsearch::Client.new end - # Get the document type used by the repository object. - # - # @example - # repository.document_type - # - # @return [ String, Symbol ] The repository's document type. - # - # @since 6.0.0 - def document_type - @document_type ||= @options[:document_type] || - __get_class_value(:document_type) - end - # Get the index name used by the repository. # # @example @@ -180,7 +165,6 @@ def klass def mapping(*args) @memoized_mapping ||= @options[:mapping] || (begin if _mapping = __get_class_value(:mapping) - _mapping.instance_variable_set(:@type, document_type) _mapping end end) || (super && @mapping) @@ -229,7 +213,7 @@ def index_exists?(*args) # # @since 6.0.0 def inspect - "#<#{self.class}:0x#{object_id} index_name=#{index_name} document_type=#{document_type} klass=#{klass}>" + "#<#{self.class}:0x#{object_id} index_name=#{index_name} klass=#{klass}>" end private diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/dsl.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/dsl.rb index de2848071..cab567d1d 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/dsl.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/dsl.rb @@ -23,7 +23,6 @@ module Repository # # @since 6.0.0 module DSL - def self.included(base) base.send(:extend, Elasticsearch::Model::Indexing::ClassMethods) base.send(:extend, ClassMethods) @@ -34,19 +33,6 @@ def self.included(base) # # @since 6.0.0 module ClassMethods - - # Get or set the class-level document type setting. - # - # @example - # MyRepository.document_type - # - # @return [ String, Symbol ] _type The repository's document type. - # - # @since 6.0.0 - def document_type(_type = nil) - @document_type ||= _type - end - # Get or set the class-level index name setting. # # @example diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/find.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/find.rb index fad2593e8..281486a4a 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/find.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/find.rb @@ -64,7 +64,6 @@ def find(*args) # def exists?(id, options={}) request = { index: index_name, id: id } - request[:type] = document_type if document_type client.exists(request.merge(options)) end @@ -84,7 +83,6 @@ def exists?(id, options={}) # def __find_one(id, options={}) request = { index: index_name, id: id } - request[:type] = document_type if document_type document = client.get(request.merge(options)) deserialize(document) rescue Elastic::Transport::Transport::Errors::NotFound => e @@ -95,7 +93,6 @@ def __find_one(id, options={}) # def __find_many(ids, options={}) request = { index: index_name, body: { ids: ids } } - request[:type] = document_type if document_type documents = client.mget(request.merge(options)) documents[DOCS].map do |document| deserialize(document) if document[FOUND] diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/search.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/search.rb index 2aa7db725..db7788682 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/search.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/search.rb @@ -60,8 +60,7 @@ module Search # @return [Elasticsearch::Persistence::Repository::Response::Results] # def search(query_or_definition, options={}) - request = { index: index_name, - type: document_type } + request = { index: index_name } if query_or_definition.respond_to?(:to_hash) request[:body] = query_or_definition.to_hash elsif query_or_definition.is_a?(String) @@ -98,8 +97,7 @@ def search(query_or_definition, options={}) # def count(query_or_definition=nil, options={}) query_or_definition ||= { query: { match_all: {} } } - request = { index: index_name, - type: document_type } + request = { index: index_name } if query_or_definition.respond_to?(:to_hash) request[:body] = query_or_definition.to_hash diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/store.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/store.rb index a8eeb1866..0986d5540 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/repository/store.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/repository/store.rb @@ -27,7 +27,7 @@ module Store # # @example # repository.save(myobject) - # => {"_index"=>"...", "_type"=>"...", "_id"=>"...", "_version"=>1, "created"=>true} + # => {"_index"=>"...", "_id"=>"...", "_version"=>1, "created"=>true} # # @param [ Object ] document The document to save into Elasticsearch. # @param [ Hash ] options The save request options. @@ -40,7 +40,6 @@ def save(document, options={}) request = { index: index_name, id: id, body: serialized } - request[:type] = document_type if document_type client.index(request.merge(options)) end @@ -49,12 +48,12 @@ def save(document, options={}) # @example Update the document with partial data # # repository.update id: 1, title: 'UPDATED', tags: [] - # # => {"_index"=>"...", "_type"=>"...", "_id"=>"1", "_version"=>2} + # # => {"_index"=>"...", "_id"=>"1", "_version"=>2} # # @example Update the document with a script # # repository.update 1, script: 'ctx._source.views += 1' - # # => {"_index"=>"...", "_type"=>"...", "_id"=>"1", "_version"=>3} + # # => {"_index"=>"...", "_id"=>"1", "_version"=>3} # # @param [ Object ] document_or_id The document to update or the id of the document to update. # @param [ Hash ] options The update request options. @@ -65,7 +64,6 @@ def update(document_or_id, options = {}) if document_or_id.is_a?(String) || document_or_id.is_a?(Integer) id = document_or_id body = options - type = document_type else document = serialize(document_or_id) id = __extract_id_from_document(document) @@ -74,9 +72,8 @@ def update(document_or_id, options = {}) else body = { doc: document }.merge(options) end - type = document.delete(:type) || document_type end - client.update(index: index_name, id: id, type: type, body: body) + client.update(index: index_name, id: id, body: body) end # Remove the serialized object or document with specified ID from Elasticsearch @@ -84,7 +81,7 @@ def update(document_or_id, options = {}) # @example Remove the document with ID 1 # # repository.delete(1) - # # => {"_index"=>"...", "_type"=>"...", "_id"=>"1", "_version"=>4} + # # => {"_index"=>"...", "_id"=>"1", "_version"=>4} # # @param [ Object ] document_or_id The document to delete or the id of the document to delete. # @param [ Hash ] options The delete request options. @@ -98,7 +95,7 @@ def delete(document_or_id, options = {}) serialized = serialize(document_or_id) id = __get_id_from_document(serialized) end - client.delete({ index: index_name, type: document_type, id: id }.merge(options)) + client.delete({ index: index_name, id: id }.merge(options)) end end end diff --git a/elasticsearch-persistence/spec/repository/find_spec.rb b/elasticsearch-persistence/spec/repository/find_spec.rb index 083ee4c25..22cc5af5e 100644 --- a/elasticsearch-persistence/spec/repository/find_spec.rb +++ b/elasticsearch-persistence/spec/repository/find_spec.rb @@ -18,7 +18,6 @@ require 'spec_helper' describe Elasticsearch::Persistence::Repository::Find do - after do begin; repository.delete_index!; rescue; end end @@ -28,9 +27,7 @@ end describe '#exists?' do - context 'when the document exists' do - let(:id) do repository.save(a: 1)['_id'] end @@ -41,30 +38,15 @@ end context 'when the document does not exist' do - it 'returns false' do expect(repository.exists?('1')).to be(false) end end - - context 'when options are provided' do - - let(:id) do - repository.save(a: 1)['_id'] - end - - it 'applies the options' do - expect(repository.exists?(id, type: 'other_type')).to be(false) - end - end end describe '#find' do - context 'when options are not provided' do - context 'when a single id is provided' do - let!(:id) do repository.save(a: 1)['_id'] end @@ -75,7 +57,6 @@ end context 'when an array of ids is provided' do - let!(:ids) do 3.times.collect do |i| repository.save(a: i)['_id'] @@ -83,28 +64,30 @@ end it 'retrieves the documents' do - expect(repository.find(ids)).to eq([{ 'a' =>0 }, - { 'a' => 1 }, - { 'a' => 2 }]) + expect(repository.find(ids)).to eq([ + { 'a' =>0 }, + { 'a' => 1 }, + { 'a' => 2 } + ]) end context 'when some documents are found and some are not' do - before do ids[1] = 22 ids end it 'returns nil in the result list for the documents not found' do - expect(repository.find(ids)).to eq([{ 'a' =>0 }, + expect(repository.find(ids)).to eq([ + { 'a' =>0 }, nil, - { 'a' => 2 }]) + { 'a' => 2 } + ]) end end end context 'when multiple ids are provided' do - let!(:ids) do 3.times.collect do |i| repository.save(a: i)['_id'] @@ -112,14 +95,15 @@ end it 'retrieves the documents' do - expect(repository.find(*ids)).to eq([{ 'a' =>0 }, - { 'a' => 1 }, - { 'a' => 2 }]) + expect(repository.find(*ids)).to eq([ + { 'a' =>0 }, + { 'a' => 1 }, + { 'a' => 2 } + ]) end end context 'when the document cannot be found' do - before do begin; repository.create_index!; rescue; end end @@ -131,66 +115,5 @@ end end end - - context 'when options are provided' do - - context 'when a single id is passed' do - - let!(:id) do - repository.save(a: 1)['_id'] - end - - it 'applies the options' do - expect { - repository.find(id, type: 'none') - }.to raise_exception(Elasticsearch::Persistence::Repository::DocumentNotFound) - end - end - - context 'when an array of ids is passed' do - - let!(:ids) do - 3.times.collect do |i| - repository.save(a: i)['_id'] - end - end - - it 'applies the options' do - expect(repository.find(ids, type: 'none')).to eq([nil, nil, nil]) - end - end - - context 'when multiple ids are passed' do - - let!(:ids) do - 3.times.collect do |i| - repository.save(a: i)['_id'] - end - end - - it 'applies the options' do - expect(repository.find(*ids, type: 'none')).to eq([nil, nil, nil]) - end - end - end - - context 'when a document_type is defined on the class' do - - let(:repository) do - MyTestRepository.new(document_type:'other_type', client: DEFAULT_CLIENT, index_name: 'test') - end - - let!(:ids) do - 3.times.collect do |i| - repository.save(a: i)['_id'] - end - end - - it 'uses the document type in the query' do - expect(repository.find(ids)).to eq([{ 'a' =>0 }, - { 'a' => 1 }, - { 'a' => 2 }]) - end - end end end diff --git a/elasticsearch-persistence/spec/repository/response/results_spec.rb b/elasticsearch-persistence/spec/repository/response/results_spec.rb index 9d98cfc79..c4ca44683 100644 --- a/elasticsearch-persistence/spec/repository/response/results_spec.rb +++ b/elasticsearch-persistence/spec/repository/response/results_spec.rb @@ -43,23 +43,24 @@ def deserialize(document) { "took" => 2, "timed_out" => false, "_shards" => {"total" => 5, "successful" => 5, "failed" => 0}, - "hits" => - { "total" => 2, - "max_score" => 0.19, - "hits" => - [{"_index" => "my_index", - "_type" => "note", - "_id" => "1", - "_score" => 0.19, - "_source" => {"id" => 1, "title" => "Test 1"}}, - - {"_index" => "my_index", - "_type" => "note", - "_id" => "2", - "_score" => 0.19, - "_source" => {"id" => 2, "title" => "Test 2"}} - ] - } + "hits" => { + "total" => 2, + "max_score" => 0.19, + "hits" => [ + { + "_index" => "my_index", + "_id" => "1", + "_score" => 0.19, + "_source" => {"id" => 1, "title" => "Test 1"} + }, + { + "_index" => "my_index", + "_id" => "2", + "_score" => 0.19, + "_source" => {"id" => 2, "title" => "Test 2"} + } + ] + } } end diff --git a/elasticsearch-persistence/spec/repository/search_spec.rb b/elasticsearch-persistence/spec/repository/search_spec.rb index 8e94ecc1d..d2e323791 100644 --- a/elasticsearch-persistence/spec/repository/search_spec.rb +++ b/elasticsearch-persistence/spec/repository/search_spec.rb @@ -18,180 +18,54 @@ require 'spec_helper' describe Elasticsearch::Persistence::Repository::Search do - after do begin; repository.delete_index!; rescue; end end - describe '#search' do + let(:repository) do + DEFAULT_REPOSITORY + end - let(:repository) do - DEFAULT_REPOSITORY + describe '#search' do + before do + repository.save({ name: 'user' }, refresh: true) end - context 'when the repository does not have a type set' do - - before do - repository.save({ name: 'user' }, refresh: true) - end - - context 'when a query definition is provided as a hash' do - - it 'uses the default document type' do - expect(repository.search({ query: { match: { name: 'user' } } }).first).to eq('name' => 'user') - end - end - - context 'when a query definition is provided as a string' do - - it 'uses the default document type' do - expect(repository.search('user').first).to eq('name' => 'user') - end - end - - context 'when the query definition is neither a String nor a Hash' do - - it 'raises an ArgumentError' do - expect { - repository.search(1) - }.to raise_exception(ArgumentError) - end - end - - context 'when options are provided' do - - context 'when a query definition is provided as a hash' do - - it 'uses the default document type' do - expect(repository.search({ query: { match: { name: 'user' } } }, type: 'other').first).to be_nil - end - end - - context 'when a query definition is provided as a string' do - - it 'uses the default document type' do - expect(repository.search('user', type: 'other').first).to be_nil - end - end - - context 'when the query definition is neither a String nor a Hash' do - - it 'raises an ArgumentError' do - expect { - repository.search(1) - }.to raise_exception(ArgumentError) - end - end + context 'when a query definition is provided as a hash' do + it 'searches' do + expect(repository.search({ query: { match: { name: 'user' } } }).first).to eq('name' => 'user') end end - context 'when the repository does have a type set' do - - let(:repository) do - MyTestRepository.new(document_type: 'other_note') - end - - before do - repository.save({ name: 'user' }, refresh: true) + context 'when a query definition is provided as a string' do + it 'searches' do + expect(repository.search('user').first).to eq('name' => 'user') end + end - context 'when options are provided' do - - context 'when a query definition is provided as a hash' do - - it 'uses the options' do - expect(repository.search({ query: { match: { name: 'user' } } }, type: 'other').first).to be_nil - end - end - - context 'when a query definition is provided as a string' do - - it 'uses the options' do - expect(repository.search('user', type: 'other').first).to be_nil - end - end - - context 'when the query definition is neither a String nor a Hash' do - - it 'raises an ArgumentError' do - expect { - repository.search(1) - }.to raise_exception(ArgumentError) - end - end + context 'when the query definition is neither a String nor a Hash' do + it 'raises an ArgumentError' do + expect { + repository.search(1) + }.to raise_exception(ArgumentError) end end end describe '#count' do - - context 'when the repository does not have a type set' do - - let(:repository) do - DEFAULT_REPOSITORY - end - - before do - repository.save({ name: 'user' }, refresh: true) - end - - context 'when a query definition is provided as a hash' do - - it 'uses the default document type' do - expect(repository.count({ query: { match: { name: 'user' } } })).to eq(1) - end - end - - context 'when a query definition is provided as a string' do - - it 'uses the default document type' do - expect(repository.count('user')).to eq(1) - end - end - - context 'when options are provided' do - - context 'when a query definition is provided as a hash' do - - it 'uses the options' do - expect(repository.count({ query: { match: { name: 'user' } } }, type: 'other')).to eq(0) - end - end - - context 'when a query definition is provided as a string' do - - it 'uses the options' do - expect(repository.count('user', type: 'other')).to eq(0) - end - end - end + before do + repository.save({ name: 'usuario' }, refresh: true) end - context 'when the repository does have a type set' do - - let(:repository) do - MyTestRepository.new(document_type: 'other_note') + context 'when a query definition is provided as a hash' do + it 'uses the default document type' do + expect(repository.count({ query: { match: { name: 'usuario' } } })).to eq(1) end + end - before do - repository.save({ name: 'user' }, refresh: true) - end - - context 'when options are provided' do - - context 'when a query definition is provided as a hash' do - - it 'uses the options' do - expect(repository.count({ query: { match: { name: 'user' } } }, type: 'other')).to eq(0) - end - end - - context 'when a query definition is provided as a string' do - - it 'uses the options' do - expect(repository.count('user', type: 'other')).to eq(0) - end - end + context 'when a query definition is provided as a string' do + it 'uses the default document type' do + expect(repository.count('usuario')).to eq(1) end end end diff --git a/elasticsearch-persistence/spec/repository/store_spec.rb b/elasticsearch-persistence/spec/repository/store_spec.rb index 82e1d3b01..5be0b5df8 100644 --- a/elasticsearch-persistence/spec/repository/store_spec.rb +++ b/elasticsearch-persistence/spec/repository/store_spec.rb @@ -18,7 +18,6 @@ require 'spec_helper' describe Elasticsearch::Persistence::Repository::Store do - let(:repository) do DEFAULT_REPOSITORY end @@ -28,7 +27,6 @@ end describe '#save' do - let(:document) do { a: 1 } end @@ -42,7 +40,6 @@ end context 'when the repository defines a custom serialize method' do - before do class OtherNoteRepository include Elasticsearch::Persistence::Repository @@ -70,24 +67,9 @@ def serialize(document) expect(repository.find(response['_id'])).to eq('b' => 1) end end - - context 'when options are provided' do - - let!(:response) do - repository.save(document) - end - - it 'saves the document using the options' do - expect { - repository.find(response['_id']) - }.to raise_exception(Elasticsearch::Persistence::Repository::DocumentNotFound) - expect(repository.find(response['_id'])).to eq('a' => 1) - end - end end describe '#update' do - before(:all) do class Note def to_hash @@ -103,15 +85,12 @@ def to_hash end context 'when the document exists' do - let!(:id) do repository.save(Note.new)['_id'] end context 'when an id is provided' do - context 'when a doc is specified in the options' do - before do repository.update(id, doc: { text: 'testing_2' }) end @@ -122,7 +101,6 @@ def to_hash end context 'when a script is specified in the options' do - before do repository.update(id, script: { inline: 'ctx._source.views += 1' }) end @@ -133,7 +111,6 @@ def to_hash end context 'when params are specified in the options' do - before do repository.update(id, script: { inline: 'ctx._source.views += params.count', params: { count: 2 } }) @@ -145,7 +122,6 @@ def to_hash end context 'when upsert is specified in the options' do - before do repository.update(id, script: { inline: 'ctx._source.views += 1' }, upsert: { text: 'testing_2' }) @@ -157,7 +133,6 @@ def to_hash end context 'when doc_as_upsert is specified in the options' do - before do repository.update(id, doc: { text: 'testing_2' }, doc_as_upsert: true) @@ -170,9 +145,7 @@ def to_hash end context 'when a document is provided as the query criteria' do - context 'when no options are provided' do - before do repository.update(id: id, text: 'testing_2') end @@ -183,9 +156,7 @@ def to_hash end context 'when options are provided' do - context 'when a doc is specified in the options' do - before do repository.update({ id: id, text: 'testing' }, doc: { text: 'testing_2' }) end @@ -196,10 +167,11 @@ def to_hash end context 'when a script is specified in the options' do - before do - repository.update({ id: id, text: 'testing' }, - script: { inline: 'ctx._source.views += 1' }) + repository.update( + { id: id, text: 'testing' }, + script: { inline: 'ctx._source.views += 1' } + ) end it 'updates using the id and script from the options' do @@ -208,7 +180,6 @@ def to_hash end context 'when params are specified in the options' do - before do repository.update({ id: id, text: 'testing' }, script: { inline: 'ctx._source.views += params.count', @@ -221,7 +192,6 @@ def to_hash end context 'when upsert is specified in the options' do - before do repository.update({ id: id, text: 'testing_2' }, doc_as_upsert: true) @@ -236,9 +206,7 @@ def to_hash end context 'when the document does not exist' do - context 'when an id is provided 'do - it 'raises an exception' do expect { repository.update(1, doc: { text: 'testing_2' }) @@ -246,7 +214,6 @@ def to_hash end context 'when upsert is provided' do - before do repository.update(1, doc: { text: 'testing' }, doc_as_upsert: true) end @@ -258,7 +225,6 @@ def to_hash end context 'when a document is provided' do - it 'raises an exception' do expect { repository.update(id: 1, text: 'testing_2') @@ -266,7 +232,6 @@ def to_hash end context 'when upsert is provided' do - before do repository.update({ id: 1, text: 'testing' }, doc_as_upsert: true) end @@ -280,7 +245,6 @@ def to_hash end describe '#delete' do - before(:all) do class Note def to_hash @@ -296,13 +260,11 @@ def to_hash end context 'when the document exists' do - let!(:id) do repository.save(Note.new)['_id'] end context 'an id is provided' do - before do repository.delete(id) end @@ -315,7 +277,6 @@ def to_hash end context 'when a document is provided' do - before do repository.delete(id: id, text: 'testing') end @@ -329,7 +290,6 @@ def to_hash end context 'when the document does not exist' do - before do repository.create_index! end diff --git a/elasticsearch-persistence/spec/repository_spec.rb b/elasticsearch-persistence/spec/repository_spec.rb index 93fd19c16..a605a5250 100644 --- a/elasticsearch-persistence/spec/repository_spec.rb +++ b/elasticsearch-persistence/spec/repository_spec.rb @@ -35,19 +35,9 @@ class RepositoryWithoutDSL expect(RepositoryWithoutDSL.create).to be_a(RepositoryWithoutDSL) end - context 'when options are provided' do - let(:repository) do - RepositoryWithoutDSL.create(document_type: 'note') - end - - it 'sets the options on the instance' do - expect(repository.document_type).to eq('note') - end - end - context 'when a block is passed' do let(:repository) do - RepositoryWithoutDSL.create(document_type: 'note') do + RepositoryWithoutDSL.create do mapping dynamic: 'strict' do indexes :foo end @@ -60,7 +50,7 @@ class RepositoryWithoutDSL context 'when options are provided in the args and set in the block' do let(:repository) do - RepositoryWithoutDSL.create(mapping: double('mapping', to_hash: {}), document_type: 'note') do + RepositoryWithoutDSL.create(mapping: double('mapping', to_hash: {})) do mapping dynamic: 'strict' do indexes :foo end @@ -116,17 +106,13 @@ class RepositoryWithoutDSL end let(:repository) do - RepositoryWithoutDSL.new(client: client, document_type: 'user', index_name: 'users', klass: Array) + RepositoryWithoutDSL.new(client: client, index_name: 'users', klass: Array) end it 'sets the client' do expect(repository.client).to be(client) end - it 'sets document type' do - expect(repository.document_type).to eq('user') - end - it 'sets index name' do expect(repository.index_name).to eq('users') end @@ -368,17 +354,20 @@ class RepositoryWithDSL context 'when the instance has a different document type' do let(:expected_mapping) do - { other_note: { dynamic: 'strict', - properties: { foo: { type: 'object', - properties: { bar: { type: 'text' } } }, - baz: { type: 'text' } } - } + { + other_note: + { + dynamic: 'strict', + properties: { + foo: { + type: 'object', + properties: { bar: { type: 'text' } } + }, + baz: { type: 'text' } + } + } } end - - it 'updates the mapping to use the document type' do - expect(RepositoryWithDSL.new(document_type: 'other_note').mapping.to_hash).to eq(expected_mapping) - end end end @@ -444,21 +433,8 @@ class RepositoryWithoutDSL end end - context '#document_type' do - - it 'does not define the method at the class level' do - expect { - RepositoryWithoutDSL.document_type - }.to raise_exception(NoMethodError) - end - - it 'allows the value to be overridden with options on the instance' do - expect(RepositoryWithoutDSL.new(document_type: 'notes').document_type).to eq('notes') - end - end context '#index_name' do - it 'does not define the method at the class level' do expect { RepositoryWithoutDSL.index_name @@ -475,7 +451,6 @@ class RepositoryWithoutDSL end describe '#create_index!' do - let(:repository) do RepositoryWithoutDSL.new(client: DEFAULT_CLIENT) end @@ -494,17 +469,9 @@ class RepositoryWithoutDSL repository.create_index! expect(repository.index_exists?).to eq(true) end - - context 'when the repository has a document type defined' do - - let(:repository) do - RepositoryWithoutDSL.new(client: DEFAULT_CLIENT, document_type: 'mytype') - end - end end describe '#delete_index!' do - let(:repository) do RepositoryWithoutDSL.new(client: DEFAULT_CLIENT) end @@ -523,7 +490,6 @@ class RepositoryWithoutDSL end describe '#refresh_index!' do - let(:repository) do RepositoryWithoutDSL.new(client: DEFAULT_CLIENT) end @@ -598,7 +564,7 @@ class RepositoryWithoutDSL end let(:repository) do - RepositoryWithoutDSL.create(document_type: 'note') do + RepositoryWithoutDSL.create do mapping dynamic: 'strict' do indexes :foo do indexes :bar @@ -649,7 +615,7 @@ class RepositoryWithoutDSL context 'when a block is passed to the #create method' do let(:repository) do - RepositoryWithoutDSL.create(document_type: 'note') do + RepositoryWithoutDSL.create do settings number_of_shards: 1, number_of_replicas: 0 end end @@ -673,7 +639,7 @@ class RepositoryWithoutDSL end let(:repository) do - RepositoryWithoutDSL.create(document_type: 'note') do + RepositoryWithoutDSL.create do settings number_of_shards: 1, number_of_replicas: 0 do mapping dynamic: 'strict' do indexes :foo do diff --git a/elasticsearch-persistence/spec/spec_helper.rb b/elasticsearch-persistence/spec/spec_helper.rb index 6e5f58402..e577d3808 100644 --- a/elasticsearch-persistence/spec/spec_helper.rb +++ b/elasticsearch-persistence/spec/spec_helper.rb @@ -47,7 +47,7 @@ class MyTestRepository # The default repository to be used by tests. # # @since 6.0.0 -DEFAULT_REPOSITORY = MyTestRepository.new(index_name: 'my_test_repository', document_type: 'test') +DEFAULT_REPOSITORY = MyTestRepository.new(index_name: 'my_test_repository') # Get the Elasticsearch server version. # From e45678941c334553ab4ad0c212aa846fa332fc4d Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Fri, 23 Jun 2023 17:39:36 +0100 Subject: [PATCH 085/113] elasticsearch-persistence: Update calling client transport --- elasticsearch-persistence/README.md | 4 ++-- elasticsearch-persistence/examples/notes/test.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/elasticsearch-persistence/README.md b/elasticsearch-persistence/README.md index e8cb0aa8a..a9b1b39ec 100644 --- a/elasticsearch-persistence/README.md +++ b/elasticsearch-persistence/README.md @@ -237,7 +237,7 @@ You can also override the default configuration with options passed to the initi ```ruby client = Elasticsearch::Client.new(url: 'http://localhost:9250', log: true) -client.transport.transport.logger.formatter = proc { |s, d, p, m| "\e[2m# #{m}\n\e[0m" } +client.transport.logger.formatter = proc { |s, d, p, m| "\e[2m# #{m}\n\e[0m" } repository = NoteRepository.new(client: client, index_name: 'notes_development') repository.create_index!(force: true) @@ -268,7 +268,7 @@ The repository uses the standard Elasticsearch [client](https://github.com/elast ```ruby client = Elasticsearch::Client.new(url: 'http://search.server.org') repository = NoteRepository.new(client: client) -repository.client.transport.transport.logger = Logger.new(STDERR) +repository.client.transport.logger = Logger.new(STDERR) repository.client # => Elasticsearch::Client diff --git a/elasticsearch-persistence/examples/notes/test.rb b/elasticsearch-persistence/examples/notes/test.rb index 27922933b..b57105341 100644 --- a/elasticsearch-persistence/examples/notes/test.rb +++ b/elasticsearch-persistence/examples/notes/test.rb @@ -90,7 +90,7 @@ def app app.settings.repository.client = Elasticsearch::Client.new \ hosts: [{ host: 'localhost', port: ENV.fetch('TEST_CLUSTER_PORT', 9250)}], log: true - app.settings.repository.client.transport.transport.logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" } + app.settings.repository.client.transport.logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" } app.settings.repository.create_index! force: true app.settings.repository.client.cluster.health wait_for_status: 'yellow' end From 3fc610187fa731ba17b243eee0c571e8fa2c7dcc Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Fri, 23 Jun 2023 17:40:32 +0100 Subject: [PATCH 086/113] elasticsearch-rails: remove type, whitespace cleanup --- .../lib/rails/templates/indexer.rb | 2 +- .../spec/instrumentation_spec.rb | 37 +++++++++++-------- elasticsearch-rails/spec/lograge_spec.rb | 9 +++-- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/elasticsearch-rails/lib/rails/templates/indexer.rb b/elasticsearch-rails/lib/rails/templates/indexer.rb index 1ea1d9b6c..4ba92a45e 100644 --- a/elasticsearch-rails/lib/rails/templates/indexer.rb +++ b/elasticsearch-rails/lib/rails/templates/indexer.rb @@ -37,7 +37,7 @@ def perform(operation, klass, record_id, options={}) record.__elasticsearch__.client = Client record.__elasticsearch__.__send__ "#{operation}_document" when /delete/ - Client.delete index: klass.constantize.index_name, type: klass.constantize.document_type, id: record_id + Client.delete index: klass.constantize.index_name, id: record_id else raise ArgumentError, "Unknown operation '#{operation}'" end end diff --git a/elasticsearch-rails/spec/instrumentation_spec.rb b/elasticsearch-rails/spec/instrumentation_spec.rb index 3fcbc5916..9245549af 100644 --- a/elasticsearch-rails/spec/instrumentation_spec.rb +++ b/elasticsearch-rails/spec/instrumentation_spec.rb @@ -18,13 +18,10 @@ require 'spec_helper' describe 'ActiveSupport::Instrumentation integration' do - before(:all) do class DummyInstrumentationModel extend Elasticsearch::Model::Searching::ClassMethods - - def self.index_name; 'foo'; end - def self.document_type; 'bar'; end + def self.index_name; 'foo'; end end end @@ -33,10 +30,14 @@ def self.document_type; 'bar'; end end let(:response_document) do - { 'took' => '5ms', - 'hits' => { 'total' => 123, - 'max_score' => 456, - 'hits' => [] } } + { + 'took' => '5ms', + 'hits' => { + 'total' => 123, + 'max_score' => 456, + 'hits' => [] + } + } end let(:search) do @@ -53,7 +54,6 @@ def self.document_type; 'bar'; end end context 'SearchRequest#execute!' do - it 'wraps the method with instrumentation' do expect(search).to respond_to(:execute_without_instrumentation!) expect(search).to respond_to(:execute_with_instrumentation!) @@ -61,14 +61,19 @@ def self.document_type; 'bar'; end end context 'Model#search' do - before do - expect(ActiveSupport::Notifications).to receive(:instrument).with('search.elasticsearch', - { klass: 'DummyInstrumentationModel', - name: 'Search', - search: { body: query, - index: 'foo', - type: 'bar' } }).and_return({}) + expect(ActiveSupport::Notifications). + to receive(:instrument). + with('search.elasticsearch', + { + klass: 'DummyInstrumentationModel', + name: 'Search', + search: { + body: query, + index: 'foo', + } + } + ).and_return({}) end let(:query) do diff --git a/elasticsearch-rails/spec/lograge_spec.rb b/elasticsearch-rails/spec/lograge_spec.rb index 980aa9f1b..3b54f1839 100644 --- a/elasticsearch-rails/spec/lograge_spec.rb +++ b/elasticsearch-rails/spec/lograge_spec.rb @@ -38,14 +38,15 @@ require 'elasticsearch/rails/lograge' describe 'ActiveSupport::Instrumentation integration' do - before do Elasticsearch::Rails::Lograge::Railtie.run_initializers end it 'customizes the Lograge configuration' do - expect(Elasticsearch::Rails::Lograge::Railtie.initializers - .select { |i| i.name == 'elasticsearch.lograge' } - .first).not_to be_nil + expect( + Elasticsearch::Rails::Lograge::Railtie.initializers + .select { |i| i.name == 'elasticsearch.lograge' } + .first + ).not_to be_nil end end From c18676b925df060d96daec5b886a47643f75bb09 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Fri, 23 Jun 2023 17:46:04 +0100 Subject: [PATCH 087/113] Bump version to 8.0.0 --- elasticsearch-model/lib/elasticsearch/model/version.rb | 2 +- .../lib/elasticsearch/persistence/version.rb | 2 +- elasticsearch-rails/lib/elasticsearch/rails/version.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/version.rb b/elasticsearch-model/lib/elasticsearch/model/version.rb index cdd631896..eb3aebc12 100644 --- a/elasticsearch-model/lib/elasticsearch/model/version.rb +++ b/elasticsearch-model/lib/elasticsearch/model/version.rb @@ -17,6 +17,6 @@ module Elasticsearch module Model - VERSION = "7.2.1" + VERSION = '8.0.0'.freeze end end diff --git a/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb b/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb index 18fe2466d..7fa2ce112 100644 --- a/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb +++ b/elasticsearch-persistence/lib/elasticsearch/persistence/version.rb @@ -17,6 +17,6 @@ module Elasticsearch module Persistence - VERSION = '7.2.1' + VERSION = '8.0.0'.freeze end end diff --git a/elasticsearch-rails/lib/elasticsearch/rails/version.rb b/elasticsearch-rails/lib/elasticsearch/rails/version.rb index 07d084dae..6506ad906 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/version.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/version.rb @@ -17,6 +17,6 @@ module Elasticsearch module Rails - VERSION = "7.2.1" + VERSION = '8.0.0'.freeze end end From 6d9cb023c579158cec34bf6745d4b1f08342f2be Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Fri, 23 Jun 2023 17:54:29 +0100 Subject: [PATCH 088/113] elasticsearch-model: update calling transport in examples --- elasticsearch-model/examples/activerecord_associations.rb | 2 +- elasticsearch-model/examples/activerecord_custom_analyzer.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/elasticsearch-model/examples/activerecord_associations.rb b/elasticsearch-model/examples/activerecord_associations.rb index 17d521cbf..b8100b33b 100644 --- a/elasticsearch-model/examples/activerecord_associations.rb +++ b/elasticsearch-model/examples/activerecord_associations.rb @@ -81,7 +81,7 @@ # ----- Elasticsearch client setup ---------------------------------------------------------------- Elasticsearch::Model.client = Elasticsearch::Client.new log: true -Elasticsearch::Model.client.transport.transport.logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" } +Elasticsearch::Model.client.transport.logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" } # ----- Search integration ------------------------------------------------------------------------ diff --git a/elasticsearch-model/examples/activerecord_custom_analyzer.rb b/elasticsearch-model/examples/activerecord_custom_analyzer.rb index d16ddbd11..886eaab91 100644 --- a/elasticsearch-model/examples/activerecord_custom_analyzer.rb +++ b/elasticsearch-model/examples/activerecord_custom_analyzer.rb @@ -37,8 +37,8 @@ end end -Elasticsearch::Model.client.transport.transport.logger = ActiveSupport::Logger.new(STDOUT) -Elasticsearch::Model.client.transport.transport.logger.formatter = lambda { |s, d, p, m| "#{m.ansi(:faint)}\n" } +Elasticsearch::Model.client.transport.logger = ActiveSupport::Logger.new(STDOUT) +Elasticsearch::Model.client.transport.logger.formatter = lambda { |s, d, p, m| "#{m.ansi(:faint)}\n" } class Article < ActiveRecord::Base include Elasticsearch::Model From 8f645f54d4a27a9d2e3112dc5f77901a236af623 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 27 Jun 2023 10:27:41 +0100 Subject: [PATCH 089/113] persistence: Updates dependency on model --- elasticsearch-persistence/elasticsearch-persistence.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticsearch-persistence/elasticsearch-persistence.gemspec b/elasticsearch-persistence/elasticsearch-persistence.gemspec index b88c0a317..6dbb7386f 100644 --- a/elasticsearch-persistence/elasticsearch-persistence.gemspec +++ b/elasticsearch-persistence/elasticsearch-persistence.gemspec @@ -44,7 +44,7 @@ Gem::Specification.new do |s| s.add_dependency 'activemodel', '> 4' s.add_dependency 'activesupport', '> 4' s.add_dependency 'elasticsearch', '~> 8' - s.add_dependency 'elasticsearch-model', '7.2.1' + s.add_dependency 'elasticsearch-model', '8' s.add_dependency 'hashie' s.add_development_dependency 'bundler' From 1422382dcfa4bfae1fb44d6c711e8ed1d7092287 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 27 Jun 2023 10:54:00 +0100 Subject: [PATCH 090/113] specs: removes active_record_at_least_4? function and related code --- .../active_record/associations_spec.rb | 124 +++++++----------- .../adapters/active_record/basic_spec.rb | 12 +- elasticsearch-model/spec/spec_helper.rb | 9 -- 3 files changed, 50 insertions(+), 95 deletions(-) diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/associations_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/associations_spec.rb index c3e460ffb..14000b693 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/associations_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/associations_spec.rb @@ -18,7 +18,6 @@ require 'spec_helper' describe 'Elasticsearch::Model::Adapter::ActiveRecord Associations' do - before(:all) do ActiveRecord::Schema.define(version: 1) do create_table :categories do |t| @@ -76,7 +75,6 @@ end context 'when a document is created' do - before do Post.create!(title: 'Test') Post.create!(title: 'Testing Coding') @@ -97,9 +95,7 @@ end describe 'has_many_and_belongs_to association' do - - context 'when an association is updated' do - + context 'when an association is updated' do before do post.categories = [category_a, category_b] Post.__elasticsearch__.refresh_index! @@ -119,20 +115,20 @@ let(:search_result) do Post.search(query: { - bool: { - must: { - multi_match: { - fields: ['title'], - query: 'first' - } - }, - filter: { - terms: { - categories: ['One'] - } - } - } - } ) + bool: { + must: { + multi_match: { + fields: ['title'], + query: 'first' + } + }, + filter: { + terms: { + categories: ['One'] + } + } + } + } ) end it 'applies the update with' do @@ -144,7 +140,6 @@ end context 'when an association is deleted' do - before do post.categories = [category_a, category_b] post.categories = [category_b] @@ -165,20 +160,20 @@ let(:search_result) do Post.search(query: { - bool: { - must: { - multi_match: { - fields: ['title'], - query: 'first' - } - }, - filter: { - terms: { - categories: ['One'] - } - } - } - } ) + bool: { + must: { + multi_match: { + fields: ['title'], + query: 'first' + } + }, + filter: { + terms: { + categories: ['One'] + } + } + } + } ) end it 'applies the update with a reindex' do @@ -189,9 +184,7 @@ end describe 'has_many through association' do - context 'when the association is updated' do - before do author_a = Author.where(first_name: "John", last_name: "Smith").first_or_create! author_b = Author.where(first_name: "Mary", last_name: "Smith").first_or_create! @@ -210,33 +203,17 @@ Post.__elasticsearch__.refresh_index! end - context 'if active record is at least 4' do - - let(:search_result) do - Post.search('authors.full_name:john') - end - - it 'applies the update', if: active_record_at_least_4? do - expect(search_result.results.size).to eq(2) - expect(search_result.records.size).to eq(2) - end + let(:search_result) do + Post.search('authors.full_name:john') end - context 'if active record is less than 4' do - - let(:search_result) do - Post.search('authors.author.full_name:john') - end - - it 'applies the update', if: !active_record_at_least_4? do - expect(search_result.results.size).to eq(2) - expect(search_result.records.size).to eq(2) - end + it 'applies the update' do + expect(search_result.results.size).to eq(2) + expect(search_result.records.size).to eq(2) end end - context 'when an association is added', if: active_record_at_least_4? do - + context 'when an association is added' do before do author_a = Author.where(first_name: "John", last_name: "Smith").first_or_create! author_b = Author.where(first_name: "Mary", last_name: "Smith").first_or_create! @@ -262,9 +239,7 @@ end describe 'has_many association' do - - context 'when an association is added', if: active_record_at_least_4? do - + context 'when an association is added' do before do # Create posts post_1 = Post.create!(title: "First Post", text: "This is the first post...") @@ -282,18 +257,18 @@ let(:search_result) do Post.search(query: { - nested: { - path: 'comments', - query: { - bool: { - must: [ - { match: { 'comments.author' => 'john' } }, - { match: { 'comments.text' => 'good' } } - ] - } - } - } - }) + nested: { + path: 'comments', + query: { + bool: { + must: [ + { match: { 'comments.author' => 'john' } }, + { match: { 'comments.text' => 'good' } } + ] + } + } + } + }) end it 'adds the association' do @@ -303,9 +278,7 @@ end describe '#touch' do - context 'when a touch callback is defined on the model' do - before do # Create categories category_a = Category.where(title: "One").first_or_create! @@ -329,7 +302,6 @@ end describe '#includes' do - before do post_1 = Post.create(title: 'One') post_2 = Post.create(title: 'Two') diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb index 5dc91da9e..20392b42b 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb @@ -327,31 +327,23 @@ end describe 'ordering of SQL queries' do - context 'when order is called on the ActiveRecord query' do - let(:search_result) do Article.search query: { match: { title: { query: 'test' } } } end - it 'allows the SQL query to be ordered independent of the Elasticsearch results order', unless: active_record_at_least_4? do - expect(search_result.records.order('title DESC').first.title).to eq('Testing Coding') - expect(search_result.records.order('title DESC')[0].title).to eq('Testing Coding') - end - - it 'allows the SQL query to be ordered independent of the Elasticsearch results order', if: active_record_at_least_4? do + it 'allows the SQL query to be ordered independent of the Elasticsearch results order' do expect(search_result.records.order(title: :desc).first.title).to eq('Testing Coding') expect(search_result.records.order(title: :desc)[0].title).to eq('Testing Coding') end end context 'when more methods are chained on the ActiveRecord query' do - let(:search_result) do Article.search query: {match: {title: {query: 'test'}}} end - it 'allows the SQL query to be ordered independent of the Elasticsearch results order', if: active_record_at_least_4? do + it 'allows the SQL query to be ordered independent of the Elasticsearch results order' do expect(search_result.records.distinct.order(title: :desc).first.title).to eq('Testing Coding') expect(search_result.records.distinct.order(title: :desc)[0].title).to eq('Testing Coding') end diff --git a/elasticsearch-model/spec/spec_helper.rb b/elasticsearch-model/spec/spec_helper.rb index 413b5f03e..d3a1e303f 100644 --- a/elasticsearch-model/spec/spec_helper.rb +++ b/elasticsearch-model/spec/spec_helper.rb @@ -65,15 +65,6 @@ end end -# Is the ActiveRecord version at least 4.0? -# -# @return [ true, false ] Whether the ActiveRecord version is at least 4.0. -# -# @since 6.0.1 -def active_record_at_least_4? - defined?(::ActiveRecord) && ::ActiveRecord::VERSION::MAJOR >= 4 -end - # Delete all documents from the indices of the provided list of models. # # @param [ Array ] models The list of models. From e5281378a388b0edacdd9587d66d86bcf947d7ab Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 14 Sep 2023 09:21:19 +0100 Subject: [PATCH 091/113] Adds debug gem --- Gemfile | 1 + elasticsearch-model/gemfiles/6.1.gemfile | 2 +- elasticsearch-model/gemfiles/7.0.gemfile | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index b6cb7cca7..b04ce3e9e 100644 --- a/Gemfile +++ b/Gemfile @@ -24,6 +24,7 @@ gem 'pry' gem 'rake', '~> 12' group :development do + gem 'debug' gem 'rspec' gem 'yard' end diff --git a/elasticsearch-model/gemfiles/6.1.gemfile b/elasticsearch-model/gemfiles/6.1.gemfile index 5e5be171f..2260df5cd 100644 --- a/elasticsearch-model/gemfiles/6.1.gemfile +++ b/elasticsearch-model/gemfiles/6.1.gemfile @@ -30,7 +30,7 @@ gem 'sqlite3' unless defined?(JRUBY_VERSION) # gem 'mongoid', '~> 6' group :development, :testing do - gem 'byebug' + gem 'debug' gem 'pry-nav' gem 'rspec' end diff --git a/elasticsearch-model/gemfiles/7.0.gemfile b/elasticsearch-model/gemfiles/7.0.gemfile index bc3bd63a5..97f1366c1 100644 --- a/elasticsearch-model/gemfiles/7.0.gemfile +++ b/elasticsearch-model/gemfiles/7.0.gemfile @@ -30,7 +30,7 @@ gem 'sqlite3' unless defined?(JRUBY_VERSION) # gem 'mongoid', '~> 6' group :development, :testing do - gem 'byebug' + gem 'debug' gem 'pry-nav' gem 'rspec' end From 283ce0a59edbc4c580ede043aaced221b63ab8b6 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 14 Sep 2023 09:22:35 +0100 Subject: [PATCH 092/113] Whitespace fixes --- .../lib/elasticsearch/model/adapters/default.rb | 4 ---- .../lib/elasticsearch/model/adapters/multiple.rb | 1 - .../lib/elasticsearch/model/importing.rb | 3 --- .../lib/elasticsearch/model/indexing.rb | 1 - .../model/adapters/active_record/basic_spec.rb | 16 +--------------- .../adapters/active_record/pagination_spec.rb | 8 -------- .../adapters/active_record/parent_child_spec.rb | 3 --- .../adapters/active_record/serialization_spec.rb | 4 ---- .../spec/elasticsearch/model/multimodel_spec.rb | 2 -- .../spec/elasticsearch/model/proxy_spec.rb | 1 - 10 files changed, 1 insertion(+), 42 deletions(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/adapters/default.rb b/elasticsearch-model/lib/elasticsearch/model/adapters/default.rb index 9891b5d64..914514136 100644 --- a/elasticsearch-model/lib/elasticsearch/model/adapters/default.rb +++ b/elasticsearch-model/lib/elasticsearch/model/adapters/default.rb @@ -18,15 +18,12 @@ module Elasticsearch module Model module Adapter - # The default adapter for models which haven't one registered # module Default - # Module for implementing methods and logic related to fetching records from the database # module Records - # Return the collection of records fetched from the database # # By default uses `MyModel#find[1, 2, 3]` @@ -60,7 +57,6 @@ def __transform raise NotImplemented, "Method not implemented for default adapter" end end - end end end diff --git a/elasticsearch-model/lib/elasticsearch/model/adapters/multiple.rb b/elasticsearch-model/lib/elasticsearch/model/adapters/multiple.rb index 30d851043..9a8657f1d 100644 --- a/elasticsearch-model/lib/elasticsearch/model/adapters/multiple.rb +++ b/elasticsearch-model/lib/elasticsearch/model/adapters/multiple.rb @@ -18,7 +18,6 @@ module Elasticsearch module Model module Adapter - # An adapter to be used for deserializing results from multiple models, # retrieved through `Elasticsearch::Model.search` # diff --git a/elasticsearch-model/lib/elasticsearch/model/importing.rb b/elasticsearch-model/lib/elasticsearch/model/importing.rb index 3060e178a..26e05458c 100644 --- a/elasticsearch-model/lib/elasticsearch/model/importing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/importing.rb @@ -158,11 +158,8 @@ def import(options={}, &block) index: target_index, body: __batch_to_bulk(batch, transform) } - params[:pipeline] = pipeline if pipeline - response = client.bulk params - yield response if block_given? errors += response['items'].select { |k, v| k.values.first['error'] } diff --git a/elasticsearch-model/lib/elasticsearch/model/indexing.rb b/elasticsearch-model/lib/elasticsearch/model/indexing.rb index 30fe0b8ff..08763a8f5 100644 --- a/elasticsearch-model/lib/elasticsearch/model/indexing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/indexing.rb @@ -97,7 +97,6 @@ def as_json(options={}) end module ClassMethods - # Defines mappings for the index # # @example Define mapping for model diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb index 20392b42b..83754cd0b 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb @@ -76,7 +76,6 @@ end describe 'indexing a document' do - let(:search_result) do Article.search('title:test') end @@ -88,7 +87,6 @@ end describe '#results' do - let(:search_result) do Article.search('title:test') end @@ -97,12 +95,11 @@ expect(search_result.results.first).to be_a(Elasticsearch::Model::Response::Result) end - it 'prooperly loads the document' do + it 'properly loads the document' do expect(search_result.results.first.title).to eq('Test') end context 'when the result contains other data' do - let(:search_result) do Article.search(query: { match: { title: 'test' } }, highlight: { fields: { title: {} } }) end @@ -119,7 +116,6 @@ end describe '#records' do - let(:search_result) do Article.search('title:test') end @@ -134,7 +130,6 @@ end describe 'Enumerable' do - let(:search_result) do Article.search('title:test') end @@ -149,7 +144,6 @@ end describe '#id' do - let(:search_result) do Article.search('title:test') end @@ -173,7 +167,6 @@ end describe 'search results order' do - let(:search_result) do Article.search(query: { match: { title: 'code' }}, sort: { clicks: :desc }) end @@ -196,7 +189,6 @@ end describe 'a paged collection' do - let(:search_result) do Article.search(query: { match: { title: { query: 'test' } } }, size: 2, @@ -212,7 +204,6 @@ end describe '#destroy' do - before do Article.create!(title: 'destroy', body: '', clicks: 1) Article.__elasticsearch__.refresh_index! @@ -233,7 +224,6 @@ end describe 'full document updates' do - before do article = Article.create!(title: 'update', body: '', clicks: 1) Article.__elasticsearch__.refresh_index! @@ -254,7 +244,6 @@ end describe 'attribute updates' do - before do article = Article.create!(title: 'update', body: '', clicks: 1) Article.__elasticsearch__.refresh_index! @@ -275,7 +264,6 @@ end describe '#save' do - before do article = Article.create!(title: 'save', body: '', clicks: 1) @@ -302,7 +290,6 @@ end describe 'a DSL search' do - let(:search_result) do Article.search(query: { match: { title: { query: 'test' } } }) end @@ -314,7 +301,6 @@ end describe 'chaining SQL queries on response.records' do - let(:search_result) do Article.search(query: { match: { title: { query: 'test' } } }) end diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/pagination_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/pagination_spec.rb index c4a503ed7..3cbd30b7f 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/pagination_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/pagination_spec.rb @@ -18,7 +18,6 @@ require 'spec_helper' describe 'Elasticsearch::Model::Adapter::ActiveRecord Pagination' do - before(:all) do ActiveRecord::Schema.define(:version => 1) do create_table ArticleForPagination.table_name do |t| @@ -41,48 +40,41 @@ end context 'when no other page is specified' do - let(:records) do ArticleForPagination.search('title:test').page(1).records end describe '#size' do - it 'returns the correct size' do expect(records.size).to eq(25) end end describe '#current_page' do - it 'returns the correct current page' do expect(records.current_page).to eq(1) end end describe '#prev_page' do - it 'returns the correct previous page' do expect(records.prev_page).to be_nil end end describe '#next_page' do - it 'returns the correct next page' do expect(records.next_page).to eq(2) end end describe '#total_pages' do - it 'returns the correct total pages' do expect(records.total_pages).to eq(3) end end describe '#first_page?' do - it 'returns the correct first page' do expect(records.first_page?).to be(true) end diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb index 06790f613..a9feb9b58 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb @@ -53,7 +53,6 @@ end describe 'has_child search' do - let(:search_result) do Question.search(query: { has_child: { type: 'answer', query: { match: { author: 'john' } } } }) end @@ -64,7 +63,6 @@ end describe 'hash_parent search' do - let(:search_result) do Answer.search(query: { has_parent: { parent_type: 'question', query: { match: { author: 'john' } } } }) end @@ -75,7 +73,6 @@ end context 'when a parent is deleted' do - before do Question.where(title: 'First Question').each(&:destroy) Question.__elasticsearch__.refresh_index! diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb index da9d3306a..3837169a9 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb @@ -18,7 +18,6 @@ require 'spec_helper' describe 'Elasticsearch::Model::Adapter::ActiveRecord Serialization' do - before(:all) do ActiveRecord::Schema.define(:version => 1) do create_table ArticleWithCustomSerialization.table_name do |t| @@ -32,14 +31,12 @@ end context 'when the model has a custom serialization defined' do - before do ArticleWithCustomSerialization.create!(title: 'Test', status: 'green') ArticleWithCustomSerialization.__elasticsearch__.refresh_index! end context 'when a document is indexed' do - let(:search_result) do ArticleWithCustomSerialization.__elasticsearch__.client.get( index: 'article_with_custom_serializations', @@ -53,7 +50,6 @@ end context 'when a document is updated' do - before do article.update(title: 'UPDATED', status: 'yellow') ArticleWithCustomSerialization.__elasticsearch__.refresh_index! diff --git a/elasticsearch-model/spec/elasticsearch/model/multimodel_spec.rb b/elasticsearch-model/spec/elasticsearch/model/multimodel_spec.rb index 3652dac1e..484b8c248 100644 --- a/elasticsearch-model/spec/elasticsearch/model/multimodel_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/multimodel_spec.rb @@ -44,9 +44,7 @@ end describe 'the model registry' do - before(:all) do - class JustAModel include Elasticsearch::Model end diff --git a/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb b/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb index f21baad3d..9e229b0ac 100644 --- a/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb @@ -18,7 +18,6 @@ require 'spec_helper' describe Elasticsearch::Model::Proxy do - before(:all) do class ::DummyProxyModel include Elasticsearch::Model::Proxy From 36a002766424722fc26ec40baba9ee2af41c1771 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 14 Sep 2023 09:25:33 +0100 Subject: [PATCH 093/113] Removes more type ocurrances --- .../lib/elasticsearch/model/indexing.rb | 7 +- .../lib/elasticsearch/model/multimodel.rb | 8 --- .../lib/elasticsearch/model/naming.rb | 65 ++----------------- .../adapters/active_record/basic_spec.rb | 38 +---------- .../model/adapters/multiple_spec.rb | 2 - .../spec/elasticsearch/model/indexing_spec.rb | 43 +----------- .../elasticsearch/model/multimodel_spec.rb | 8 +-- .../model/response/aggregations_spec.rb | 1 - .../response/pagination/will_paginate_spec.rb | 1 - .../model/response/records_spec.rb | 1 - .../model/response/results_spec.rb | 1 - 11 files changed, 12 insertions(+), 163 deletions(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/indexing.rb b/elasticsearch-model/lib/elasticsearch/model/indexing.rb index 08763a8f5..b1e07e61a 100644 --- a/elasticsearch-model/lib/elasticsearch/model/indexing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/indexing.rb @@ -51,7 +51,6 @@ def as_json(options={}) class Mappings attr_accessor :options - # @private TYPES_WITH_EMBEDDED_PROPERTIES = %w(object nested) def initialize(options={}) @@ -84,11 +83,7 @@ def indexes(name, options={}, &block) end def to_hash - if @type - { @type.to_sym => @options.merge( properties: @mapping ) } - else - @options.merge( properties: @mapping ) - end + @options.merge( properties: @mapping ) end def as_json(options={}) diff --git a/elasticsearch-model/lib/elasticsearch/model/multimodel.rb b/elasticsearch-model/lib/elasticsearch/model/multimodel.rb index b8c415cad..c7dfaedb1 100644 --- a/elasticsearch-model/lib/elasticsearch/model/multimodel.rb +++ b/elasticsearch-model/lib/elasticsearch/model/multimodel.rb @@ -80,14 +80,6 @@ def index_name models.map { |m| m.index_name } end - # Get an Array of document types used for retrieving documents when doing a search across multiple models - # - # @return [Array] the list of document types used for retrieving documents - # - def document_type - models.map { |m| m.document_type }.compact.presence - end - # Get the client common for all models # # @return Elastic::Transport::Client diff --git a/elasticsearch-model/lib/elasticsearch/model/naming.rb b/elasticsearch-model/lib/elasticsearch/model/naming.rb index c4c796ab2..36f9288b0 100644 --- a/elasticsearch-model/lib/elasticsearch/model/naming.rb +++ b/elasticsearch-model/lib/elasticsearch/model/naming.rb @@ -17,15 +17,10 @@ module Elasticsearch module Model - - # Provides methods for getting and setting index name and document type for the model + # Provides methods for getting and setting index name the model # module Naming - - DEFAULT_DOC_TYPE = '_doc'.freeze - module ClassMethods - # Get or set the name of the index # # @example Set the index name for the `Article` model @@ -64,46 +59,18 @@ def index_name=(name) @index_name = name end - # Get or set the document type - # - # @example Set the document type for the `Article` model - # - # class Article - # document_type "my-article" - # end - # - # @example Directly set the document type for the `Article` model - # - # Article.document_type "my-article" - # - def document_type name=nil - @document_type = name || @document_type || implicit(:document_type) - end - - - # Set the document type - # - # @see document_type - # - def document_type=(name) - @document_type = name - end - private - def implicit(prop) - self.send("default_#{prop}") - end - - def default_index_name - self.model_name.collection.gsub(/\//, '-') - end + def implicit(prop) + self.send("default_#{prop}") + end - def default_document_type; end + def default_index_name + self.model_name.collection.gsub(/\//, '-') + end end module InstanceMethods - # Get or set the index name for the model instance # # @example Set the index name for an instance of the `Article` model @@ -129,25 +96,7 @@ def index_name name=nil, &block def index_name=(name) @index_name = name end - - # @example Set the document type for an instance of the `Article` model - # - # @article.document_type "my-article" - # @article.__elasticsearch__.update_document - # - def document_type name=nil - @document_type = name || @document_type || self.class.document_type - end - - # Set the document type - # - # @see document_type - # - def document_type=(name) - @document_type = name - end end - end end end diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb index 83754cd0b..5cdd13ef1 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb @@ -18,43 +18,7 @@ require 'spec_helper' describe Elasticsearch::Model::Adapter::ActiveRecord do - - context 'when a document_type is not defined for the Model' do - before do - ActiveRecord::Schema.define(:version => 1) do - create_table :article_no_types do |t| - t.string :title - t.string :body - t.integer :clicks, :default => 0 - t.datetime :created_at, :default => 'NOW()' - end - end - - ArticleNoType.delete_all - ArticleNoType.__elasticsearch__.create_index!(force: true) - - ArticleNoType.create!(title: 'Test', body: '', clicks: 1) - ArticleNoType.create!(title: 'Testing Coding', body: '', clicks: 2) - ArticleNoType.create!(title: 'Coding', body: '', clicks: 3) - - ArticleNoType.__elasticsearch__.refresh_index! - end - - describe 'indexing a document' do - - let(:search_result) do - ArticleNoType.search('title:test') - end - - it 'allows searching for documents' do - expect(search_result.results.size).to be(2) - expect(search_result.records.size).to be(2) - end - end - end - - context 'when a document_type is defined for the Model' do - + context 'for the Model' do before(:all) do ActiveRecord::Schema.define(:version => 1) do create_table :articles do |t| diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/multiple_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/multiple_spec.rb index eb5a983b0..f52368b55 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/multiple_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/multiple_spec.rb @@ -18,13 +18,11 @@ require 'spec_helper' describe Elasticsearch::Model::Adapter::Multiple do - before(:all) do class DummyOne include Elasticsearch::Model index_name 'dummy' - document_type 'dummy_one' def self.find(ids) ids.map { |id| new(id) } diff --git a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb index c8df409e5..68fc2c242 100644 --- a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb @@ -94,10 +94,6 @@ class NotFound < Exception; end expect(DummyIndexingModel.mappings).to be_a(Elasticsearch::Model::Indexing::Mappings) end - it 'does not raise an exception when there is no type passed to the #initialize method' do - expect(Elasticsearch::Model::Indexing::Mappings.new) - end - it 'should be convertible to a hash' do expect(Elasticsearch::Model::Indexing::Mappings.new({ foo: 'bar' }).to_hash).to eq(expected_mapping_hash) end @@ -106,44 +102,7 @@ class NotFound < Exception; end expect(Elasticsearch::Model::Indexing::Mappings.new({ foo: 'bar' }).as_json).to eq(expected_mapping_hash) end - context 'when a type is specified' do - let(:mappings) do - Elasticsearch::Model::Indexing::Mappings.new - end - - before do - mappings.indexes :foo, { type: 'boolean', include_in_all: false } - mappings.indexes :bar - end - - it 'creates the correct mapping definition' do - expect(mappings.to_hash[:properties][:foo][:type]).to eq('boolean') - end - - it 'uses text as the default field type' do - expect(mappings.to_hash[:properties][:bar][:type]).to eq('text') - end - - context 'when the \'include_type_name\' option is specified' do - let(:mappings) do - Elasticsearch::Model::Indexing::Mappings.new(include_type_name: true) - end - - before do - mappings.indexes :foo, { type: 'boolean', include_in_all: false } - end - - it 'creates the correct mapping definition' do - expect(mappings.to_hash[:properties][:foo][:type]).to eq('boolean') - end - - it 'sets the \'include_type_name\' option' do - expect(mappings.to_hash[:include_type_name]).to eq(true) - end - end - end - - context 'when a type is not specified' do + context 'basic mappings' do let(:mappings) do Elasticsearch::Model::Indexing::Mappings.new end diff --git a/elasticsearch-model/spec/elasticsearch/model/multimodel_spec.rb b/elasticsearch-model/spec/elasticsearch/model/multimodel_spec.rb index 484b8c248..31d429074 100644 --- a/elasticsearch-model/spec/elasticsearch/model/multimodel_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/multimodel_spec.rb @@ -24,21 +24,17 @@ end let(:model_1) do - double('Foo', index_name: 'foo_index', document_type: 'foo', to_ary: nil) + double('Foo', index_name: 'foo_index', to_ary: nil) end let(:model_2) do - double('Bar', index_name: 'bar_index', document_type: 'bar', to_ary: nil) + double('Bar', index_name: 'bar_index', to_ary: nil) end it 'has an index name' do expect(multimodel.index_name).to eq(['foo_index', 'bar_index']) end - it 'has an document type' do - expect(multimodel.document_type).to eq(['foo', 'bar']) - end - it 'has a client' do expect(multimodel.client).to eq(Elasticsearch::Model.client) end diff --git a/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb index a455140ea..e840d949d 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb @@ -22,7 +22,6 @@ before(:all) do class OriginClass def self.index_name; 'foo'; end - def self.document_type; 'bar'; end end end diff --git a/elasticsearch-model/spec/elasticsearch/model/response/pagination/will_paginate_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/pagination/will_paginate_spec.rb index 25f1f0d1e..0f7303adf 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/pagination/will_paginate_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/pagination/will_paginate_spec.rb @@ -22,7 +22,6 @@ before(:all) do class ModelClass def self.index_name; 'foo'; end - def self.document_type; 'bar'; end def self.per_page 33 diff --git a/elasticsearch-model/spec/elasticsearch/model/response/records_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/records_spec.rb index 2a80dcfc6..a4e5e7072 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/records_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/records_spec.rb @@ -31,7 +31,6 @@ def foo; 'BAR'; end class DummyModel def self.index_name; 'foo'; end - def self.document_type; 'bar'; end def self.find(*args) DummyCollection.new diff --git a/elasticsearch-model/spec/elasticsearch/model/response/results_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/results_spec.rb index f69db2c01..f944e1877 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/results_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/results_spec.rb @@ -22,7 +22,6 @@ before(:all) do class OriginClass def self.index_name; 'foo'; end - def self.document_type; 'bar'; end end end From 15911543900fff42cc16e1c017df9926452f7bd6 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 14 Sep 2023 09:26:06 +0100 Subject: [PATCH 094/113] Code Style changes --- elasticsearch-model/Rakefile | 2 ++ .../spec/elasticsearch/model/importing_spec.rb | 10 +++++----- .../spec/elasticsearch/model/proxy_spec.rb | 7 +++---- .../elasticsearch/model/response/aggregations_spec.rb | 7 ++++--- .../model/searching_search_request_spec.rb | 10 +++++----- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/elasticsearch-model/Rakefile b/elasticsearch-model/Rakefile index bbcf9ad41..9efdda0af 100644 --- a/elasticsearch-model/Rakefile +++ b/elasticsearch-model/Rakefile @@ -56,6 +56,8 @@ namespace :test do puts '-' * 80 end end + + task unit: :all end # ----- Documentation tasks --------------------------------------------------- diff --git a/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb index 438d0c9e9..b905fa4eb 100644 --- a/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/importing_spec.rb @@ -24,7 +24,7 @@ class DummyImportingModel module DummyImportingAdapter module ImportingMixin - def __find_in_batches( options = {}, &block) + def __find_in_batches(options = {}, &block) yield if block_given? end def __transform @@ -125,7 +125,7 @@ def importing_mixin context 'when the method is called with the force option' do before do expect(DummyImportingModel).to receive(:create_index!).with(force: true, index: 'foo').and_return(true) - expect(DummyImportingModel).to receive(:__find_in_batches).with(foo: 'bar').and_return(true) + expect(DummyImportingModel).to receive(:__find_in_batches).with({ foo: 'bar' }).and_return(true) end it 'deletes and creates the index' do @@ -136,7 +136,7 @@ def importing_mixin context 'when the method is called with the refresh option' do before do expect(DummyImportingModel).to receive(:refresh_index!).with(index: 'foo').and_return(true) - expect(DummyImportingModel).to receive(:__find_in_batches).with(foo: 'bar').and_return(true) + expect(DummyImportingModel).to receive(:__find_in_batches).with({ foo: 'bar' }).and_return(true) end it 'refreshes the index' do @@ -147,7 +147,7 @@ def importing_mixin context 'when a different index name is provided' do before do expect(DummyImportingModel).to receive(:client).and_return(client) - expect(client).to receive(:bulk).with(body: nil, index: 'my-new-index').and_return(response) + expect(client).to receive(:bulk).with({ body: nil, index: 'my-new-index' }).and_return(response) end it 'uses the alternate index name' do @@ -203,7 +203,7 @@ def importing_mixin context 'when a pipeline is provided as an options' do before do expect(DummyImportingModel).to receive(:client).and_return(client) - expect(client).to receive(:bulk).with(body: nil, index: 'foo', pipeline: 'my-pipeline').and_return(response) + expect(client).to receive(:bulk).with({ body: nil, index: 'foo', pipeline: 'my-pipeline' }).and_return(response) end it 'uses the pipeline option' do diff --git a/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb b/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb index 9e229b0ac..5465c22a9 100644 --- a/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/proxy_spec.rb @@ -122,10 +122,9 @@ def changes_to_save expect(model).to eq(model_target) expect(duplicate).to eq(duplicate_target) end - end - it 'forwards keyword arguments to target methods' do - expect(DummyProxyModel.new.__elasticsearch__.keyword_method(foo: 'bar')).to eq('bar') + it 'forwards keyword arguments to target methods' do + expect(DummyProxyModel.new.__elasticsearch__.keyword_method(foo: 'bar')).to eq('bar') + end end - end diff --git a/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb b/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb index e840d949d..4bfd89efe 100644 --- a/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/response/aggregations_spec.rb @@ -33,9 +33,10 @@ def self.index_name; 'foo'; end { 'aggregations' => { 'foo' => {'bar' => 10 }, - 'price' => { 'doc_count' => 123, - 'min' => { 'value' => 1.0}, - 'max' => { 'value' => 99 } + 'price' => { + 'doc_count' => 123, + 'min' => { 'value' => 1.0}, + 'max' => { 'value' => 99 } } } } diff --git a/elasticsearch-model/spec/elasticsearch/model/searching_search_request_spec.rb b/elasticsearch-model/spec/elasticsearch/model/searching_search_request_spec.rb index 1a7b4e413..1ab23365a 100644 --- a/elasticsearch-model/spec/elasticsearch/model/searching_search_request_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/searching_search_request_spec.rb @@ -43,7 +43,7 @@ def self.index_name; 'foo'; end context 'when the search definition is a simple query' do before do - expect(client).to receive(:search).with(index: 'foo', q: 'foo').and_return({}) + expect(client).to receive(:search).with({ index: 'foo', q: 'foo' }).and_return({}) end let(:search) do @@ -58,7 +58,7 @@ def self.index_name; 'foo'; end context 'when the search definition is a hash' do before do - expect(client).to receive(:search).with(index: 'foo', body: { foo: 'bar' }).and_return({}) + expect(client).to receive(:search).with({ index: 'foo', body: { foo: 'bar' } }).and_return({}) end let(:search) do @@ -73,7 +73,7 @@ def self.index_name; 'foo'; end context 'when the search definition is a json string' do before do - expect(client).to receive(:search).with(index: 'foo', body: '{"foo":"bar"}').and_return({}) + expect(client).to receive(:search).with({ index: 'foo', body: '{"foo":"bar"}' }).and_return({}) end let(:search) do @@ -98,7 +98,7 @@ def to_hash; {foo: 'bar'}; end end before do - expect(client).to receive(:search).with(index: 'foo', body: {foo: 'bar'}).and_return({}) + expect(client).to receive(:search).with({ index: 'foo', body: {foo: 'bar'} }).and_return({}) end let(:search) do @@ -113,7 +113,7 @@ def to_hash; {foo: 'bar'}; end context 'when extra options are specified' do before do - expect(client).to receive(:search).with(index: 'foo', q: 'foo', size: 15).and_return({}) + expect(client).to receive(:search).with({ index: 'foo', q: 'foo', size: 15 }).and_return({}) end let(:search) do From 136d4f3e44633b0b9eb679b6d2347f5e8fdda2db Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 14 Sep 2023 09:26:55 +0100 Subject: [PATCH 095/113] Addresses client.transport access --- elasticsearch-model/lib/elasticsearch/model/indexing.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch-model/lib/elasticsearch/model/indexing.rb b/elasticsearch-model/lib/elasticsearch/model/indexing.rb index b1e07e61a..0e9c68b30 100644 --- a/elasticsearch-model/lib/elasticsearch/model/indexing.rb +++ b/elasticsearch-model/lib/elasticsearch/model/indexing.rb @@ -281,7 +281,7 @@ def delete_index!(options={}) self.client.indices.delete index: target_index rescue Exception => e if e.class.to_s =~ /NotFound/ && options[:force] - client.transport.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.transport.logger + client.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.logger nil else raise e @@ -308,7 +308,7 @@ def refresh_index!(options={}) self.client.indices.refresh index: target_index rescue Exception => e if e.class.to_s =~ /NotFound/ && options[:force] - client.transport.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.transport.logger + client.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.logger nil else raise e From 4e85fa38eb1ee02af733b109737955f08e2d08ae Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 14 Sep 2023 09:27:07 +0100 Subject: [PATCH 096/113] Updates aggregation interval to calendar_interval --- .../elasticsearch/model/adapters/active_record/basic_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb index 5cdd13ef1..d334685b2 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/basic_spec.rb @@ -301,11 +301,10 @@ end describe 'access to the response via methods' do - let(:search_result) do Article.search(query: { match: { title: { query: 'test' } } }, aggregations: { - dates: { date_histogram: { field: 'created_at', interval: 'hour' } }, + dates: { date_histogram: { field: 'created_at', calendar_interval: 'hour' } }, clicks: { global: {}, aggregations: { min: { min: { field: 'clicks' } } } } }, suggest: { text: 'tezt', title: { term: { field: 'title', suggest_mode: 'always' } } }) From 2468640a64293dea90512713e90a27315240c682 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 14 Sep 2023 09:37:32 +0100 Subject: [PATCH 097/113] Updates MultiModel tests I need to understand if we still need MultiModel or if it was based on the document_type which is no longer a thing in Elasticsearch. --- .../spec/elasticsearch/model/adapters/multiple_spec.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/multiple_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/multiple_spec.rb index f52368b55..86c001db8 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/multiple_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/multiple_spec.rb @@ -40,7 +40,6 @@ class DummyTwo include Elasticsearch::Model index_name 'dummy' - document_type 'dummy_two' def self.find(ids) ids.map { |id| new(id) } @@ -58,7 +57,6 @@ class DummyTwo include Elasticsearch::Model index_name 'other_index' - document_type 'dummy_two' def self.find(ids) ids.map { |id| new(id) } @@ -84,27 +82,22 @@ def initialize(id) [ { _index: 'dummy', - _type: 'dummy_two', _id: '2' }, { _index: 'dummy', - _type: 'dummy_one', _id: '2' }, { _index: 'other_index', - _type: 'dummy_two', _id: '1' }, { _index: 'dummy', - _type: 'dummy_two', _id: '1' }, { _index: 'dummy', - _type: 'dummy_one', _id: '3' } ] @@ -119,13 +112,12 @@ def initialize(id) end describe '#records' do - before do multimodel.class.send :include, Elasticsearch::Model::Adapter::Multiple::Records expect(multimodel).to receive(:response).at_least(:once).and_return(response) end - it 'instantiates the correct types of instances' do + xit 'instantiates the correct types of instances' do expect(multimodel.records[0]).to be_a(Namespace::DummyTwo) expect(multimodel.records[1]).to be_a(DummyOne) expect(multimodel.records[2]).to be_a(DummyTwo) From 3cf23800f24159a0d9416ab5755827b236f40706 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 14 Sep 2023 10:24:51 +0100 Subject: [PATCH 098/113] [CI] Update GitHub Actions: - Adds Ruby 3.0 tests - Removes Ruby 2.6 and 2.7 tests --- .github/workflows/2.7.yml | 46 -------------------------- .github/workflows/{2.6.yml => 3.0.yml} | 20 +++++------ 2 files changed, 10 insertions(+), 56 deletions(-) delete mode 100644 .github/workflows/2.7.yml rename .github/workflows/{2.6.yml => 3.0.yml} (79%) diff --git a/.github/workflows/2.7.yml b/.github/workflows/2.7.yml deleted file mode 100644 index 8bfd9b66f..000000000 --- a/.github/workflows/2.7.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Ruby 2.7 -on: - push: - branches: - - main - pull_request: - branches: - - main - workflow_dispatch: - branches: - - '*' -jobs: - tests: - env: - TEST_ES_SERVER: http://localhost:9200 - RAILS_VERSIONS: '5.0,6.0' - strategy: - fail-fast: false - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Increase system limits - run: | - sudo swapoff -a - sudo sysctl -w vm.swappiness=1 - sudo sysctl -w fs.file-max=262144 - sudo sysctl -w vm.max_map_count=262144 - - uses: elastic/elastic-github-actions/elasticsearch@master - with: - stack-version: 7.x-SNAPSHOT - - uses: ruby/setup-ruby@v1 - with: - ruby-version: 2.7 - - name: Bundle - run: | - sudo apt-get install libsqlite3-dev - gem install bundler - bundle install - bundle exec rake bundle:clean - bundle exec rake bundle:install - - name: Test elasticsearch-rails - run: cd elasticsearch-rails && bundle exec rake test:all - - name: Test elasticsearch-persistence - run: cd elasticsearch-persistence && bundle exec rake test:all - - name: Test elasticsearch-model - run: cd elasticsearch-model && bundle exec rake test:all diff --git a/.github/workflows/2.6.yml b/.github/workflows/3.0.yml similarity index 79% rename from .github/workflows/2.6.yml rename to .github/workflows/3.0.yml index c003a58e5..fb65ce452 100644 --- a/.github/workflows/2.6.yml +++ b/.github/workflows/3.0.yml @@ -1,21 +1,20 @@ -name: Ruby 2.6 +name: Ruby 3.0 on: push: branches: - - main + - 8.x pull_request: branches: - - main - workflow_dispatch: - branches: - - '*' + - 8.x jobs: tests: env: - TEST_ES_SERVER: http://localhost:9200 - RAILS_VERSIONS: '5.0,6.0' + ELASTICSEARCH_URL: http://localhost:9200 + RAILS_VERSIONS: ${{ matrix.rails }} strategy: fail-fast: false + matrix: + rails: [ '6.1', '7.0' ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -27,10 +26,11 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 7.x-SNAPSHOT + stack-version: 8.11.0-SNAPSHOT + security-enabled: false - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.6 + ruby-version: 3.0 - name: Bundle run: | sudo apt-get install libsqlite3-dev From 33aa4bbc2621b5e6e0d34011fa820c73ce893f5c Mon Sep 17 00:00:00 2001 From: Colin MacKenzie IV Date: Fri, 12 Apr 2024 15:47:21 -0400 Subject: [PATCH 099/113] Handle security config for ES8 --- Rakefile | 18 ++++++++++-------- .../spec/elasticsearch/model/indexing_spec.rb | 2 +- elasticsearch-model/spec/spec_helper.rb | 3 ++- elasticsearch-persistence/spec/spec_helper.rb | 3 ++- elasticsearch-rails/spec/spec_helper.rb | 3 ++- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Rakefile b/Rakefile index 4d49a8f34..55c294486 100644 --- a/Rakefile +++ b/Rakefile @@ -38,14 +38,16 @@ def admin_client if test_suite == 'security' transport_options.merge!(:ssl => { verify: false, - ca_path: CERT_DIR }) + ca_path: defined?(CERT_DIR) ? CERT_DIR : nil + }.compact) password = ENV['ELASTIC_PASSWORD'] user = ENV['ELASTIC_USER'] || 'elastic' - url = "https://#{user}:#{password}@#{host}:#{port}" + url = "https://#{user}:#{password}@#{host || 'localhost'}:#{port || 9200}" else url = "http://#{host || 'localhost'}:#{port || 9200}" end + ENV['ELASTICSEARCH_URL'] ||= url Elasticsearch::Client.new(host: url, transport_options: transport_options) end end @@ -140,7 +142,7 @@ namespace :test do end desc "Run all tests in all subprojects" - task all: :wait_for_green do + task all: :wait_for_green_or_yellow do subprojects.each do |project| puts '-'*80 sh "cd #{project} && " + @@ -151,20 +153,20 @@ namespace :test do end end -desc "Wait for elasticsearch cluster to be in green state" -task :wait_for_green do +desc "Wait for elasticsearch cluster to be in green or yellow state" +task :wait_for_green_or_yellow do require 'elasticsearch' ready = nil 5.times do |i| begin - puts "Attempting to wait for green status: #{i + 1}" - if admin_client.cluster.health(wait_for_status: 'green', timeout: '50s') + puts "Attempting to wait for green or yellow status: #{i + 1}" + if admin_client.cluster.health(wait_for_status: 'yellow', timeout: '50s') ready = true break end rescue Elastic::Transport::Transport::Errors::RequestTimeout => ex - puts "Couldn't confirm green status.\n#{ex.inspect}." + puts "Couldn't confirm green or yellow status.\n#{ex.inspect}." rescue Faraday::ConnectionFailed => ex puts "Couldn't connect to Elasticsearch.\n#{ex.inspect}." sleep(30) diff --git a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb index 68fc2c242..b4c0d299d 100644 --- a/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb @@ -591,7 +591,7 @@ class ::DummyIndexingModelForRecreate context 'when the index is not found' do let(:logger) { nil } - let(:client) { Elasticsearch::Client.new(logger: logger) } + let(:client) { Elasticsearch::Client.new(logger: logger, transport_options: { ssl: { verify: false } }) } before do expect(DummyIndexingModelForRecreate).to receive(:client).at_most(3).times.and_return(client) diff --git a/elasticsearch-model/spec/spec_helper.rb b/elasticsearch-model/spec/spec_helper.rb index d3a1e303f..921c1cfa2 100644 --- a/elasticsearch-model/spec/spec_helper.rb +++ b/elasticsearch-model/spec/spec_helper.rb @@ -45,7 +45,8 @@ tracer.formatter = lambda { |s, d, p, m| "#{m.gsub(/^.*$/) { |n| ' ' + n }.ansi(:faint)}\n" } Elasticsearch::Model.client = Elasticsearch::Client.new( host: ELASTICSEARCH_URL, - tracer: (ENV['QUIET'] ? nil : tracer) + tracer: (ENV['QUIET'] ? nil : tracer), + transport_options: { :ssl => { verify: false } } ) puts "Elasticsearch Version: #{Elasticsearch::Model.client.info['version']}" diff --git a/elasticsearch-persistence/spec/spec_helper.rb b/elasticsearch-persistence/spec/spec_helper.rb index e577d3808..bf9ac3e07 100644 --- a/elasticsearch-persistence/spec/spec_helper.rb +++ b/elasticsearch-persistence/spec/spec_helper.rb @@ -36,7 +36,8 @@ # # @since 6.0.0 DEFAULT_CLIENT = Elasticsearch::Client.new(host: ELASTICSEARCH_URL, - tracer: (ENV['QUIET'] ? nil : ::Logger.new(STDERR))) + tracer: (ENV['QUIET'] ? nil : ::Logger.new(STDERR)), + transport_options: { :ssl => { verify: false } }) class MyTestRepository include Elasticsearch::Persistence::Repository diff --git a/elasticsearch-rails/spec/spec_helper.rb b/elasticsearch-rails/spec/spec_helper.rb index e0a299964..ccc28f345 100644 --- a/elasticsearch-rails/spec/spec_helper.rb +++ b/elasticsearch-rails/spec/spec_helper.rb @@ -36,7 +36,8 @@ tracer = ::Logger.new(STDERR) tracer.formatter = lambda { |s, d, p, m| "#{m.gsub(/^.*$/) { |n| ' ' + n }.ansi(:faint)}\n" } Elasticsearch::Model.client = Elasticsearch::Client.new host: ELASTICSEARCH_URL, - tracer: (ENV['QUIET'] ? nil : tracer) + tracer: (ENV['QUIET'] ? nil : tracer), + transport_options: { :ssl => { verify: false } } puts "Elasticsearch Version: #{Elasticsearch::Model.client.info['version']}" unless ActiveRecord::Base.connected? From 4ee1708c906084cc357f9ae906512cd654a3d6dc Mon Sep 17 00:00:00 2001 From: Colin MacKenzie IV Date: Fri, 12 Apr 2024 19:11:44 -0400 Subject: [PATCH 100/113] Test that the model namespace isn't polluted. The goal of ClassMethodsProxy is to avoid polluting the target's namespace, but it was possible to do this by accident when calling `class_eval` before ActiveSupport was completely loaded. This test ensures the namespace isn't polluted, regardless of the load state of ActiveSupport. --- .../elasticsearch/model/adapters/active_record/import_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb index a23e58c37..73be18c59 100644 --- a/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb +++ b/elasticsearch-model/spec/elasticsearch/model/adapters/active_record/import_spec.rb @@ -52,6 +52,10 @@ it 'imports all documents' do expect(ImportArticle.search('*').results.total).to eq(10) end + + it "does not pollute the model's namespace" do + expect(ImportArticle.methods).not_to include(:__transform) + end end context 'when batch size is specified' do From 98c5fa177f6f1913b8ee0cf145784df312469891 Mon Sep 17 00:00:00 2001 From: Colin MacKenzie IV Date: Fri, 12 Apr 2024 19:12:33 -0400 Subject: [PATCH 101/113] Require activesupport/all to more closely mirror a production Rails app. ActiveSupport patches Kernel to add `class_eval` but this behavior wasn't loaded in the test environment. This created a discrepancy between test and prod, causing tests to fail that should have passed and vice versa. Fully loading ActiveSupport makes the test environment more accurate. --- elasticsearch-model/spec/spec_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/elasticsearch-model/spec/spec_helper.rb b/elasticsearch-model/spec/spec_helper.rb index 921c1cfa2..7c4f21a4a 100644 --- a/elasticsearch-model/spec/spec_helper.rb +++ b/elasticsearch-model/spec/spec_helper.rb @@ -31,6 +31,10 @@ require 'yaml' require 'active_record' +# Load all of ActiveSupport to be sure of complete compatibility - +# see https://github.com/elastic/elasticsearch-rails/pull/1075 for details +require 'active_support/all' + unless defined?(ELASTICSEARCH_URL) ELASTICSEARCH_URL = ENV['ELASTICSEARCH_URL'] || "localhost:#{(ENV['TEST_CLUSTER_PORT'] || 9200)}" end From e40cb7b2af89d47d0464045bb9af579155863bcb Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 15 Apr 2024 15:25:46 +0100 Subject: [PATCH 102/113] Updates Ruby, Rails, Stack versions for tests --- .github/workflows/3.0.yml | 6 ++-- elasticsearch-model/gemfiles/7.1.gemfile | 36 +++++++++++++++++++ .../lib/elasticsearch/model/multimodel.rb | 1 - .../lib/elasticsearch/model/naming.rb | 2 +- 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 elasticsearch-model/gemfiles/7.1.gemfile diff --git a/.github/workflows/3.0.yml b/.github/workflows/3.0.yml index fb65ce452..556caeaef 100644 --- a/.github/workflows/3.0.yml +++ b/.github/workflows/3.0.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - rails: [ '6.1', '7.0' ] + rails: [ '6.1', '7.0', '7.1' ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -26,11 +26,11 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 8.11.0-SNAPSHOT + stack-version: 8.13-SNAPSHOT security-enabled: false - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.0 + ruby-version: 3.3 - name: Bundle run: | sudo apt-get install libsqlite3-dev diff --git a/elasticsearch-model/gemfiles/7.1.gemfile b/elasticsearch-model/gemfiles/7.1.gemfile new file mode 100644 index 000000000..bd1d30838 --- /dev/null +++ b/elasticsearch-model/gemfiles/7.1.gemfile @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Usage: +# +# $ BUNDLE_GEMFILE=./gemfiles/7.0.gemfile bundle install +# $ BUNDLE_GEMFILE=./gemfiles/7.0.gemfile bundle exec rake test:integration + +source 'https://rubygems.org' + +gemspec path: '../' + +gem 'activemodel', '~> 7.1' +gem 'activerecord', '~> 7.1' +gem 'sqlite3' unless defined?(JRUBY_VERSION) +# gem 'mongoid', '~> 6' + +group :development, :testing do + gem 'debug' + gem 'pry-nav' + gem 'rspec' +end diff --git a/elasticsearch-model/lib/elasticsearch/model/multimodel.rb b/elasticsearch-model/lib/elasticsearch/model/multimodel.rb index c7dfaedb1..c519ea968 100644 --- a/elasticsearch-model/lib/elasticsearch/model/multimodel.rb +++ b/elasticsearch-model/lib/elasticsearch/model/multimodel.rb @@ -17,7 +17,6 @@ module Elasticsearch module Model - # Keeps a global registry of classes that include `Elasticsearch::Model` # class Registry diff --git a/elasticsearch-model/lib/elasticsearch/model/naming.rb b/elasticsearch-model/lib/elasticsearch/model/naming.rb index 36f9288b0..643f3559b 100644 --- a/elasticsearch-model/lib/elasticsearch/model/naming.rb +++ b/elasticsearch-model/lib/elasticsearch/model/naming.rb @@ -17,7 +17,7 @@ module Elasticsearch module Model - # Provides methods for getting and setting index name the model + # Provides methods for getting and setting index and name for the model # module Naming module ClassMethods From 77ebcef17159b5efb230e7d8a1f145bfc8546562 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 15 Apr 2024 15:38:32 +0100 Subject: [PATCH 103/113] [CI] Updates GitHub Actions --- .github/workflows/{3.0.yml => tests.yml} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename .github/workflows/{3.0.yml => tests.yml} (89%) diff --git a/.github/workflows/3.0.yml b/.github/workflows/tests.yml similarity index 89% rename from .github/workflows/3.0.yml rename to .github/workflows/tests.yml index 556caeaef..2cc6457ad 100644 --- a/.github/workflows/3.0.yml +++ b/.github/workflows/tests.yml @@ -15,9 +15,10 @@ jobs: fail-fast: false matrix: rails: [ '6.1', '7.0', '7.1' ] + ruby: ['3.1', '3.2', '3.3'] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Increase system limits run: | sudo swapoff -a @@ -26,11 +27,11 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 8.13-SNAPSHOT + stack-version: 8.14.0-SNAPSHOT security-enabled: false - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.3 + ruby-version: ${{ matrix.ruby }} - name: Bundle run: | sudo apt-get install libsqlite3-dev From f9631b8856aa67db8e52009098840c5c50dc3b85 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 15 Apr 2024 15:57:54 +0100 Subject: [PATCH 104/113] [DOCS] Updates README --- README.md | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 26ee3860e..fd639b862 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,7 @@ # Elasticsearch Rails -[![Ruby 2.7](https://github.com/elastic/elasticsearch-rails/workflows/Ruby%202.7/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) -[![Ruby 2.6](https://github.com/elastic/elasticsearch-rails/workflows/Ruby%202.6/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) -[![Ruby 2.5](https://github.com/elastic/elasticsearch-rails/workflows/Ruby%202.5/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) -[![Ruby 2.4](https://github.com/elastic/elasticsearch-rails/workflows/Ruby%202.4/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) -[![JRuby](https://github.com/elastic/elasticsearch-rails/workflows/JRuby/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions) -[![Code Climate](https://codeclimate.com/github/elastic/elasticsearch-rails/badges/gpa.svg)](https://codeclimate.com/github/elastic/elasticsearch-rails) +[![Ruby tests](https://github.com/elastic/elasticsearch-rails/actions/workflows/tests.yml/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions/workflows/tests.yml) +[![JRuby tests](https://github.com/elastic/elasticsearch-rails/actions/workflows/jruby.yml/badge.svg)](https://github.com/elastic/elasticsearch-rails/actions/workflows/jruby.yml) This repository contains various Ruby and Rails integrations for [Elasticsearch](http://elasticsearch.org): @@ -29,20 +25,13 @@ Install each library from [Rubygems](https://rubygems.org/gems/elasticsearch): gem install elasticsearch-model gem install elasticsearch-rails -To use an unreleased version, add it to your `Gemfile` for [Bundler](http://bundler.io): - -```ruby -gem 'elasticsearch-model', github: 'elastic/elasticsearch-rails', branch: '5.x' -gem 'elasticsearch-rails', github: 'elastic/elasticsearch-rails', branch: '5.x' -``` - ## Compatibility -The libraries are compatible with Ruby 2.4 and higher. +The libraries are compatible with Ruby 3.0 and higher. We follow Ruby’s own maintenance policy and officially support all currently maintained versions per [Ruby Maintenance Branches](https://www.ruby-lang.org/en/downloads/branches/). -The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `7.x` of the Elasticsearch stack. **We haven't tested and updated the code for Elasticsearch `8.0` yet**. +The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `8.x` of the Elasticsearch stack. | Rubygem | | Elasticsearch | |:-------------:|:-:| :-----------: | @@ -50,7 +39,9 @@ The version numbers follow the Elasticsearch major versions. Currently the `main | 2.x | → | 2.x | | 5.x | → | 5.x | | 6.x | → | 6.x | -| main | → | 7.x | +| 7.x | → | 7.x | +| 8.x | → | 8.x | +| main | → | 8.x | Check out [Elastic product end of life dates](https://www.elastic.co/support/eol) to learn which releases are still actively supported and tested. From 0aedb0da202aaf4619f8e3aa3d9c3fbb91290f8e Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Mon, 15 Apr 2024 15:55:25 +0100 Subject: [PATCH 105/113] [CI] Updates GitHub Actions for JRuby, names --- .github/workflows/jruby.yml | 20 ++++++++++++-------- .github/workflows/tests.yml | 2 +- Gemfile | 2 +- elasticsearch-model/Gemfile | 2 +- elasticsearch-persistence/Gemfile | 2 +- elasticsearch-rails/Gemfile | 6 ++++-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/jruby.yml b/.github/workflows/jruby.yml index 7a3ec1be7..5ac8c162d 100644 --- a/.github/workflows/jruby.yml +++ b/.github/workflows/jruby.yml @@ -1,11 +1,11 @@ -name: JRuby +name: JRuby tests on: push: branches: - - main + - 8.x pull_request: branches: - - main + - 8.x workflow_dispatch: branches: - '*' @@ -13,12 +13,15 @@ jobs: tests: env: TEST_ES_SERVER: http://localhost:9200 - RAILS_VERSIONS: '5.0,6.0' + RAILS_VERSIONS: ${{ matrix.rails }} strategy: fail-fast: false + matrix: + rails: [ '6.1', '7.0', '7.1' ] + ruby: ['jruby-9.4'] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Increase system limits run: | sudo swapoff -a @@ -27,13 +30,14 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 7.x-SNAPSHOT + stack-version: 8.14.0-SNAPSHOT + security-enabled: false - uses: ruby/setup-ruby@v1 with: - ruby-version: jruby-9.3 + ruby-version: ${{ matrix.ruby }} - name: Bundle run: | - sudo apt-get install libsqlite3-dev + sudo apt-get install libsqlite3-dev libcurl4-openssl-dev gem install bundler bundle install bundle exec rake bundle:clean diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2cc6457ad..ff76e3925 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: Ruby 3.0 +name: Ruby tests on: push: branches: diff --git a/Gemfile b/Gemfile index b04ce3e9e..ddb9b7bbd 100644 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,7 @@ gem 'pry' gem 'rake', '~> 12' group :development do - gem 'debug' + gem 'debug' unless defined?(JRUBY_VERSION) gem 'rspec' gem 'yard' end diff --git a/elasticsearch-model/Gemfile b/elasticsearch-model/Gemfile index 72fae31be..58f5b6b92 100644 --- a/elasticsearch-model/Gemfile +++ b/elasticsearch-model/Gemfile @@ -21,7 +21,7 @@ source 'https://rubygems.org' gemspec group :development, :testing do - gem 'debug' + gem 'debug' unless defined?(JRUBY_VERSION) gem 'pry-nav' gem 'rspec' end diff --git a/elasticsearch-persistence/Gemfile b/elasticsearch-persistence/Gemfile index 2afccf280..4e228558e 100644 --- a/elasticsearch-persistence/Gemfile +++ b/elasticsearch-persistence/Gemfile @@ -25,7 +25,7 @@ gem 'elasticsearch-model', require: false group :development, :testing do - gem 'debug' + gem 'debug' unless defined?(JRUBY_VERSION) gem 'pry-nav' gem 'rspec' end diff --git a/elasticsearch-rails/Gemfile b/elasticsearch-rails/Gemfile index 2f333c4b5..f51541c74 100644 --- a/elasticsearch-rails/Gemfile +++ b/elasticsearch-rails/Gemfile @@ -29,8 +29,10 @@ gem 'elasticsearch-persistence', require: false group :development, :testing do - gem 'debug' gem 'pry-nav' gem 'rspec' - gem 'sqlite3' unless defined?(JRUBY_VERSION) + unless defined?(JRUBY_VERSION) + gem 'sqlite3' + gem 'debug' + end end From 18fa01d1f2110c00278ac3dd4bf52f34fe4c59ea Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 16 Apr 2024 12:46:41 +0100 Subject: [PATCH 106/113] [CI] Updates GitHub Actions --- .github/workflows/jruby.yml | 4 ++-- .github/workflows/tests.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/jruby.yml b/.github/workflows/jruby.yml index 5ac8c162d..f61c93932 100644 --- a/.github/workflows/jruby.yml +++ b/.github/workflows/jruby.yml @@ -2,10 +2,10 @@ name: JRuby tests on: push: branches: - - 8.x + - main pull_request: branches: - - 8.x + - main workflow_dispatch: branches: - '*' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ff76e3925..30474143c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,10 +2,10 @@ name: Ruby tests on: push: branches: - - 8.x + - main pull_request: branches: - - 8.x + - main jobs: tests: env: From 54117829a0887cbe7da35dcbf664fc1c0bf824b0 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Wed, 17 Apr 2024 09:47:17 +0100 Subject: [PATCH 107/113] [DOCS] Updates READMEs --- README.md | 6 +-- elasticsearch-model/README.md | 4 +- elasticsearch-persistence/README.md | 75 +++++++++-------------------- elasticsearch-rails/README.md | 25 +++++----- 4 files changed, 41 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index fd639b862..0e27afb21 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ repository = Elasticsearch::Persistence::Repository.new repository.save Article.new(title: 'Test') # POST http://localhost:9200/repository/article -# => {"_index"=>"repository", "_type"=>"article", "_id"=>"Ak75E0U9Q96T5Y999_39NA", ...} +# => {"_index"=>"repository", "_id"=>"Ak75E0U9Q96T5Y999_39NA", ...} ``` **Please refer to each library documentation for detailed information and examples.** @@ -164,9 +164,9 @@ This software is licensed under the Apache 2 license, quoted below. the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/elasticsearch-model/README.md b/elasticsearch-model/README.md index 12add7e01..4103ffa8b 100644 --- a/elasticsearch-model/README.md +++ b/elasticsearch-model/README.md @@ -8,7 +8,7 @@ It aims to simplify integration of Ruby classes ("models"), commonly found e.g. This library is compatible with Ruby 3 and higher. -The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `7.x` of the Elasticsearch stack. **We haven't tested and updated the code for Elasticsearch `8.0` yet**. +The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `8.x` of the Elasticsearch stack. | Rubygem | | Elasticsearch | |:-------:|:-:|:-------------:| @@ -141,7 +141,7 @@ Elasticsearch::Model.client = Elasticsearch::Client.new log: true You might want to do this during your application bootstrap process, e.g. in a Rails initializer. Please refer to the -[`elasticsearch-transport`](https://github.com/elastic/elasticsearch-ruby/tree/main/elasticsearch-transport) +[`elastic-transport`](https://github.com/elastic/elastic-transport-ruby/) library documentation for all the configuration options, and to the [`elasticsearch-api`](http://rubydoc.info/gems/elasticsearch-api) library documentation for information about the Ruby client API. diff --git a/elasticsearch-persistence/README.md b/elasticsearch-persistence/README.md index a9b1b39ec..47747b6ff 100644 --- a/elasticsearch-persistence/README.md +++ b/elasticsearch-persistence/README.md @@ -4,18 +4,19 @@ Persistence layer for Ruby domain objects in Elasticsearch, using the Repository ## Compatibility -This library is compatible with Ruby 2.4 and higher. +This library is compatible with Ruby 3.1 and higher. -The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `7.x` of the Elasticsearch stack. **We haven't tested and updated the code for Elasticsearch `8.0` yet**. +The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `8.x` of the Elasticsearch stack. -| Rubygem | | Elasticsearch | -|:-------------:|:-:| :-----------: | -| 0.1 | → | 1.x | -| 2.x | → | 2.x | -| 5.x | → | 5.x | -| 6.x | → | 6.x | -| 7.x | → | 7.x | -| main | → | 7.x | +| Rubygem | | Elasticsearch | +|:-------:|:-:|:-------------:| +| 0.1 | → | 1.x | +| 2.x | → | 2.x | +| 5.x | → | 5.x | +| 6.x | → | 6.x | +| 7.x | → | 7.x | +| 8.x | → | 8.x | +| main | → | 8.x | ## Installation @@ -78,7 +79,7 @@ note = Note.new id: 1, text: 'Test' repository.save(note) # PUT http://localhost:9200/repository/_doc/1 [status:201, request:0.210s, query:n/a] # > {"id":1,"text":"Test"} -# < {"_index":"repository","_type":"note","_id":"1","_version":1,"created":true} +# < {"_index":"repository","_id":"1","_version":1,"created":true} ``` ...find it... @@ -86,7 +87,7 @@ repository.save(note) ```ruby n = repository.find(1) # GET http://localhost:9200/repository/_doc/1 [status:200, request:0.003s, query:n/a] -# < {"_index":"repository","_type":"note","_id":"1","_version":2,"found":true, "_source" : {"id":1,"text":"Test"}} +# < {"_index":"repository","_id":"1","_version":2,"found":true, "_source" : {"id":1,"text":"Test"}} => 1, "text"=>"Test"}> ``` @@ -105,14 +106,14 @@ repository.search(query: { match: { text: 'test' } }).first ```ruby repository.delete(note) # DELETE http://localhost:9200/repository/_doc/1 [status:200, request:0.014s, query:n/a] -# < {"found":true,"_index":"repository","_type":"note","_id":"1","_version":3} -=> {"found"=>true, "_index"=>"repository", "_type"=>"note", "_id"=>"1", "_version"=>2} +# < {"found":true,"_index":"repository","_id":"1","_version":3} +=> {"found"=>true, "_index"=>"repository", "_id"=>"1", "_version"=>2} ``` The repository module provides a number of features and facilities to configure and customize the behavior: * Configuring the Elasticsearch [client](https://github.com/elastic/elasticsearch-ruby#usage) being used -* Setting the index name, document type, and object class for deserialization +* Setting the index name, and object class for deserialization * Composing mappings and settings for the index * Creating, deleting or refreshing the index * Finding or searching for documents @@ -145,7 +146,7 @@ class MyRepository end client = Elasticsearch::Client.new(url: ENV['ELASTICSEARCH_URL'], log: true) -repository = MyRepository.new(client: client, index_name: :my_notes, type: :note, klass: Note) +repository = MyRepository.new(client: client, index_name: :my_notes, klass: Note) repository.settings number_of_shards: 1 do mapping do indexes :text, analyzer: 'snowball' @@ -153,8 +154,7 @@ repository.settings number_of_shards: 1 do end ``` -The custom Elasticsearch client will be used now, with a custom index and type names, -as well as the custom serialization and de-serialization logic. +The custom Elasticsearch client will be used now, with a custom index, as well as the custom serialization and de-serialization logic. We can create the index with the desired settings and mappings: @@ -170,7 +170,7 @@ Save the document with extra properties added by the `serialize` method: repository.save(note) # PUT http://localhost:9200/my_notes/note/1 # > {"id":1,"text":"Test","my_special_key":"my_special_stuff"} -{"_index"=>"my_notes", "_type"=>"my_note", "_id"=>"1", "_version"=>4, ... } +{"_index"=>"my_notes", "_id"=>"1", "_version"=>4, ... } ``` And `deserialize` it: @@ -194,7 +194,6 @@ class NoteRepository include Elasticsearch::Persistence::Repository::DSL index_name 'notes' - document_type 'note' klass Note settings number_of_shards: 1 do @@ -318,36 +317,8 @@ repository.index_name ``` -The `document_type` method specifies the Elasticsearch document type to use for storage, lookup and search. The default value is -'_doc'. Keep in mind that future versions of Elasticsearch will not allow you to set this yourself and will use the type, -'_doc'. - -```ruby -repository = NoteRepository.new(document_type: 'note') -repository.document_type -# => 'note' - -``` - -or with the DSL mixin: - -```ruby -class NoteRepository - include Elasticsearch::Persistence::Repository - include Elasticsearch::Persistence::Repository::DSL - - document_type 'note' -end - -repository = NoteRepository.new -repository.document_type -# => 'note' - -``` - The `klass` method specifies the Ruby class name to use when initializing objects from -documents retrieved from the repository. If this value is not set, a Hash representation of the document will be -returned instead. +documents retrieved from the repository. If this value is not set, a Hash representation of the document will be returned instead. ```ruby repository = NoteRepository.new(klass: Note) @@ -452,7 +423,7 @@ The `save` method allows you to store a domain object in the repository: ```ruby note = Note.new id: 1, title: 'Quick Brown Fox' repository.save(note) -# => {"_index"=>"notes_development", "_type"=>"_doc", "_id"=>"1", "_version"=>1, "created"=>true} +# => {"_index"=>"notes_development", "_id"=>"1", "_version"=>1, "created"=>true} ``` The `update` method allows you to perform a partial update of a document in the repository. @@ -460,14 +431,14 @@ Use either a partial document: ```ruby repository.update id: 1, title: 'UPDATED', tags: [] -# => {"_index"=>"notes_development", "_type"=>"_doc", "_id"=>"1", "_version"=>2} +# => {"_index"=>"notes_development", "_id"=>"1", "_version"=>2} ``` Or a script (optionally with parameters): ```ruby repository.update 1, script: 'if (!ctx._source.tags.contains(t)) { ctx._source.tags += t }', params: { t: 'foo' } -# => {"_index"=>"notes_development", "_type"=>"_doc", "_id"=>"1", "_version"=>3} +# => {"_index"=>"notes_development", "_id"=>"1", "_version"=>3} ``` diff --git a/elasticsearch-rails/README.md b/elasticsearch-rails/README.md index 12e7d7d59..4ec8ac2f8 100644 --- a/elasticsearch-rails/README.md +++ b/elasticsearch-rails/README.md @@ -6,18 +6,19 @@ library, providing features suitable for Ruby on Rails applications. ## Compatibility -This library is compatible with Ruby 1.9.3 and higher. +This library is compatible with Ruby 3.1 and higher. -The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `7.x` of the Elasticsearch stack. **We haven't tested and updated the code for Elasticsearch `8.0` yet**. +The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `8.x` of the Elasticsearch stack. -| Rubygem | | Elasticsearch | -|:-------------:|:-:| :-----------: | -| 0.1 | → | 1.x | -| 2.x | → | 2.x | -| 5.x | → | 5.x | -| 6.x | → | 6.x | -| 7.x | → | 7.x | -| main | → | 7.x | +| Rubygem | | Elasticsearch | +|:-------:|:-:|:-------------:| +| 0.1 | → | 1.x | +| 2.x | → | 2.x | +| 5.x | → | 5.x | +| 6.x | → | 6.x | +| 7.x | → | 7.x | +| 8.x | → | 8.x | +| main | → | 8.x | ## Installation @@ -137,9 +138,9 @@ This software is licensed under the Apache 2 license, quoted below. the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY From 98b6ce022f03e3fe5f899e5dda6a378c897759ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciek=20Dubi=C5=84ski?= Date: Wed, 27 Dec 2023 16:53:40 +0100 Subject: [PATCH 108/113] Address Rails 7.1 deprecation warning in elasticsearch-rails This PR switches the elasticsearch-rails gem to use a new signature of the ActiveSupport::LogSubscriber#color method when called in an app using Rails 7.1+. With older Rails, the gem uses the working, old signature. --- .../rails/instrumentation/log_subscriber.rb | 13 ++++- .../instrumentation/log_subscriber_spec.rb | 57 +++++++++++++++++++ elasticsearch-rails/spec/spec_helper.rb | 1 + 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb diff --git a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb index c388961c0..a9f112f5d 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/instrumentation/log_subscriber.rb @@ -46,8 +46,19 @@ def search(event) payload = event.payload name = "#{payload[:klass]} #{payload[:name]} (#{event.duration.round(1)}ms)" search = payload[:search].inspect.gsub(/:(\w+)=>/, '\1: ') + debug %Q| #{color(name, GREEN, color_option(true))} #{colorize_logging ? "\e[2m#{search}\e[0m" : search}| + end + + private + + def color_option(bold_value) + new_color_syntax? ? { bold: bold_value } : bold_value + end + + def new_color_syntax? + return @new_color_syntax if defined?(@new_color_syntax) - debug %Q| #{color(name, GREEN, true)} #{colorize_logging ? "\e[2m#{search}\e[0m" : search}| + @new_color_syntax = ::Rails.respond_to?(:gem_version) && ::Rails.gem_version >= '7.1' end end diff --git a/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb b/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb new file mode 100644 index 000000000..7512f006a --- /dev/null +++ b/elasticsearch-rails/spec/instrumentation/log_subscriber_spec.rb @@ -0,0 +1,57 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +require 'spec_helper' +require 'elasticsearch/rails/instrumentation/log_subscriber' + +describe Elasticsearch::Rails::Instrumentation::LogSubscriber do + subject(:instance) { described_class.new } + + let(:logger) { instance_double(Logger) } + + before do + allow(instance).to receive(:logger) { logger } + end + + describe "#search" do + subject { instance.search(event) } + + let(:event) { double("search.elasticsearch", duration: 1.2345, payload: { name: "execute", search: { query: { match_all: {}}}}) } + + it "logs the event" do + expect(instance).to receive(:color).with(" execute (1.2ms)", described_class::GREEN, { bold: true }).and_call_original + expect(logger).to receive(:debug?) { true } + expect(logger).to receive(:debug).with(" \e[1m\e[32m execute (1.2ms)\e[0m \e[2m{query: {match_all: {}}}\e[0m") + subject + end + + context "when Rails version is older" do + let(:rails_version) { "7.0.0" } + + before do + allow(::Rails).to receive(:gem_version) { Gem::Version.new(rails_version) } + end + + it "logs the event" do + expect(instance).to receive(:color).with(" execute (1.2ms)", described_class::GREEN, true).and_call_original + expect(logger).to receive(:debug?) { true } + expect(logger).to receive(:debug).with(" \e[1m\e[32m execute (1.2ms)\e[0m \e[2m{query: {match_all: {}}}\e[0m") + subject + end + end + end +end diff --git a/elasticsearch-rails/spec/spec_helper.rb b/elasticsearch-rails/spec/spec_helper.rb index ccc28f345..3a9eb8e6c 100644 --- a/elasticsearch-rails/spec/spec_helper.rb +++ b/elasticsearch-rails/spec/spec_helper.rb @@ -20,6 +20,7 @@ require 'elasticsearch/model' require 'elasticsearch/rails' require 'rails/railtie' +require 'rails/version' require 'elasticsearch/rails/instrumentation' From bd546fa8d93a6b2adc6f9a5dbc568eedba2c9ccb Mon Sep 17 00:00:00 2001 From: Martin Streicher Date: Mon, 4 Mar 2024 11:06:38 -0500 Subject: [PATCH 109/113] Ensure subclasses are added to the registry --- elasticsearch-model/lib/elasticsearch/model.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/elasticsearch-model/lib/elasticsearch/model.rb b/elasticsearch-model/lib/elasticsearch/model.rb index 5b28726cb..6cc595050 100644 --- a/elasticsearch-model/lib/elasticsearch/model.rb +++ b/elasticsearch-model/lib/elasticsearch/model.rb @@ -112,6 +112,11 @@ class << self METHODS.each do |method| delegate method, to: :__elasticsearch__ unless self.public_instance_methods.include?(method) end + + def inherited(subclass) + super + Registry.add(subclass) if subclass.is_a?(Class) + end end end From 9a49625382bce0ac792c2c783099156446bd5ff6 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 30 May 2024 15:36:33 +0100 Subject: [PATCH 110/113] Dependency management --- elasticsearch-model/elasticsearch-model.gemspec | 2 +- elasticsearch-model/gemfiles/6.1.gemfile | 2 +- elasticsearch-model/gemfiles/7.0.gemfile | 2 +- elasticsearch-model/gemfiles/7.1.gemfile | 2 +- elasticsearch-rails/Gemfile | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/elasticsearch-model/elasticsearch-model.gemspec b/elasticsearch-model/elasticsearch-model.gemspec index c00b5c87a..57f95b6ae 100644 --- a/elasticsearch-model/elasticsearch-model.gemspec +++ b/elasticsearch-model/elasticsearch-model.gemspec @@ -63,6 +63,6 @@ Gem::Specification.new do |s| unless defined?(JRUBY_VERSION) s.add_development_dependency 'oj' s.add_development_dependency 'ruby-prof' - s.add_development_dependency 'sqlite3' + s.add_development_dependency 'sqlite3', '~> 1.4' end end diff --git a/elasticsearch-model/gemfiles/6.1.gemfile b/elasticsearch-model/gemfiles/6.1.gemfile index 2260df5cd..79a13d5c4 100644 --- a/elasticsearch-model/gemfiles/6.1.gemfile +++ b/elasticsearch-model/gemfiles/6.1.gemfile @@ -26,7 +26,7 @@ gemspec path: '../' gem 'activemodel', '6.1' gem 'activerecord', '6.1' -gem 'sqlite3' unless defined?(JRUBY_VERSION) +gem 'sqlite3', '~> 1.4' unless defined?(JRUBY_VERSION) # gem 'mongoid', '~> 6' group :development, :testing do diff --git a/elasticsearch-model/gemfiles/7.0.gemfile b/elasticsearch-model/gemfiles/7.0.gemfile index 97f1366c1..f1b5e3ba0 100644 --- a/elasticsearch-model/gemfiles/7.0.gemfile +++ b/elasticsearch-model/gemfiles/7.0.gemfile @@ -26,7 +26,7 @@ gemspec path: '../' gem 'activemodel', '~> 7' gem 'activerecord', '~> 7' -gem 'sqlite3' unless defined?(JRUBY_VERSION) +gem 'sqlite3', '~> 1.4' unless defined?(JRUBY_VERSION) # gem 'mongoid', '~> 6' group :development, :testing do diff --git a/elasticsearch-model/gemfiles/7.1.gemfile b/elasticsearch-model/gemfiles/7.1.gemfile index bd1d30838..6a8e59da9 100644 --- a/elasticsearch-model/gemfiles/7.1.gemfile +++ b/elasticsearch-model/gemfiles/7.1.gemfile @@ -26,7 +26,7 @@ gemspec path: '../' gem 'activemodel', '~> 7.1' gem 'activerecord', '~> 7.1' -gem 'sqlite3' unless defined?(JRUBY_VERSION) +gem 'sqlite3', '~> 1.4' unless defined?(JRUBY_VERSION) # gem 'mongoid', '~> 6' group :development, :testing do diff --git a/elasticsearch-rails/Gemfile b/elasticsearch-rails/Gemfile index f51541c74..4be2dd014 100644 --- a/elasticsearch-rails/Gemfile +++ b/elasticsearch-rails/Gemfile @@ -32,7 +32,7 @@ group :development, :testing do gem 'pry-nav' gem 'rspec' unless defined?(JRUBY_VERSION) - gem 'sqlite3' + gem 'sqlite3', '~> 1.4' gem 'debug' end end From 6d1eeeb0232f41372286ff99579755314b3ee8e0 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 30 May 2024 15:36:50 +0100 Subject: [PATCH 111/113] [CI] Tests with latest snapshot stack version --- .github/workflows/jruby.yml | 2 +- .github/workflows/tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jruby.yml b/.github/workflows/jruby.yml index f61c93932..91dc5ff48 100644 --- a/.github/workflows/jruby.yml +++ b/.github/workflows/jruby.yml @@ -30,7 +30,7 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 8.14.0-SNAPSHOT + stack-version: 8.15.0-SNAPSHOT security-enabled: false - uses: ruby/setup-ruby@v1 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 30474143c..e2ae0ca8b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,7 +27,7 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 8.14.0-SNAPSHOT + stack-version: 8.15.0-SNAPSHOT security-enabled: false - uses: ruby/setup-ruby@v1 with: From 92c8d16f14f2a931c0daa7339aabc23762dffd44 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 30 May 2024 15:04:35 +0100 Subject: [PATCH 112/113] [DOCS] Updates CHANGELOG for 8.0.0 --- CHANGELOG.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3405dea7..ce1eed141 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,25 @@ +## 8.0.0 + +First general availability release for `8.0.0`. Major versions of `8.x` will support Elasticsearch version `8.x` changing the `elasticsearch` dependency's major version: `gem 'elasticsearch', '~> 8'`. +All references to `type` should have been removed. Document types were deprecated and do not exist in `8.x`. + +The dependency from `elasticsearch` on `elasticsearch-transport` was updated to `elastic-transport`. All `8.x` Elasticsearch APIs supported by `elasticsearch` should now be supported on the Rails library. See [Release notes for the Elasticsearch client 8.0](https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/release_notes_80.html) and the [8.x release notes](https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/release_notes.html#_8_x) for more information. + +### Compatibility + +The gem is currently testing with Ruby 3.1, 3.2 and 3.3 and JRuby 9.4. Testing for Ruby `2.x` versions has been dropped as they're no longer updated or supported. Currently testing with Rails 6.1, 7.0 and 7.1. + +### Changes since 8.0.0.pre + +- Address Rails 7.1 deprecation warning in elasticsearch-rails [PR](https://github.com/elastic/elasticsearch-rails/pull/1067) +- Ensure subclasses are added to the registry [PR](https://github.com/elastic/elasticsearch-rails/pull/1073) + +### Development changes + +- Using `debug` for debugging in `development` and `testing` Gemfile groups. +- Minor general code cleanups and styling changes. +- Updated code for `elasticsearch` 8.x. + ## 7.2.1 * The default git branch `master` has been renamed to `main` From 0b92c86ce24222d7422aeb2a67a8f13dfd358681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20J=C3=B6rg?= Date: Tue, 18 Jun 2024 22:37:05 +0200 Subject: [PATCH 113/113] Update import.rb Fixes issue #1082 --- elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb b/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb index b43d67163..dcdc82d89 100644 --- a/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb +++ b/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb @@ -80,7 +80,6 @@ total_errors = klass.__elasticsearch__.import force: ENV.fetch('FORCE', false), batch_size: ENV.fetch('BATCH', 1000).to_i, index: ENV.fetch('INDEX', nil), - type: ENV.fetch('TYPE', nil), scope: ENV.fetch('SCOPE', nil) do |response| pbar.inc response['items'].size if pbar STDERR.flush