elasticsearch-model 7.0.0.pre → 7.1.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +41 -43
- data/Rakefile +7 -10
- data/elasticsearch-model.gemspec +37 -39
- data/examples/activerecord_associations.rb +16 -0
- data/gemfiles/4.0.gemfile +4 -3
- data/gemfiles/6.0.gemfile +3 -3
- data/lib/elasticsearch/model.rb +10 -55
- data/lib/elasticsearch/model/adapters/active_record.rb +1 -1
- data/lib/elasticsearch/model/importing.rb +43 -16
- data/lib/elasticsearch/model/indexing.rb +41 -36
- data/lib/elasticsearch/model/multimodel.rb +1 -1
- data/lib/elasticsearch/model/naming.rb +1 -10
- data/lib/elasticsearch/model/proxy.rb +41 -21
- data/lib/elasticsearch/model/response/records.rb +0 -1
- data/lib/elasticsearch/model/version.rb +1 -1
- data/spec/elasticsearch/model/adapters/active_record/import_spec.rb +1 -12
- data/spec/elasticsearch/model/adapters/mongoid/multi_model_spec.rb +11 -11
- data/spec/elasticsearch/model/importing_spec.rb +12 -0
- data/spec/elasticsearch/model/indexing_spec.rb +3 -33
- data/spec/elasticsearch/model/module_spec.rb +1 -0
- data/spec/spec_helper.rb +19 -5
- data/spec/support/app.rb +9 -2
- metadata +46 -48
- data/spec/elasticsearch/model/naming_inheritance_spec.rb +0 -123
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51e1e98703f1834d64dc969afcc75f107460220a9e213dc128dc5e1015be5a7b
|
4
|
+
data.tar.gz: b44da631182388ef384dcab9f6e9d3626c40bf2b6272ef35c6f4857670320f6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a627d5e725a0a3ffb0476873617e0f5d99f297ac1bad49554b69e1546f28bbc58a6cd3b3e54282d0127ed3da828f187f6dba4dc449bbe51ad8229b0b0167a276
|
7
|
+
data.tar.gz: 35b7bc2cb6161fff40247e4cf76fd789ffbc12c4c2acfb1e8223b567ce799bcb12a9fd8857cf1bdbdb13999a981114b2e46f6054f5a27dfb1d487cb188f86860
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,25 +1,22 @@
|
|
1
1
|
# Elasticsearch::Model
|
2
2
|
|
3
|
-
The `elasticsearch-model` library builds on top of the
|
4
|
-
the [`elasticsearch`](https://github.com/elastic/elasticsearch-ruby) library.
|
3
|
+
The `elasticsearch-model` library builds on top of the the [`elasticsearch`](https://github.com/elastic/elasticsearch-ruby) library.
|
5
4
|
|
6
|
-
It aims to simplify integration of Ruby classes ("models"), commonly found
|
7
|
-
e.g. in [Ruby on Rails](http://rubyonrails.org) applications, with the
|
8
|
-
[Elasticsearch](http://www.elasticsearch.org) search and analytics engine.
|
5
|
+
It aims to simplify integration of Ruby classes ("models"), commonly found e.g. in [Ruby on Rails](http://rubyonrails.org) applications, with the [Elasticsearch](https://www.elastic.co) search and analytics engine.
|
9
6
|
|
10
7
|
## Compatibility
|
11
8
|
|
12
|
-
This library is compatible with Ruby
|
9
|
+
This library is compatible with Ruby 2.4 and higher.
|
13
10
|
|
14
|
-
The library version numbers follow the Elasticsearch major versions
|
15
|
-
is compatible with the Elasticsearch `master` branch, therefore, with the next major version.
|
11
|
+
The library version numbers follow the Elasticsearch major versions. The `master` branch is compatible with the latest Elasticsearch stack stable release.
|
16
12
|
|
17
13
|
| Rubygem | | Elasticsearch |
|
18
14
|
|:-------------:|:-:| :-----------: |
|
19
15
|
| 0.1 | → | 1.x |
|
20
16
|
| 2.x | → | 2.x |
|
21
17
|
| 5.x | → | 5.x |
|
22
|
-
|
|
18
|
+
| 6.x | → | 6.x |
|
19
|
+
| master | → | 7.x |
|
23
20
|
|
24
21
|
## Installation
|
25
22
|
|
@@ -72,9 +69,7 @@ This will extend the model with functionality related to Elasticsearch.
|
|
72
69
|
|
73
70
|
#### Feature Extraction Pattern
|
74
71
|
|
75
|
-
Instead of including the `Elasticsearch::Model` module directly in your model,
|
76
|
-
you can include it in a "concern" or "trait" module, which is quite common pattern in Rails applications,
|
77
|
-
using e.g. `ActiveSupport::Concern` as the instrumentation:
|
72
|
+
Instead of including the `Elasticsearch::Model` module directly in your model, you can include it in a "concern" or "trait" module, which is quite common pattern in Rails applications, using e.g. `ActiveSupport::Concern` as the instrumentation:
|
78
73
|
|
79
74
|
```ruby
|
80
75
|
# In: app/models/concerns/searchable.rb
|
@@ -151,7 +146,7 @@ for information about the Ruby client API.
|
|
151
146
|
|
152
147
|
### Importing the data
|
153
148
|
|
154
|
-
The first thing you'll want to do is
|
149
|
+
The first thing you'll want to do is import your data into the index:
|
155
150
|
|
156
151
|
```ruby
|
157
152
|
Article.import
|
@@ -289,11 +284,8 @@ NOTE: It is _not_ possible to chain other methods on top of the `records` object
|
|
289
284
|
|
290
285
|
#### Pagination
|
291
286
|
|
292
|
-
You can implement pagination with the `from` and `size` search parameters. However, search results
|
293
|
-
|
294
|
-
[`will_paginate`](https://github.com/mislav/will_paginate) gems.
|
295
|
-
(The pagination gems must be added before the Elasticsearch gems in your Gemfile,
|
296
|
-
or loaded first in your application.)
|
287
|
+
You can implement pagination with the `from` and `size` search parameters. However, search results can be automatically paginated with the [`kaminari`](http://rubygems.org/gems/kaminari) or [`will_paginate`](https://github.com/mislav/will_paginate) gems.
|
288
|
+
(The pagination gems must be added before the Elasticsearch gems in your Gemfile, or loaded first in your application.)
|
297
289
|
|
298
290
|
If Kaminari or WillPaginate is loaded, use the familiar paging methods:
|
299
291
|
|
@@ -321,8 +313,7 @@ Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model
|
|
321
313
|
|
322
314
|
#### The Elasticsearch DSL
|
323
315
|
|
324
|
-
In most situations, you'll want to pass the search definition
|
325
|
-
in the Elasticsearch [domain-specific language](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html) to the client:
|
316
|
+
In most situations, you'll want to pass the search definition in the Elasticsearch [domain-specific language](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html) to the client:
|
326
317
|
|
327
318
|
```ruby
|
328
319
|
response = Article.search query: { match: { title: "Fox Dogs" } },
|
@@ -332,8 +323,7 @@ response.results.first.highlight.title
|
|
332
323
|
# ["Quick brown <em>fox</em>"]
|
333
324
|
```
|
334
325
|
|
335
|
-
You can pass any object which implements a `to_hash` method, which is called automatically,
|
336
|
-
so you can use a custom class or your favourite JSON builder to build the search definition:
|
326
|
+
You can pass any object which implements a `to_hash` method, which is called automatically, so you can use a custom class or your favourite JSON builder to build the search definition:
|
337
327
|
|
338
328
|
```ruby
|
339
329
|
require 'jbuilder'
|
@@ -353,8 +343,7 @@ response.results.first.title
|
|
353
343
|
# => "Quick brown fox"
|
354
344
|
```
|
355
345
|
|
356
|
-
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
|
357
|
-
the Elasticsearch Query DSL:
|
346
|
+
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:
|
358
347
|
|
359
348
|
```ruby
|
360
349
|
require 'elasticsearch/dsl'
|
@@ -732,13 +721,8 @@ module and its submodules for technical information.
|
|
732
721
|
|
733
722
|
The module provides a common `settings` method to customize various features.
|
734
723
|
|
735
|
-
|
736
|
-
|
737
|
-
in Rails:
|
738
|
-
|
739
|
-
```ruby
|
740
|
-
Elasticsearch::Model.settings[:inheritance_enabled] = true
|
741
|
-
```
|
724
|
+
Before version 7.0.0 of the gem, the only supported setting was `:inheritance_enabled`. This setting has been deprecated
|
725
|
+
and removed.
|
742
726
|
|
743
727
|
## Development and Community
|
744
728
|
|
@@ -756,20 +740,34 @@ curl -# https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticse
|
|
756
740
|
SERVER=start TEST_CLUSTER_COMMAND=$PWD/tmp/elasticsearch-1.0.0.RC1/bin/elasticsearch bundle exec rake test:all
|
757
741
|
```
|
758
742
|
|
743
|
+
### Single Table Inheritance support
|
744
|
+
|
745
|
+
Versions < 7.0.0 of this gem supported inheritance-- more specifically, `Single Table Inheritance`. With this feature,
|
746
|
+
elasticsearch settings (index mappings, etc) on a parent model could be inherited by a child model leading to different
|
747
|
+
model documents being indexed into the same Elasticsearch index. This feature depended on the ability to set a `type`
|
748
|
+
for a document in Elasticsearch. The Elasticsearch team has deprecated support for `types`, as is described
|
749
|
+
[here.](https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html)
|
750
|
+
This gem will also remove support for types and `Single Table Inheritance` in version 7.0 as it enables an anti-pattern.
|
751
|
+
Please save different model documents in separate indices. If you want to use STI, you can include an artificial
|
752
|
+
`type` field manually in each document and use it in other operations.
|
753
|
+
|
759
754
|
## License
|
760
755
|
|
761
756
|
This software is licensed under the Apache 2 license, quoted below.
|
762
757
|
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
758
|
+
Licensed to Elasticsearch B.V. under one or more contributor
|
759
|
+
license agreements. See the NOTICE file distributed with
|
760
|
+
this work for additional information regarding copyright
|
761
|
+
ownership. Elasticsearch B.V. licenses this file to you under
|
762
|
+
the Apache License, Version 2.0 (the "License"); you may
|
763
|
+
not use this file except in compliance with the License.
|
767
764
|
You may obtain a copy of the License at
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
Unless required by applicable law or agreed to in writing,
|
772
|
-
distributed under the License is distributed on an
|
773
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
774
|
-
See the License for the
|
775
|
-
|
765
|
+
|
766
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
767
|
+
|
768
|
+
Unless required by applicable law or agreed to in writing,
|
769
|
+
software distributed under the License is distributed on an
|
770
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
771
|
+
KIND, either express or implied. See the License for the
|
772
|
+
specific language governing permissions and limitations
|
773
|
+
under the License.
|
data/Rakefile
CHANGED
@@ -15,17 +15,15 @@
|
|
15
15
|
# specific language governing permissions and limitations
|
16
16
|
# under the License.
|
17
17
|
|
18
|
-
require
|
18
|
+
require 'bundler/gem_tasks'
|
19
19
|
|
20
|
-
desc
|
21
|
-
task :
|
22
|
-
task :
|
20
|
+
desc 'Run unit tests'
|
21
|
+
task default: 'test:all'
|
22
|
+
task test: 'test:all'
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
GEMFILES = ['4.0.gemfile', '5.0.gemfile', '6.0.gemfile']
|
28
|
-
end
|
24
|
+
gemfiles = ['5.0.gemfile', '6.0.gemfile']
|
25
|
+
gemfiles << '4.0.gemfile' if RUBY_VERSION < '2.7'
|
26
|
+
GEMFILES = gemfiles.freeze
|
29
27
|
|
30
28
|
namespace :bundle do
|
31
29
|
desc 'Install dependencies for all the Gemfiles in /gemfiles. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0'
|
@@ -47,7 +45,6 @@ end
|
|
47
45
|
|
48
46
|
require 'rake/testtask'
|
49
47
|
namespace :test do
|
50
|
-
|
51
48
|
desc 'Run all tests. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0'
|
52
49
|
task :all, [:rails_versions] do |task, args|
|
53
50
|
gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map {|v| "#{v}.gemfile"} : GEMFILES
|
data/elasticsearch-model.gemspec
CHANGED
@@ -16,56 +16,54 @@
|
|
16
16
|
# under the License.
|
17
17
|
|
18
18
|
# coding: utf-8
|
19
|
-
|
19
|
+
|
20
|
+
lib = File.expand_path('lib', __dir__)
|
20
21
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
21
22
|
require 'elasticsearch/model/version'
|
22
23
|
|
23
24
|
Gem::Specification.new do |s|
|
24
|
-
s.name =
|
25
|
+
s.name = 'elasticsearch-model'
|
25
26
|
s.version = Elasticsearch::Model::VERSION
|
26
|
-
s.authors = [
|
27
|
-
s.email = [
|
28
|
-
s.description =
|
29
|
-
s.summary =
|
30
|
-
s.homepage =
|
31
|
-
s.license =
|
27
|
+
s.authors = ['Karel Minarik']
|
28
|
+
s.email = ['karel.minarik@elasticsearch.org']
|
29
|
+
s.description = 'ActiveModel/Record integrations for Elasticsearch.'
|
30
|
+
s.summary = 'ActiveModel/Record integrations for Elasticsearch.'
|
31
|
+
s.homepage = 'https://github.com/elasticsearch/elasticsearch-rails/'
|
32
|
+
s.license = 'Apache 2'
|
32
33
|
|
33
34
|
s.files = `git ls-files`.split($/)
|
34
35
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
35
36
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
36
|
-
s.require_paths = [
|
37
|
-
|
38
|
-
s.extra_rdoc_files = [ "README.md", "LICENSE.txt" ]
|
39
|
-
s.rdoc_options = [ "--charset=UTF-8" ]
|
40
|
-
|
41
|
-
s.required_ruby_version = ">= 1.9.3"
|
42
|
-
|
43
|
-
s.add_dependency "elasticsearch", '> 1'
|
44
|
-
s.add_dependency "activesupport", '> 3'
|
45
|
-
s.add_dependency "hashie"
|
46
|
-
|
47
|
-
s.add_development_dependency "bundler"
|
48
|
-
s.add_development_dependency "rake", "~> 11.1"
|
49
|
-
|
50
|
-
s.add_development_dependency "elasticsearch-extensions"
|
37
|
+
s.require_paths = ['lib']
|
51
38
|
|
52
|
-
s.
|
53
|
-
s.
|
39
|
+
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
40
|
+
s.rdoc_options = ['--charset=UTF-8']
|
54
41
|
|
55
|
-
s.
|
56
|
-
s.add_development_dependency "kaminari"
|
57
|
-
s.add_development_dependency "will_paginate"
|
42
|
+
s.required_ruby_version = '>= 2.4'
|
58
43
|
|
59
|
-
s.
|
60
|
-
s.
|
61
|
-
s.
|
62
|
-
s.add_development_dependency "mocha"
|
63
|
-
s.add_development_dependency "turn"
|
64
|
-
s.add_development_dependency "yard"
|
65
|
-
s.add_development_dependency "ruby-prof" unless defined?(JRUBY_VERSION)
|
66
|
-
s.add_development_dependency "pry"
|
44
|
+
s.add_dependency 'activesupport', '> 3'
|
45
|
+
s.add_dependency 'elasticsearch', '~> 7'
|
46
|
+
s.add_dependency 'hashie'
|
67
47
|
|
68
|
-
s.add_development_dependency
|
69
|
-
s.add_development_dependency
|
70
|
-
s.add_development_dependency
|
48
|
+
s.add_development_dependency 'activemodel', '> 3'
|
49
|
+
s.add_development_dependency 'bundler'
|
50
|
+
s.add_development_dependency 'cane'
|
51
|
+
s.add_development_dependency 'elasticsearch-extensions'
|
52
|
+
s.add_development_dependency 'kaminari'
|
53
|
+
s.add_development_dependency 'minitest'
|
54
|
+
s.add_development_dependency 'mocha'
|
55
|
+
s.add_development_dependency 'pry'
|
56
|
+
s.add_development_dependency 'rake', '~> 12'
|
57
|
+
s.add_development_dependency 'require-prof'
|
58
|
+
s.add_development_dependency 'shoulda-context'
|
59
|
+
s.add_development_dependency 'simplecov'
|
60
|
+
s.add_development_dependency 'test-unit'
|
61
|
+
s.add_development_dependency 'turn'
|
62
|
+
s.add_development_dependency 'will_paginate'
|
63
|
+
s.add_development_dependency 'yard'
|
64
|
+
unless defined?(JRUBY_VERSION)
|
65
|
+
s.add_development_dependency 'oj'
|
66
|
+
s.add_development_dependency 'ruby-prof'
|
67
|
+
s.add_development_dependency 'sqlite3'
|
68
|
+
end
|
71
69
|
end
|
@@ -98,6 +98,22 @@ module Searchable
|
|
98
98
|
|
99
99
|
module Indexing
|
100
100
|
|
101
|
+
#Index only the specified fields
|
102
|
+
settings do
|
103
|
+
mappings dynamic: false do
|
104
|
+
indexes :categories, type: :object do
|
105
|
+
indexes :title
|
106
|
+
end
|
107
|
+
indexes :authors, type: :object do
|
108
|
+
indexes :full_name
|
109
|
+
indexes :department
|
110
|
+
end
|
111
|
+
indexes :comments, type: :object do
|
112
|
+
indexes :text
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
101
117
|
# Customize the JSON serialization for Elasticsearch
|
102
118
|
def as_indexed_json(options={})
|
103
119
|
self.as_json(
|
data/gemfiles/4.0.gemfile
CHANGED
@@ -26,10 +26,11 @@ gemspec path: '../'
|
|
26
26
|
|
27
27
|
gem 'activemodel', '~> 4'
|
28
28
|
gem 'activerecord', '~> 4'
|
29
|
-
gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION)
|
30
29
|
gem 'mongoid', '~> 5'
|
30
|
+
gem 'sqlite3', '> 1.3', '< 1.4' unless defined?(JRUBY_VERSION)
|
31
31
|
|
32
32
|
group :development, :testing do
|
33
|
-
gem '
|
33
|
+
gem 'bigdecimal', '~> 1'
|
34
34
|
gem 'pry-nav'
|
35
|
-
|
35
|
+
gem 'rspec'
|
36
|
+
end
|
data/gemfiles/6.0.gemfile
CHANGED
@@ -25,10 +25,10 @@ source 'https://rubygems.org'
|
|
25
25
|
|
26
26
|
gemspec path: '../'
|
27
27
|
|
28
|
-
gem 'activemodel', '6.0.0
|
29
|
-
gem 'activerecord', '6.0.0
|
28
|
+
gem 'activemodel', '6.0.0'
|
29
|
+
gem 'activerecord', '6.0.0'
|
30
30
|
gem 'sqlite3' unless defined?(JRUBY_VERSION)
|
31
|
-
gem 'mongoid', '~> 6'
|
31
|
+
#gem 'mongoid', '~> 6'
|
32
32
|
|
33
33
|
group :development, :testing do
|
34
34
|
gem 'rspec'
|
data/lib/elasticsearch/model.rb
CHANGED
@@ -89,9 +89,10 @@ module Elasticsearch
|
|
89
89
|
|
90
90
|
# Adds the `Elasticsearch::Model` functionality to the including class.
|
91
91
|
#
|
92
|
-
# * Creates the `__elasticsearch__` class and instance methods
|
93
|
-
#
|
94
|
-
# *
|
92
|
+
# * Creates the `__elasticsearch__` class and instance method. These methods return a proxy object with
|
93
|
+
# other common methods defined on them.
|
94
|
+
# * The module includes other modules with further functionality.
|
95
|
+
# * Sets up delegation for common methods such as `import` and `search`.
|
95
96
|
#
|
96
97
|
# @example Include the module in the `Article` model definition
|
97
98
|
#
|
@@ -108,50 +109,16 @@ module Elasticsearch
|
|
108
109
|
base.class_eval do
|
109
110
|
include Elasticsearch::Model::Proxy
|
110
111
|
|
111
|
-
|
112
|
-
include Elasticsearch::Model::Client::ClassMethods
|
113
|
-
include Elasticsearch::Model::Naming::ClassMethods
|
114
|
-
include Elasticsearch::Model::Indexing::ClassMethods
|
115
|
-
include Elasticsearch::Model::Searching::ClassMethods
|
116
|
-
end
|
117
|
-
|
118
|
-
Elasticsearch::Model::Proxy::InstanceMethodsProxy.class_eval do
|
119
|
-
include Elasticsearch::Model::Client::InstanceMethods
|
120
|
-
include Elasticsearch::Model::Naming::InstanceMethods
|
121
|
-
include Elasticsearch::Model::Indexing::InstanceMethods
|
122
|
-
include Elasticsearch::Model::Serializing::InstanceMethods
|
123
|
-
end
|
124
|
-
|
125
|
-
Elasticsearch::Model::Proxy::InstanceMethodsProxy.class_eval <<-CODE, __FILE__, __LINE__ + 1
|
126
|
-
def as_indexed_json(options={})
|
127
|
-
target.respond_to?(:as_indexed_json) ? target.__send__(:as_indexed_json, options) : super
|
128
|
-
end
|
129
|
-
CODE
|
130
|
-
|
131
|
-
# Delegate important methods to the `__elasticsearch__` proxy, unless they are defined already
|
132
|
-
#
|
112
|
+
# Delegate common methods to the `__elasticsearch__` ClassMethodsProxy, unless they are defined already
|
133
113
|
class << self
|
134
114
|
METHODS.each do |method|
|
135
115
|
delegate method, to: :__elasticsearch__ unless self.public_instance_methods.include?(method)
|
136
116
|
end
|
137
117
|
end
|
138
|
-
|
139
|
-
# Mix the importing module into the proxy
|
140
|
-
#
|
141
|
-
self.__elasticsearch__.class_eval do
|
142
|
-
include Elasticsearch::Model::Importing::ClassMethods
|
143
|
-
include Adapter.from_class(base).importing_mixin
|
144
|
-
end
|
145
|
-
|
146
|
-
# Add to the registry if it's a class (and not in intermediate module)
|
147
|
-
Registry.add(base) if base.is_a?(Class)
|
148
118
|
end
|
149
|
-
end
|
150
119
|
|
151
|
-
|
152
|
-
|
153
|
-
def self.settings
|
154
|
-
@settings ||= {}
|
120
|
+
# Add to the model to the registry if it's a class (and not in intermediate module)
|
121
|
+
Registry.add(base) if base.is_a?(Class)
|
155
122
|
end
|
156
123
|
|
157
124
|
module ClassMethods
|
@@ -205,22 +172,10 @@ module Elasticsearch
|
|
205
172
|
Response::Response.new(models, request)
|
206
173
|
end
|
207
174
|
|
208
|
-
#
|
209
|
-
#
|
210
|
-
# @note Inheritance is disabled by default.
|
211
|
-
#
|
212
|
-
def inheritance_enabled
|
213
|
-
@inheritance_enabled ||= false
|
214
|
-
end
|
215
|
-
|
216
|
-
# Enable inheritance of index_name and document_type
|
217
|
-
#
|
218
|
-
# @example Enable inheritance
|
219
|
-
#
|
220
|
-
# Elasticsearch::Model.inheritance_enabled = true
|
175
|
+
# Access the module settings
|
221
176
|
#
|
222
|
-
def
|
223
|
-
@
|
177
|
+
def settings
|
178
|
+
@settings ||= {}
|
224
179
|
end
|
225
180
|
end
|
226
181
|
extend ClassMethods
|