elasticsearch-model 7.2.1 → 8.0.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Gemfile +1 -0
 - data/README.md +19 -19
 - data/Rakefile +7 -6
 - data/elasticsearch-model.gemspec +4 -4
 - data/examples/activerecord_associations.rb +1 -1
 - data/examples/activerecord_custom_analyzer.rb +2 -2
 - data/gemfiles/{6.0.gemfile → 6.1.gemfile} +5 -5
 - data/gemfiles/{5.0.gemfile → 7.0.gemfile} +7 -6
 - data/gemfiles/{3.0.gemfile → 7.1.gemfile} +9 -8
 - data/lib/elasticsearch/model/adapter.rb +0 -2
 - data/lib/elasticsearch/model/adapters/active_record.rb +0 -4
 - data/lib/elasticsearch/model/adapters/default.rb +0 -4
 - data/lib/elasticsearch/model/adapters/mongoid.rb +9 -11
 - data/lib/elasticsearch/model/adapters/multiple.rb +0 -1
 - data/lib/elasticsearch/model/importing.rb +1 -12
 - data/lib/elasticsearch/model/indexing.rb +6 -19
 - data/lib/elasticsearch/model/multimodel.rb +1 -10
 - data/lib/elasticsearch/model/naming.rb +7 -58
 - data/lib/elasticsearch/model/proxy.rb +1 -5
 - data/lib/elasticsearch/model/response/result.rb +0 -6
 - data/lib/elasticsearch/model/searching.rb +2 -3
 - data/lib/elasticsearch/model/version.rb +1 -1
 - data/lib/elasticsearch/model.rb +1 -3
 - data/spec/elasticsearch/model/adapter_spec.rb +0 -11
 - data/spec/elasticsearch/model/adapters/active_record/associations_spec.rb +48 -76
 - data/spec/elasticsearch/model/adapters/active_record/basic_spec.rb +6 -78
 - data/spec/elasticsearch/model/adapters/active_record/import_spec.rb +6 -2
 - data/spec/elasticsearch/model/adapters/active_record/namespaced_model_spec.rb +1 -5
 - data/spec/elasticsearch/model/adapters/active_record/pagination_spec.rb +0 -8
 - data/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb +1 -4
 - data/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb +9 -11
 - data/spec/elasticsearch/model/adapters/mongoid_spec.rb +1 -1
 - data/spec/elasticsearch/model/adapters/multiple_spec.rb +1 -11
 - data/spec/elasticsearch/model/importing_spec.rb +6 -35
 - data/spec/elasticsearch/model/indexing_spec.rb +45 -170
 - data/spec/elasticsearch/model/module_spec.rb +0 -1
 - data/spec/elasticsearch/model/multimodel_spec.rb +2 -8
 - data/spec/elasticsearch/model/naming_spec.rb +0 -68
 - data/spec/elasticsearch/model/proxy_spec.rb +3 -5
 - data/spec/elasticsearch/model/response/aggregations_spec.rb +4 -4
 - data/spec/elasticsearch/model/response/base_spec.rb +0 -1
 - data/spec/elasticsearch/model/response/pagination/kaminari_spec.rb +3 -4
 - data/spec/elasticsearch/model/response/pagination/will_paginate_spec.rb +0 -1
 - data/spec/elasticsearch/model/response/records_spec.rb +0 -1
 - data/spec/elasticsearch/model/response/response_spec.rb +0 -1
 - data/spec/elasticsearch/model/response/result_spec.rb +0 -17
 - data/spec/elasticsearch/model/response/results_spec.rb +0 -1
 - data/spec/elasticsearch/model/searching_search_request_spec.rb +5 -6
 - data/spec/spec_helper.rb +9 -11
 - data/spec/support/app/answer.rb +0 -1
 - data/spec/support/app/article.rb +0 -2
 - data/spec/support/app/article_no_type.rb +1 -1
 - data/spec/support/app/namespaced_book.rb +0 -2
 - data/spec/support/app/parent_and_child_searchable.rb +6 -4
 - data/spec/support/app/question.rb +0 -1
 - metadata +11 -12
 - data/gemfiles/4.0.gemfile +0 -36
 
| 
         @@ -24,29 +24,23 @@ describe Elasticsearch::Model::Multimodel do 
     | 
|
| 
       24 
24 
     | 
    
         
             
              end
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
              let(:model_1) do
         
     | 
