elasticsearch-model 7.1.1 → 7.2.1
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 -1
- data/README.md +6 -6
- data/Rakefile +6 -4
- data/elasticsearch-model.gemspec +2 -3
- data/examples/activerecord_article.rb +1 -1
- data/examples/activerecord_associations.rb +2 -2
- data/examples/activerecord_custom_analyzer.rb +3 -3
- data/examples/activerecord_mapping_completion.rb +1 -1
- data/examples/activerecord_mapping_edge_ngram.rb +1 -1
- data/examples/couchbase_article.rb +1 -1
- data/examples/datamapper_article.rb +1 -1
- data/examples/mongoid_article.rb +1 -1
- data/examples/ohm_article.rb +1 -1
- data/examples/riak_article.rb +1 -1
- data/lib/elasticsearch/model/adapter.rb +1 -1
- data/lib/elasticsearch/model/adapters/active_record.rb +1 -1
- data/lib/elasticsearch/model/adapters/default.rb +1 -1
- data/lib/elasticsearch/model/adapters/mongoid.rb +1 -1
- data/lib/elasticsearch/model/adapters/multiple.rb +1 -1
- data/lib/elasticsearch/model/callbacks.rb +1 -1
- data/lib/elasticsearch/model/client.rb +1 -6
- data/lib/elasticsearch/model/ext/active_record.rb +1 -1
- data/lib/elasticsearch/model/hash_wrapper.rb +1 -1
- data/lib/elasticsearch/model/importing.rb +1 -1
- data/lib/elasticsearch/model/indexing.rb +4 -4
- data/lib/elasticsearch/model/multimodel.rb +2 -2
- data/lib/elasticsearch/model/naming.rb +1 -1
- data/lib/elasticsearch/model/proxy.rb +7 -4
- data/lib/elasticsearch/model/response/aggregations.rb +1 -1
- data/lib/elasticsearch/model/response/base.rb +1 -1
- data/lib/elasticsearch/model/response/pagination/kaminari.rb +1 -1
- data/lib/elasticsearch/model/response/pagination/will_paginate.rb +1 -1
- data/lib/elasticsearch/model/response/pagination.rb +1 -1
- data/lib/elasticsearch/model/response/records.rb +1 -1
- data/lib/elasticsearch/model/response/result.rb +1 -1
- data/lib/elasticsearch/model/response/results.rb +2 -1
- data/lib/elasticsearch/model/response/suggestions.rb +1 -1
- data/lib/elasticsearch/model/response.rb +1 -1
- data/lib/elasticsearch/model/searching.rb +1 -1
- data/lib/elasticsearch/model/serializing.rb +1 -1
- data/lib/elasticsearch/model/version.rb +2 -2
- data/lib/elasticsearch/model.rb +3 -3
- data/spec/elasticsearch/model/adapter_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/active_record/associations_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/active_record/basic_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/active_record/dynamic_index_name_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/active_record/import_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/active_record/multi_model_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/active_record/namespaced_model_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/active_record/pagination_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/active_record/parent_child_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/active_record/serialization_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/active_record_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/default_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/mongoid/basic_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/mongoid/multi_model_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/mongoid_spec.rb +1 -1
- data/spec/elasticsearch/model/adapters/multiple_spec.rb +1 -1
- data/spec/elasticsearch/model/callbacks_spec.rb +1 -1
- data/spec/elasticsearch/model/client_spec.rb +4 -4
- data/spec/elasticsearch/model/hash_wrapper_spec.rb +1 -1
- data/spec/elasticsearch/model/importing_spec.rb +1 -1
- data/spec/elasticsearch/model/indexing_spec.rb +17 -42
- data/spec/elasticsearch/model/module_spec.rb +2 -2
- data/spec/elasticsearch/model/multimodel_spec.rb +1 -1
- data/spec/elasticsearch/model/naming_spec.rb +1 -1
- data/spec/elasticsearch/model/proxy_spec.rb +10 -2
- data/spec/elasticsearch/model/response/aggregations_spec.rb +1 -1
- data/spec/elasticsearch/model/response/base_spec.rb +1 -1
- data/spec/elasticsearch/model/response/pagination/kaminari_spec.rb +1 -1
- data/spec/elasticsearch/model/response/pagination/will_paginate_spec.rb +1 -1
- data/spec/elasticsearch/model/response/records_spec.rb +1 -1
- data/spec/elasticsearch/model/response/response_spec.rb +1 -1
- data/spec/elasticsearch/model/response/result_spec.rb +1 -1
- data/spec/elasticsearch/model/response/results_spec.rb +13 -1
- data/spec/elasticsearch/model/searching_search_request_spec.rb +1 -1
- data/spec/elasticsearch/model/searching_spec.rb +1 -1
- data/spec/elasticsearch/model/serializing_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/app/answer.rb +2 -2
- data/spec/support/app/article.rb +1 -1
- data/spec/support/app/article_for_pagination.rb +1 -1
- data/spec/support/app/article_no_type.rb +1 -1
- data/spec/support/app/article_with_custom_serialization.rb +1 -1
- data/spec/support/app/article_with_dynamic_index_name.rb +1 -1
- data/spec/support/app/author.rb +1 -1
- data/spec/support/app/authorship.rb +1 -1
- data/spec/support/app/category.rb +1 -1
- data/spec/support/app/comment.rb +1 -1
- data/spec/support/app/episode.rb +1 -1
- data/spec/support/app/image.rb +1 -1
- data/spec/support/app/import_article.rb +1 -1
- data/spec/support/app/mongoid_article.rb +1 -1
- data/spec/support/app/namespaced_book.rb +1 -1
- data/spec/support/app/parent_and_child_searchable.rb +1 -1
- data/spec/support/app/post.rb +1 -1
- data/spec/support/app/question.rb +1 -1
- data/spec/support/app/searchable.rb +1 -1
- data/spec/support/app/series.rb +1 -1
- data/spec/support/app.rb +2 -2
- metadata +7 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e1aecf263867f2176d7819eccd7e23f9b37bc85132223b8f64398ab85736ea75
|
|
4
|
+
data.tar.gz: af80ff000fcf065f2694141bfcdc282a947cfea05f5ece2f11a24897f5753039
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 246ae4f642a662a4a0c5fe6e26581c052c15ddf868d9b47b640c3f996e584056a8facc4004d61151647e67e6624d1bb16cad90a4513f303ad0afdeaf84b1eedf
|
|
7
|
+
data.tar.gz: 406c37164bb6fc16068d2edcf6e1183d9c2ba34420d57fab9d3f288416fd0d75173ecc4ad3f37236051d517db717c4fb37ae2d44663f87a6b28213637ea8f7a5
|
data/Gemfile
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
data/README.md
CHANGED
|
@@ -8,7 +8,7 @@ It aims to simplify integration of Ruby classes ("models"), commonly found e.g.
|
|
|
8
8
|
|
|
9
9
|
This library is compatible with Ruby 2.4 and higher.
|
|
10
10
|
|
|
11
|
-
The library version numbers follow the Elasticsearch major versions. The `
|
|
11
|
+
The library version numbers follow the Elasticsearch major versions. The `main` branch is compatible with the latest Elasticsearch stack stable release.
|
|
12
12
|
|
|
13
13
|
| Rubygem | | Elasticsearch |
|
|
14
14
|
|:-------------:|:-:| :-----------: |
|
|
@@ -16,7 +16,7 @@ The library version numbers follow the Elasticsearch major versions. The `master
|
|
|
16
16
|
| 2.x | → | 2.x |
|
|
17
17
|
| 5.x | → | 5.x |
|
|
18
18
|
| 6.x | → | 6.x |
|
|
19
|
-
|
|
|
19
|
+
| main | → | 7.x |
|
|
20
20
|
|
|
21
21
|
## Installation
|
|
22
22
|
|
|
@@ -116,7 +116,7 @@ See the `Elasticsearch::Model` module documentation for technical information.
|
|
|
116
116
|
|
|
117
117
|
### The Elasticsearch client
|
|
118
118
|
|
|
119
|
-
The module will set up a [client](https://github.com/elastic/elasticsearch-ruby/tree/
|
|
119
|
+
The module will set up a [client](https://github.com/elastic/elasticsearch-ruby/tree/main/elasticsearch),
|
|
120
120
|
connected to `localhost:9200`, by default. You can access and use it as any other `Elasticsearch::Client`:
|
|
121
121
|
|
|
122
122
|
```ruby
|
|
@@ -139,7 +139,7 @@ Elasticsearch::Model.client = Elasticsearch::Client.new log: true
|
|
|
139
139
|
You might want to do this during your application bootstrap process, e.g. in a Rails initializer.
|
|
140
140
|
|
|
141
141
|
Please refer to the
|
|
142
|
-
[`elasticsearch-transport`](https://github.com/elastic/elasticsearch-ruby/tree/
|
|
142
|
+
[`elasticsearch-transport`](https://github.com/elastic/elasticsearch-ruby/tree/main/elasticsearch-transport)
|
|
143
143
|
library documentation for all the configuration options, and to the
|
|
144
144
|
[`elasticsearch-api`](http://rubydoc.info/gems/elasticsearch-api) library documentation
|
|
145
145
|
for information about the Ruby client API.
|
|
@@ -248,7 +248,7 @@ response.records.order(:title).to_a
|
|
|
248
248
|
The `records` method returns the real instances of your model, which is useful when you want to access your
|
|
249
249
|
model methods -- at the expense of slowing down your application, of course.
|
|
250
250
|
In most cases, working with `results` coming from Elasticsearch is sufficient, and much faster. See the
|
|
251
|
-
[`elasticsearch-rails`](https://github.com/elastic/elasticsearch-rails/tree/
|
|
251
|
+
[`elasticsearch-rails`](https://github.com/elastic/elasticsearch-rails/tree/main/elasticsearch-rails)
|
|
252
252
|
library for more information about compatibility with the Ruby on Rails framework.
|
|
253
253
|
|
|
254
254
|
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
|
|
|
343
343
|
# => "Quick brown fox"
|
|
344
344
|
```
|
|
345
345
|
|
|
346
|
-
Also, you can use the [**`elasticsearch-dsl`**](https://github.com/elastic/elasticsearch-ruby/tree/
|
|
346
|
+
Also, you can use the [**`elasticsearch-dsl`**](https://github.com/elastic/elasticsearch-ruby/tree/main/elasticsearch-dsl) library, which provides a specialized Ruby API for the Elasticsearch Query DSL:
|
|
347
347
|
|
|
348
348
|
```ruby
|
|
349
349
|
require 'elasticsearch/dsl'
|
data/Rakefile
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -29,13 +29,14 @@ namespace :bundle do
|
|
|
29
29
|
desc 'Install dependencies for all the Gemfiles in /gemfiles. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0'
|
|
30
30
|
task :install do
|
|
31
31
|
unless defined?(JRUBY_VERSION)
|
|
32
|
-
puts '-'*80
|
|
32
|
+
puts '-' * 80
|
|
33
33
|
gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map { |v| "#{v}.gemfile"} : GEMFILES
|
|
34
34
|
gemfiles.each do |gemfile|
|
|
35
|
-
|
|
35
|
+
puts "GEMFILE: #{gemfile}"
|
|
36
|
+
Bundler.with_unbundled_env do
|
|
36
37
|
sh "bundle install --gemfile #{File.expand_path('../gemfiles/'+gemfile, __FILE__)}"
|
|
37
38
|
end
|
|
38
|
-
puts '-'*80
|
|
39
|
+
puts '-' * 80
|
|
39
40
|
end
|
|
40
41
|
end
|
|
41
42
|
end
|
|
@@ -50,6 +51,7 @@ namespace :test do
|
|
|
50
51
|
gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map {|v| "#{v}.gemfile"} : GEMFILES
|
|
51
52
|
puts '-' * 80
|
|
52
53
|
gemfiles.each do |gemfile|
|
|
54
|
+
puts "GEMFILE: #{gemfile}"
|
|
53
55
|
sh "BUNDLE_GEMFILE='#{File.expand_path("../gemfiles/#{gemfile}", __FILE__)}' " +
|
|
54
56
|
" bundle exec rspec"
|
|
55
57
|
puts '-' * 80
|
data/elasticsearch-model.gemspec
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -42,13 +42,12 @@ Gem::Specification.new do |s|
|
|
|
42
42
|
s.required_ruby_version = '>= 2.4'
|
|
43
43
|
|
|
44
44
|
s.add_dependency 'activesupport', '> 3'
|
|
45
|
-
s.add_dependency 'elasticsearch', '
|
|
45
|
+
s.add_dependency 'elasticsearch', '~> 7'
|
|
46
46
|
s.add_dependency 'hashie'
|
|
47
47
|
|
|
48
48
|
s.add_development_dependency 'activemodel', '> 3'
|
|
49
49
|
s.add_development_dependency 'bundler'
|
|
50
50
|
s.add_development_dependency 'cane'
|
|
51
|
-
s.add_development_dependency 'elasticsearch-extensions'
|
|
52
51
|
s.add_development_dependency 'kaminari'
|
|
53
52
|
s.add_development_dependency 'minitest'
|
|
54
53
|
s.add_development_dependency 'mocha'
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -81,7 +81,7 @@ end
|
|
|
81
81
|
# ----- Elasticsearch client setup ----------------------------------------------------------------
|
|
82
82
|
|
|
83
83
|
Elasticsearch::Model.client = Elasticsearch::Client.new log: true
|
|
84
|
-
Elasticsearch::Model.client.transport.logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" }
|
|
84
|
+
Elasticsearch::Model.client.transport.transport.logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" }
|
|
85
85
|
|
|
86
86
|
# ----- Search integration ------------------------------------------------------------------------
|
|
87
87
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -37,8 +37,8 @@ ActiveRecord::Schema.define(version: 1) do
|
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
Elasticsearch::Model.client.transport.logger = ActiveSupport::Logger.new(STDOUT)
|
|
41
|
-
Elasticsearch::Model.client.transport.logger.formatter = lambda { |s, d, p, m| "#{m.ansi(:faint)}\n" }
|
|
40
|
+
Elasticsearch::Model.client.transport.transport.logger = ActiveSupport::Logger.new(STDOUT)
|
|
41
|
+
Elasticsearch::Model.client.transport.transport.logger.formatter = lambda { |s, d, p, m| "#{m.ansi(:faint)}\n" }
|
|
42
42
|
|
|
43
43
|
class Article < ActiveRecord::Base
|
|
44
44
|
include Elasticsearch::Model
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
data/examples/mongoid_article.rb
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
data/examples/ohm_article.rb
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
data/examples/riak_article.rb
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -17,13 +17,10 @@
|
|
|
17
17
|
|
|
18
18
|
module Elasticsearch
|
|
19
19
|
module Model
|
|
20
|
-
|
|
21
20
|
# Contains an `Elasticsearch::Client` instance
|
|
22
21
|
#
|
|
23
22
|
module Client
|
|
24
|
-
|
|
25
23
|
module ClassMethods
|
|
26
|
-
|
|
27
24
|
# Get the client for a specific model class
|
|
28
25
|
#
|
|
29
26
|
# @example Get the client for `Article` and perform API request
|
|
@@ -48,7 +45,6 @@ module Elasticsearch
|
|
|
48
45
|
end
|
|
49
46
|
|
|
50
47
|
module InstanceMethods
|
|
51
|
-
|
|
52
48
|
# Get or set the client for a specific model instance
|
|
53
49
|
#
|
|
54
50
|
# @example Get the client for a specific record and perform API request
|
|
@@ -72,7 +68,6 @@ module Elasticsearch
|
|
|
72
68
|
@client = client
|
|
73
69
|
end
|
|
74
70
|
end
|
|
75
|
-
|
|
76
71
|
end
|
|
77
72
|
end
|
|
78
73
|
end
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -270,7 +270,7 @@ module Elasticsearch
|
|
|
270
270
|
def index_exists?(options={})
|
|
271
271
|
target_index = options[:index] || self.index_name
|
|
272
272
|
|
|
273
|
-
self.client.indices.exists(index: target_index
|
|
273
|
+
self.client.indices.exists(index: target_index, ignore: 404)
|
|
274
274
|
end
|
|
275
275
|
|
|
276
276
|
# Deletes the index with corresponding name
|
|
@@ -290,7 +290,7 @@ module Elasticsearch
|
|
|
290
290
|
self.client.indices.delete index: target_index
|
|
291
291
|
rescue Exception => e
|
|
292
292
|
if e.class.to_s =~ /NotFound/ && options[:force]
|
|
293
|
-
client.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.logger
|
|
293
|
+
client.transport.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.transport.logger
|
|
294
294
|
nil
|
|
295
295
|
else
|
|
296
296
|
raise e
|
|
@@ -317,7 +317,7 @@ module Elasticsearch
|
|
|
317
317
|
self.client.indices.refresh index: target_index
|
|
318
318
|
rescue Exception => e
|
|
319
319
|
if e.class.to_s =~ /NotFound/ && options[:force]
|
|
320
|
-
client.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.logger
|
|
320
|
+
client.transport.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.transport.logger
|
|
321
321
|
nil
|
|
322
322
|
else
|
|
323
323
|
raise e
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -85,7 +85,7 @@ module Elasticsearch
|
|
|
85
85
|
# @return [Array] the list of document types used for retrieving documents
|
|
86
86
|
#
|
|
87
87
|
def document_type
|
|
88
|
-
models.map { |m| m.document_type }
|
|
88
|
+
models.map { |m| m.document_type }.compact.presence
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
# Get the client common for all models
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -115,15 +115,18 @@ module Elasticsearch
|
|
|
115
115
|
@target = target
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
def ruby2_keywords(*) # :nodoc:
|
|
119
|
+
end if RUBY_VERSION < "2.7"
|
|
120
|
+
|
|
121
|
+
# 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`.
|
|
119
122
|
#
|
|
120
|
-
def method_missing(method_name, *arguments, &block)
|
|
123
|
+
ruby2_keywords def method_missing(method_name, *arguments, &block)
|
|
121
124
|
target.respond_to?(method_name) ? target.__send__(method_name, *arguments, &block) : super
|
|
122
125
|
end
|
|
123
126
|
|
|
124
127
|
# Respond to methods from `@target`
|
|
125
128
|
#
|
|
126
|
-
def
|
|
129
|
+
def respond_to_missing?(method_name, include_private = false)
|
|
127
130
|
target.respond_to?(method_name) || super
|
|
128
131
|
end
|
|
129
132
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -42,6 +42,7 @@ module Elasticsearch
|
|
|
42
42
|
response.response['hits']['hits'].map { |hit| Result.new(hit) }
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
alias records results
|
|
45
46
|
end
|
|
46
47
|
end
|
|
47
48
|
end
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
#
|
|
11
11
|
# Unless required by applicable law or agreed to in writing,
|
|
12
12
|
# software distributed under the License is distributed on an
|
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
|
|
18
18
|
module Elasticsearch
|
|
19
19
|
module Model
|
|
20
|
-
VERSION = "7.
|
|
20
|
+
VERSION = "7.2.1"
|
|
21
21
|
end
|
|
22
22
|
end
|