| 
       27 
     | 
    
         
            -
                double('Foo', index_name: 'foo_index',  
     | 
| 
      
 27 
     | 
    
         
            +
                double('Foo', index_name: 'foo_index', to_ary: nil)
         
     | 
| 
       28 
28 
     | 
    
         
             
              end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
              let(:model_2) do
         
     | 
| 
       31 
     | 
    
         
            -
                double('Bar', index_name: 'bar_index',  
     | 
| 
      
 31 
     | 
    
         
            +
                double('Bar', index_name: 'bar_index', to_ary: nil)
         
     | 
| 
       32 
32 
     | 
    
         
             
              end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
              it 'has an index name' do
         
     | 
| 
       35 
35 
     | 
    
         
             
                expect(multimodel.index_name).to eq(['foo_index', 'bar_index'])
         
     | 
| 
       36 
36 
     | 
    
         
             
              end
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
              it 'has an document type' do
         
     | 
| 
       39 
     | 
    
         
            -
                expect(multimodel.document_type).to eq(['foo', 'bar'])
         
     | 
| 
       40 
     | 
    
         
            -
              end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
38 
     | 
    
         
             
              it 'has a client' do
         
     | 
| 
       43 
39 
     | 
    
         
             
                expect(multimodel.client).to eq(Elasticsearch::Model.client)
         
     | 
| 
       44 
40 
     | 
    
         
             
              end
         
     | 
| 
       45 
41 
     | 
    
         | 
| 
       46 
42 
     | 
    
         
             
              describe 'the model registry' do
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
43 
     | 
    
         
             
                before(:all) do
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
44 
     | 
    
         
             
                  class JustAModel
         
     | 
| 
       51 
45 
     | 
    
         
             
                    include Elasticsearch::Model
         
     | 
| 
       52 
46 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -51,13 +51,7 @@ describe 'naming' do 
     | 
|
| 
       51 
51 
     | 
    
         
             
                expect(::MyNamespace::DummyNamingModelInNamespace.new.index_name).to eq('my_namespace-dummy_naming_model_in_namespaces')
         
     | 
| 
       52 
52 
     | 
    
         
             
              end
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
       54 
     | 
    
         
            -
              it 'returns nil' do
         
     | 
| 
       55 
     | 
    
         
            -
                expect(DummyNamingModel.document_type).to be_nil
         
     | 
| 
       56 
     | 
    
         
            -
                expect(DummyNamingModel.new.document_type).to be_nil
         
     | 
| 
       57 
     | 
    
         
            -
              end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
54 
     | 
    
         
             
              describe '#index_name' do
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
55 
     | 
    
         
             
                context 'when the index name is set on the class' do
         
     | 
| 
       62 
56 
     | 
    
         | 
| 
       63 
57 
     | 
    
         
             
                  before do
         
     | 
| 
         @@ -138,66 +132,4 @@ describe 'naming' do 
     | 
|
| 
       138 
132 
     | 
    
         
             
                  end
         
     | 
| 
       139 
133 
     | 
    
         
             
                end
         
     | 
| 
       140 
134 
     | 
    
         
             
              end
         
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
       142 
     | 
    
         
            -
              describe '#document_type' do
         
     | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
       144 
     | 
    
         
            -
                it 'returns nil' do
         
     | 
| 
       145 
     | 
    
         
            -
                  expect(DummyNamingModel.document_type).to be_nil
         
     | 
| 
       146 
     | 
    
         
            -
                end
         
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
                context 'when the method is called with an argument' do
         
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
                  before do
         
     | 
| 
       151 
     | 
    
         
            -
                    DummyNamingModel.document_type 'foo'
         
     | 
| 
       152 
     | 
    
         
            -
                  end
         
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
                  it 'changes the document type' do
         
     | 
| 
       155 
     | 
    
         
            -
                    expect(DummyNamingModel.document_type).to eq('foo')
         
     | 
| 
       156 
     | 
    
         
            -
                  end
         
     | 
| 
       157 
     | 
    
         
            -
                end
         
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
                context 'when the method is called on an instance' do
         
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
                  let(:instance) do
         
     | 
| 
       162 
     | 
    
         
            -
                    DummyNamingModel.new
         
     | 
| 
       163 
     | 
    
         
            -
                  end
         
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
                  before do
         
     | 
| 
       166 
     | 
    
         
            -
                    instance.document_type 'foobar_d'
         
     | 
| 
       167 
     | 
    
         
            -
                  end
         
     | 
| 
       168 
     | 
    
         
            -
             
     | 
| 
       169 
     | 
    
         
            -
                  it 'changes the document type' do
         
     | 
| 
       170 
     | 
    
         
            -
                    expect(instance.document_type).to eq('foobar_d')
         
     | 
| 
       171 
     | 
    
         
            -
                  end
         
     | 
| 
       172 
     | 
    
         
            -
                end
         
     | 
| 
       173 
     | 
    
         
            -
              end
         
     | 
| 
       174 
     | 
    
         
            -
             
     | 
| 
       175 
     | 
    
         
            -
              describe '#document_type=' do
         
     | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
       177 
     | 
    
         
            -
                context 'when the method is called on the class' do
         
     | 
| 
       178 
     | 
    
         
            -
             
     | 
| 
       179 
     | 
    
         
            -
                  before do
         
     | 
| 
       180 
     | 
    
         
            -
                    DummyNamingModel.document_type = 'foo_z'
         
     | 
| 
       181 
     | 
    
         
            -
                  end
         
     | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
       183 
     | 
    
         
            -
                  it 'changes the document type' do
         
     | 
| 
       184 
     | 
    
         
            -
                    expect(DummyNamingModel.document_type).to eq('foo_z')
         
     | 
| 
       185 
     | 
    
         
            -
                  end
         
     | 
| 
       186 
     | 
    
         
            -
                end
         
     | 
| 
       187 
     | 
    
         
            -
             
     | 
| 
       188 
     | 
    
         
            -
                context 'when the method is called on an instance' do
         
     | 
| 
       189 
     | 
    
         
            -
             
     | 
| 
       190 
     | 
    
         
            -
                  let(:instance) do
         
     | 
| 
       191 
     | 
    
         
            -
                    DummyNamingModel.new
         
     | 
| 
       192 
     | 
    
         
            -
                  end
         
     | 
| 
       193 
     | 
    
         
            -
             
     | 
| 
       194 
     | 
    
         
            -
                  before do
         
     | 
| 
       195 
     | 
    
         
            -
                    instance.document_type = 'foobar_b'
         
     | 
| 
       196 
     | 
    
         
            -
                  end
         
     | 
| 
       197 
     | 
    
         
            -
             
     | 
| 
       198 
     | 
    
         
            -
                  it 'changes the document type' do
         
     | 
| 
       199 
     | 
    
         
            -
                    expect(instance.document_type).to eq('foobar_b')
         
     | 
| 
       200 
     | 
    
         
            -
                  end
         
     | 
| 
       201 
     | 
    
         
            -
                end
         
     | 
| 
       202 
     | 
    
         
            -
              end
         
     | 
| 
       203 
135 
     | 
    
         
             
            end
         
     | 
| 
         @@ -18,7 +18,6 @@ 
     | 
|
| 
       18 
18 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
            describe Elasticsearch::Model::Proxy do
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
21 
     | 
    
         
             
              before(:all) do
         
     | 
| 
       23 
22 
     | 
    
         
             
                class ::DummyProxyModel
         
     | 
| 
       24 
23 
     | 
    
         
             
                  include Elasticsearch::Model::Proxy
         
     | 
| 
         @@ -123,10 +122,9 @@ describe Elasticsearch::Model::Proxy do 
     | 
|
| 
       123 
122 
     | 
    
         
             
                  expect(model).to eq(model_target)
         
     | 
| 
       124 
123 
     | 
    
         
             
                  expect(duplicate).to eq(duplicate_target)
         
     | 
| 
       125 
124 
     | 
    
         
             
                end
         
     | 
| 
       126 
     | 
    
         
            -
              end
         
     | 
| 
       127 
125 
     | 
    
         | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
      
 126 
     | 
    
         
            +
                it 'forwards keyword arguments to target methods' do
         
     | 
| 
      
 127 
     | 
    
         
            +
                  expect(DummyProxyModel.new.__elasticsearch__.keyword_method(foo: 'bar')).to eq('bar')
         
     | 
| 
      
 128 
     | 
    
         
            +
                end
         
     | 
| 
       130 
129 
     | 
    
         
             
              end
         
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
130 
     | 
    
         
             
            end
         
     | 
| 
         @@ -22,7 +22,6 @@ describe Elasticsearch::Model::Response::Aggregations do 
     | 
|
| 
       22 
22 
     | 
    
         
             
              before(:all) do
         
     | 
| 
       23 
23 
     | 
    
         
             
                class OriginClass
         
     | 
| 
       24 
24 
     | 
    
         
             
                  def self.index_name;    'foo'; end
         
     | 
| 
       25 
     | 
    
         
            -
                  def self.document_type; 'bar'; end
         
     | 
| 
       26 
25 
     | 
    
         
             
                end
         
     | 
| 
       27 
26 
     | 
    
         
             
              end
         
     | 
| 
       28 
27 
     | 
    
         | 
| 
         @@ -34,9 +33,10 @@ describe Elasticsearch::Model::Response::Aggregations do 
     | 
|
| 
       34 
33 
     | 
    
         
             
                {
         
     | 
| 
       35 
34 
     | 
    
         
             
                    'aggregations' => {
         
     | 
| 
       36 
35 
     | 
    
         
             
                        'foo' => {'bar' => 10 },
         
     | 
| 
       37 
     | 
    
         
            -
                        'price' => { 
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
                        'price' => {
         
     | 
| 
      
 37 
     | 
    
         
            +
                          'doc_count' => 123,
         
     | 
| 
      
 38 
     | 
    
         
            +
                          'min' => { 'value' => 1.0},
         
     | 
| 
      
 39 
     | 
    
         
            +
                          'max' => { 'value' => 99 }
         
     | 
| 
       40 
40 
     | 
    
         
             
                        }
         
     | 
| 
       41 
41 
     | 
    
         
             
                    }
         
     | 
| 
       42 
42 
     | 
    
         
             
                }
         
     | 
| 
         @@ -23,7 +23,6 @@ describe 'Elasticsearch::Model::Response::Response Kaminari' do 
     | 
|
| 
       23 
23 
     | 
    
         
             
                class ModelClass
         
     | 
| 
       24 
24 
     | 
    
         
             
                  include ::Kaminari::ConfigurationMethods
         
     | 
| 
       25 
25 
     | 
    
         
             
                  def self.index_name;    'foo'; end
         
     | 
| 
       26 
     | 
    
         
            -
                  def self.document_type; 'bar'; end
         
     | 
| 
       27 
26 
     | 
    
         
             
                end
         
     | 
| 
       28 
27 
     | 
    
         
             
              end
         
     | 
| 
       29 
28 
     | 
    
         | 
| 
         @@ -58,7 +57,7 @@ describe 'Elasticsearch::Model::Response::Response Kaminari' do 
     | 
|
| 
       58 
57 
     | 
    
         
             
                  context 'when page is called once' do
         
     | 
| 
       59 
58 
     | 
    
         | 
| 
       60 
59 
     | 
    
         
             
                    let(:search_request) do
         
     | 
| 
       61 
     | 
    
         
            -
                      { index: index_field, from: 25, size: 25, q: '*' 
     | 
| 
      
 60 
     | 
    
         
            +
                      { index: index_field, from: 25, size: 25, q: '*' }
         
     | 
| 
       62 
61 
     | 
    
         
             
                    end
         
     | 
| 
       63 
62 
     | 
    
         | 
| 
       64 
63 
     | 
    
         
             
                    before do
         
     | 
| 
         @@ -75,11 +74,11 @@ describe 'Elasticsearch::Model::Response::Response Kaminari' do 
     | 
|
| 
       75 
74 
     | 
    
         
             
                  context 'when page is called more than once' do
         
     | 
| 
       76 
75 
     | 
    
         | 
| 
       77 
76 
     | 
    
         
             
                    let(:search_request_one) do
         
     | 
| 
       78 
     | 
    
         
            -
                      { index: index_field, from: 25, size: 25, q: '*' 
     | 
| 
      
 77 
     | 
    
         
            +
                      { index: index_field, from: 25, size: 25, q: '*' }
         
     | 
| 
       79 
78 
     | 
    
         
             
                    end
         
     | 
| 
       80 
79 
     | 
    
         | 
| 
       81 
80 
     | 
    
         
             
                    let(:search_request_two) do
         
     | 
| 
       82 
     | 
    
         
            -
                      { index: index_field, from: 75, size: 25, q: '*' 
     | 
| 
      
 81 
     | 
    
         
            +
                      { index: index_field, from: 75, size: 25, q: '*' }
         
     | 
| 
       83 
82 
     | 
    
         
             
                    end
         
     | 
| 
       84 
83 
     | 
    
         | 
| 
       85 
84 
     | 
    
         
             
                    before do
         
     | 
| 
         @@ -19,7 +19,6 @@ require 'spec_helper' 
     | 
|
| 
       19 
19 
     | 
    
         
             
            require 'active_support/json/encoding'
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
            describe Elasticsearch::Model::Response::Result do
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
22 
     | 
    
         
             
              let(:result) do
         
     | 
| 
       24 
23 
     | 
    
         
             
                described_class.new(foo: 'bar', bar: { bam: 'baz' })
         
     | 
| 
       25 
24 
     | 
    
         
             
              end
         
     | 
| 
         @@ -45,23 +44,7 @@ describe Elasticsearch::Model::Response::Result do 
     | 
|
| 
       45 
44 
     | 
    
         
             
                end
         
     | 
| 
       46 
45 
     | 
    
         
             
              end
         
     | 
| 
       47 
46 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
              describe '#type' do
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                let(:result) do
         
     | 
| 
       51 
     | 
    
         
            -
                  described_class.new(foo: 'bar', _type: 'baz', _source: { type: 'BAM' })
         
     | 
| 
       52 
     | 
    
         
            -
                end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                it 'returns the _type field' do
         
     | 
| 
       55 
     | 
    
         
            -
                  expect(result.type).to eq('baz')
         
     | 
| 
       56 
     | 
    
         
            -
                end
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                it 'provides access to the source type field' do
         
     | 
| 
       59 
     | 
    
         
            -
                  expect(result._source.type).to eq('BAM')
         
     | 
| 
       60 
     | 
    
         
            -
                end
         
     | 
| 
       61 
     | 
    
         
            -
              end
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
47 
     | 
    
         
             
              describe 'method delegation' do
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
48 
     | 
    
         
             
                let(:result) do
         
     | 
| 
       66 
49 
     | 
    
         
             
                  described_class.new(foo: 'bar', _source: { bar: { bam: 'baz' } })
         
     | 
| 
       67 
50 
     | 
    
         
             
                end
         
     | 
| 
         @@ -23,7 +23,6 @@ describe Elasticsearch::Model::Serializing do 
     | 
|
| 
       23 
23 
     | 
    
         
             
                class ::DummySearchingModel
         
     | 
| 
       24 
24 
     | 
    
         
             
                  extend Elasticsearch::Model::Searching::ClassMethods
         
     | 
| 
       25 
25 
     | 
    
         
             
                  def self.index_name;    'foo'; end
         
     | 
| 
       26 
     | 
    
         
            -
                  def self.document_type; 'bar'; end
         
     | 
| 
       27 
26 
     | 
    
         
             
                end
         
     | 
| 
       28 
27 
     | 
    
         
             
              end
         
     | 
| 
       29 
28 
     | 
    
         | 
| 
         @@ -44,7 +43,7 @@ describe Elasticsearch::Model::Serializing do 
     | 
|
| 
       44 
43 
     | 
    
         
             
                context 'when the search definition is a simple query' do
         
     | 
| 
       45 
44 
     | 
    
         | 
| 
       46 
45 
     | 
    
         
             
                  before do
         
     | 
| 
       47 
     | 
    
         
            -
                    expect(client).to receive(:search).with(index: 'foo',  
     | 
| 
      
 46 
     | 
    
         
            +
                    expect(client).to receive(:search).with({ index: 'foo', q: 'foo' }).and_return({})
         
     | 
| 
       48 
47 
     | 
    
         
             
                  end
         
     | 
| 
       49 
48 
     | 
    
         | 
| 
       50 
49 
     | 
    
         
             
                  let(:search) do
         
     | 
| 
         @@ -59,7 +58,7 @@ describe Elasticsearch::Model::Serializing do 
     | 
|
| 
       59 
58 
     | 
    
         
             
                context 'when the search definition is a hash' do
         
     | 
| 
       60 
59 
     | 
    
         | 
| 
       61 
60 
     | 
    
         
             
                  before do
         
     | 
| 
       62 
     | 
    
         
            -
                    expect(client).to receive(:search).with(index: 'foo',  
     | 
| 
      
 61 
     | 
    
         
            +
                    expect(client).to receive(:search).with({ index: 'foo', body: { foo: 'bar' } }).and_return({})
         
     | 
| 
       63 
62 
     | 
    
         
             
                  end
         
     | 
| 
       64 
63 
     | 
    
         | 
| 
       65 
64 
     | 
    
         
             
                  let(:search) do
         
     | 
| 
         @@ -74,7 +73,7 @@ describe Elasticsearch::Model::Serializing do 
     | 
|
| 
       74 
73 
     | 
    
         
             
                context 'when the search definition is a json string' do
         
     | 
| 
       75 
74 
     | 
    
         | 
| 
       76 
75 
     | 
    
         
             
                  before do
         
     | 
| 
       77 
     | 
    
         
            -
                    expect(client).to receive(:search).with(index: 'foo',  
     | 
| 
      
 76 
     | 
    
         
            +
                    expect(client).to receive(:search).with({ index: 'foo', body: '{"foo":"bar"}' }).and_return({})
         
     | 
| 
       78 
77 
     | 
    
         
             
                  end
         
     | 
| 
       79 
78 
     | 
    
         | 
| 
       80 
79 
     | 
    
         
             
                  let(:search) do
         
     | 
| 
         @@ -99,7 +98,7 @@ describe Elasticsearch::Model::Serializing do 
     | 
|
| 
       99 
98 
     | 
    
         
             
                  end
         
     | 
| 
       100 
99 
     | 
    
         | 
| 
       101 
100 
     | 
    
         
             
                  before do
         
     | 
| 
       102 
     | 
    
         
            -
                    expect(client).to receive(:search).with(index: 'foo',  
     | 
| 
      
 101 
     | 
    
         
            +
                    expect(client).to receive(:search).with({ index: 'foo', body: {foo: 'bar'} }).and_return({})
         
     | 
| 
       103 
102 
     | 
    
         
             
                  end
         
     | 
| 
       104 
103 
     | 
    
         | 
| 
       105 
104 
     | 
    
         
             
                  let(:search) do
         
     | 
| 
         @@ -114,7 +113,7 @@ describe Elasticsearch::Model::Serializing do 
     | 
|
| 
       114 
113 
     | 
    
         
             
                context 'when extra options are specified' do
         
     | 
| 
       115 
114 
     | 
    
         | 
| 
       116 
115 
     | 
    
         
             
                  before do
         
     | 
| 
       117 
     | 
    
         
            -
                    expect(client).to receive(:search).with(index: 'foo',  
     | 
| 
      
 116 
     | 
    
         
            +
                    expect(client).to receive(:search).with({ index: 'foo', q: 'foo', size: 15 }).and_return({})
         
     | 
| 
       118 
117 
     | 
    
         
             
                  end
         
     | 
| 
       119 
118 
     | 
    
         | 
| 
       120 
119 
     | 
    
         
             
                  let(:search) do
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -31,6 +31,10 @@ end 
     | 
|
| 
       31 
31 
     | 
    
         
             
            require 'yaml'
         
     | 
| 
       32 
32 
     | 
    
         
             
            require 'active_record'
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
      
 34 
     | 
    
         
            +
            # Load all of ActiveSupport to be sure of complete compatibility -
         
     | 
| 
      
 35 
     | 
    
         
            +
            # see https://github.com/elastic/elasticsearch-rails/pull/1075 for details
         
     | 
| 
      
 36 
     | 
    
         
            +
            require 'active_support/all'
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
       34 
38 
     | 
    
         
             
            unless defined?(ELASTICSEARCH_URL)
         
     | 
| 
       35 
39 
     | 
    
         
             
              ELASTICSEARCH_URL = ENV['ELASTICSEARCH_URL'] || "localhost:#{(ENV['TEST_CLUSTER_PORT'] || 9200)}"
         
     | 
| 
       36 
40 
     | 
    
         
             
            end
         
     | 
| 
         @@ -43,8 +47,11 @@ RSpec.configure do |config| 
     | 
|
| 
       43 
47 
     | 
    
         
             
                require 'ansi'
         
     | 
| 
       44 
48 
     | 
    
         
             
                tracer = ::Logger.new(STDERR)
         
     | 
| 
       45 
49 
     | 
    
         
             
                tracer.formatter = lambda { |s, d, p, m| "#{m.gsub(/^.*$/) { |n| '   ' + n }.ansi(:faint)}\n" }
         
     | 
| 
       46 
     | 
    
         
            -
                Elasticsearch::Model.client = Elasticsearch::Client.new 
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
      
 50 
     | 
    
         
            +
                Elasticsearch::Model.client = Elasticsearch::Client.new(
         
     | 
| 
      
 51 
     | 
    
         
            +
                  host: ELASTICSEARCH_URL,
         
     | 
| 
      
 52 
     | 
    
         
            +
                  tracer: (ENV['QUIET'] ? nil : tracer),
         
     | 
| 
      
 53 
     | 
    
         
            +
                  transport_options: { :ssl => { verify: false } }
         
     | 
| 
      
 54 
     | 
    
         
            +
                )
         
     | 
| 
       48 
55 
     | 
    
         
             
                puts "Elasticsearch Version: #{Elasticsearch::Model.client.info['version']}"
         
     | 
| 
       49 
56 
     | 
    
         | 
| 
       50 
57 
     | 
    
         
             
                unless ActiveRecord::Base.connected?
         
     | 
| 
         @@ -63,15 +70,6 @@ RSpec.configure do |config| 
     | 
|
| 
       63 
70 
     | 
    
         
             
              end
         
     | 
| 
       64 
71 
     | 
    
         
             
            end
         
     | 
| 
       65 
72 
     | 
    
         | 
| 
       66 
     | 
    
         
            -
            # Is the ActiveRecord version at least 4.0?
         
     | 
| 
       67 
     | 
    
         
            -
            #
         
     | 
| 
       68 
     | 
    
         
            -
            # @return [ true, false ] Whether the ActiveRecord version is at least 4.0.
         
     | 
| 
       69 
     | 
    
         
            -
            #
         
     | 
| 
       70 
     | 
    
         
            -
            # @since 6.0.1
         
     | 
| 
       71 
     | 
    
         
            -
            def active_record_at_least_4?
         
     | 
| 
       72 
     | 
    
         
            -
              defined?(::ActiveRecord) && ::ActiveRecord::VERSION::MAJOR >= 4
         
     | 
| 
       73 
     | 
    
         
            -
            end
         
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
73 
     | 
    
         
             
            # Delete all documents from the indices of the provided list of models.
         
     | 
| 
       76 
74 
     | 
    
         
             
            #
         
     | 
| 
       77 
75 
     | 
    
         
             
            # @param [ Array<ActiveRecord::Base> ] models The list of models.
         
     | 
    
        data/spec/support/app/answer.rb
    CHANGED
    
    
    
        data/spec/support/app/article.rb
    CHANGED
    
    | 
         @@ -19,8 +19,6 @@ class ::Article < ActiveRecord::Base 
     | 
|
| 
       19 
19 
     | 
    
         
             
              include Elasticsearch::Model
         
     | 
| 
       20 
20 
     | 
    
         
             
              include Elasticsearch::Model::Callbacks
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
              document_type 'article'
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
22 
     | 
    
         
             
              settings index: {number_of_shards: 1, number_of_replicas: 0} do
         
     | 
| 
       25 
23 
     | 
    
         
             
                mapping do
         
     | 
| 
       26 
24 
     | 
    
         
             
                  indexes :title, type: 'text', analyzer: 'snowball'
         
     | 
| 
         @@ -21,7 +21,7 @@ class ::ArticleNoType < ActiveRecord::Base 
     | 
|
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
              settings index: {number_of_shards: 1, number_of_replicas: 0} do
         
     | 
| 
       23 
23 
     | 
    
         
             
                mapping do
         
     | 
| 
       24 
     | 
    
         
            -
                  indexes :title,  
     | 
| 
      
 24 
     | 
    
         
            +
                  indexes :title, analyzer: 'snowball'
         
     | 
| 
       25 
25 
     | 
    
         
             
                  indexes :body, type: 'text'
         
     | 
| 
       26 
26 
     | 
    
         
             
                  indexes :clicks, type: 'integer'
         
     | 
| 
       27 
27 
     | 
    
         
             
                  indexes :created_at, type: 'date'
         
     | 
| 
         @@ -26,10 +26,12 @@ module ParentChildSearchable 
     | 
|
| 
       26 
26 
     | 
    
         
             
                settings = Question.settings.to_hash.merge Answer.settings.to_hash
         
     | 
| 
       27 
27 
     | 
    
         
             
                mapping_properties = { join_field: { type: JOIN,
         
     | 
| 
       28 
28 
     | 
    
         
             
                                                     relations: { Question::JOIN_TYPE => Answer::JOIN_TYPE } } }
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
      
 29 
     | 
    
         
            +
                merged_properties = mapping_properties.merge(
         
     | 
| 
      
 30 
     | 
    
         
            +
                  Question.mappings.to_hash[:properties]
         
     | 
| 
      
 31 
     | 
    
         
            +
                ).merge(
         
     | 
| 
      
 32 
     | 
    
         
            +
                  Answer.mappings.to_hash[:properties]
         
     | 
| 
      
 33 
     | 
    
         
            +
                )
         
     | 
| 
      
 34 
     | 
    
         
            +
                mappings = { properties: merged_properties }
         
     | 
| 
       33 
35 
     | 
    
         | 
| 
       34 
36 
     | 
    
         
             
                client.indices.create({ index: INDEX_NAME,
         
     | 
| 
       35 
37 
     | 
    
         
             
                                        body: {
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: elasticsearch-model
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version:  
     | 
| 
      
 4 
     | 
    
         
            +
              version: 8.0.0.pre
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
     | 
    
         
            -
            -  
     | 
| 
      
 7 
     | 
    
         
            +
            - Elastic Client Library Maintainers
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2024-04-16 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activesupport
         
     | 
| 
         @@ -30,14 +30,14 @@ dependencies: 
     | 
|
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
31 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '8'
         
     | 
| 
       34 
34 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       35 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
38 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '8'
         
     | 
| 
       41 
41 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
42 
     | 
    
         
             
              name: hashie
         
     | 
| 
       43 
43 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -306,7 +306,7 @@ dependencies: 
     | 
|
| 
       306 
306 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       307 
307 
     | 
    
         
             
            description: ActiveModel/Record integrations for Elasticsearch.
         
     | 
| 
       308 
308 
     | 
    
         
             
            email:
         
     | 
| 
       309 
     | 
    
         
            -
            -  
     | 
| 
      
 309 
     | 
    
         
            +
            - client-libs@elastic.co
         
     | 
| 
       310 
310 
     | 
    
         
             
            executables: []
         
     | 
| 
       311 
311 
     | 
    
         
             
            extensions: []
         
     | 
| 
       312 
312 
     | 
    
         
             
            extra_rdoc_files:
         
     | 
| 
         @@ -330,10 +330,9 @@ files: 
     | 
|
| 
       330 
330 
     | 
    
         
             
            - examples/mongoid_article.rb
         
     | 
| 
       331 
331 
     | 
    
         
             
            - examples/ohm_article.rb
         
     | 
| 
       332 
332 
     | 
    
         
             
            - examples/riak_article.rb
         
     | 
| 
       333 
     | 
    
         
            -
            - gemfiles/ 
     | 
| 
       334 
     | 
    
         
            -
            - gemfiles/ 
     | 
| 
       335 
     | 
    
         
            -
            - gemfiles/ 
     | 
| 
       336 
     | 
    
         
            -
            - gemfiles/6.0.gemfile
         
     | 
| 
      
 333 
     | 
    
         
            +
            - gemfiles/6.1.gemfile
         
     | 
| 
      
 334 
     | 
    
         
            +
            - gemfiles/7.0.gemfile
         
     | 
| 
      
 335 
     | 
    
         
            +
            - gemfiles/7.1.gemfile
         
     | 
| 
       337 
336 
     | 
    
         
             
            - lib/elasticsearch/model.rb
         
     | 
| 
       338 
337 
     | 
    
         
             
            - lib/elasticsearch/model/adapter.rb
         
     | 
| 
       339 
338 
     | 
    
         
             
            - lib/elasticsearch/model/adapters/active_record.rb
         
     | 
| 
         @@ -435,14 +434,14 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       435 
434 
     | 
    
         
             
              requirements:
         
     | 
| 
       436 
435 
     | 
    
         
             
              - - ">="
         
     | 
| 
       437 
436 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       438 
     | 
    
         
            -
                  version: ' 
     | 
| 
      
 437 
     | 
    
         
            +
                  version: '3'
         
     | 
| 
       439 
438 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       440 
439 
     | 
    
         
             
              requirements:
         
     | 
| 
       441 
440 
     | 
    
         
             
              - - ">="
         
     | 
| 
       442 
441 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       443 
442 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       444 
443 
     | 
    
         
             
            requirements: []
         
     | 
| 
       445 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
      
 444 
     | 
    
         
            +
            rubygems_version: 3.5.3
         
     | 
| 
       446 
445 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       447 
446 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       448 
447 
     | 
    
         
             
            summary: ActiveModel/Record integrations for Elasticsearch.
         
     | 
    
        data/gemfiles/4.0.gemfile
    DELETED
    
    | 
         @@ -1,36 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # Licensed to Elasticsearch B.V. under one or more contributor
         
     | 
| 
       2 
     | 
    
         
            -
            # license agreements. See the NOTICE file distributed with
         
     | 
| 
       3 
     | 
    
         
            -
            # this work for additional information regarding copyright
         
     | 
| 
       4 
     | 
    
         
            -
            # ownership. Elasticsearch B.V. licenses this file to you under
         
     | 
| 
       5 
     | 
    
         
            -
            # the Apache License, Version 2.0 (the "License"); you may
         
     | 
| 
       6 
     | 
    
         
            -
            # not use this file except in compliance with the License.
         
     | 
| 
       7 
     | 
    
         
            -
            # You may obtain a copy of the License at
         
     | 
| 
       8 
     | 
    
         
            -
            #
         
     | 
| 
       9 
     | 
    
         
            -
            #	http://www.apache.org/licenses/LICENSE-2.0
         
     | 
| 
       10 
     | 
    
         
            -
            #
         
     | 
| 
       11 
     | 
    
         
            -
            # Unless required by applicable law or agreed to in writing,
         
     | 
| 
       12 
     | 
    
         
            -
            # software distributed under the License is distributed on an
         
     | 
| 
       13 
     | 
    
         
            -
            # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
         
     | 
| 
       14 
     | 
    
         
            -
            # KIND, either express or implied.  See the License for the
         
     | 
| 
       15 
     | 
    
         
            -
            # specific language governing permissions and limitations
         
     | 
| 
       16 
     | 
    
         
            -
            # under the License.
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
            # Usage:
         
     | 
| 
       19 
     | 
    
         
            -
            #
         
     | 
| 
       20 
     | 
    
         
            -
            # $ BUNDLE_GEMFILE=./gemfiles/4.0.gemfile bundle install
         
     | 
| 
       21 
     | 
    
         
            -
            # $ BUNDLE_GEMFILE=./gemfiles/4.0.gemfile bundle exec rake test:integration
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
            source 'https://rubygems.org'
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
            gemspec path: '../'
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
            gem 'activemodel',  '~> 4'
         
     | 
| 
       28 
     | 
    
         
            -
            gem 'activerecord', '~> 4'
         
     | 
| 
       29 
     | 
    
         
            -
            gem 'mongoid', '~> 5'
         
     | 
| 
       30 
     | 
    
         
            -
            gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION)
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
            group :development, :testing do
         
     | 
| 
       33 
     | 
    
         
            -
              gem 'bigdecimal', '~> 1'
         
     | 
| 
       34 
     | 
    
         
            -
              gem 'pry-nav'
         
     | 
| 
       35 
     | 
    
         
            -
              gem 'rspec'
         
     | 
| 
       36 
     | 
    
         
            -
            end
         
     |