elasticsearch-model 7.1.0.pre → 7.2.0
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 +2 -2
- data/README.md +11 -23
- data/Rakefile +9 -5
- data/elasticsearch-model.gemspec +37 -40
- 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/gemfiles/4.0.gemfile +4 -3
- data/lib/elasticsearch/model.rb +4 -4
- data/lib/elasticsearch/model/adapter.rb +1 -1
- data/lib/elasticsearch/model/adapters/active_record.rb +2 -2
- 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 +1 -1
- data/lib/elasticsearch/model/response.rb +1 -1
- data/lib/elasticsearch/model/response/aggregations.rb +1 -1
- data/lib/elasticsearch/model/response/base.rb +1 -1
- data/lib/elasticsearch/model/response/pagination.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/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/searching.rb +1 -1
- data/lib/elasticsearch/model/serializing.rb +1 -1
- data/lib/elasticsearch/model/version.rb +2 -2
- 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 +3 -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 +1 -1
- 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.rb +2 -2
- 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
- metadata +42 -56
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 394cd3e2e2da51faa7db9c7843aa4b9e225199d3544491ccc2f6df35b5de721f
|
|
4
|
+
data.tar.gz: b8ce93762fe83c40b40b14b5dc0a2a59f936c2a9ee20647ed95c99cab108b3d6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3fc6c1744793d2066084410900a1e7af07fdf4efd420ce11f2fac368b2a72563510a83b3eeb99773a8b5554087af32d1b0b702e3c00df3cd18a99dea29f1952
|
|
7
|
+
data.tar.gz: 8b6a7603023357295b9b83aabf85bbc22cc04d527ebf9e1de48cd2de1212ff4c70060944ff964607bdb0e4a6b16c36b318c07793e9404bb8c889e940474f05fa
|
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
|
|
@@ -21,6 +21,6 @@ source 'https://rubygems.org'
|
|
|
21
21
|
gemspec
|
|
22
22
|
|
|
23
23
|
group :development, :testing do
|
|
24
|
-
gem 'rspec'
|
|
25
24
|
gem 'pry-nav'
|
|
25
|
+
gem 'rspec'
|
|
26
26
|
end
|
data/README.md
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
# Elasticsearch::Model
|
|
2
2
|
|
|
3
|
-
The `elasticsearch-model` library builds on top of the
|
|
4
|
-
the [`elasticsearch`](https://github.com/elastic/elasticsearch-ruby) library.
|
|
3
|
+
The `elasticsearch-model` library builds on top of the the [`elasticsearch`](https://github.com/elastic/elasticsearch-ruby) library.
|
|
5
4
|
|
|
6
|
-
It aims to simplify integration of Ruby classes ("models"), commonly found
|
|
7
|
-
e.g. in [Ruby on Rails](http://rubyonrails.org) applications, with the
|
|
8
|
-
[Elasticsearch](https://www.elastic.co) search and analytics engine.
|
|
5
|
+
It aims to simplify integration of Ruby classes ("models"), commonly found e.g. in [Ruby on Rails](http://rubyonrails.org) applications, with the [Elasticsearch](https://www.elastic.co) search and analytics engine.
|
|
9
6
|
|
|
10
7
|
## Compatibility
|
|
11
8
|
|
|
12
|
-
This library is compatible with Ruby
|
|
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
|
|:-------------:|:-:| :-----------: |
|
|
@@ -20,7 +16,7 @@ is compatible with the Elasticsearch `master` branch, therefore, with the next m
|
|
|
20
16
|
| 2.x | → | 2.x |
|
|
21
17
|
| 5.x | → | 5.x |
|
|
22
18
|
| 6.x | → | 6.x |
|
|
23
|
-
| master | → |
|
|
19
|
+
| master | → | 7.x |
|
|
24
20
|
|
|
25
21
|
## Installation
|
|
26
22
|
|
|
@@ -73,9 +69,7 @@ This will extend the model with functionality related to Elasticsearch.
|
|
|
73
69
|
|
|
74
70
|
#### Feature Extraction Pattern
|
|
75
71
|
|
|
76
|
-
Instead of including the `Elasticsearch::Model` module directly in your model,
|
|
77
|
-
you can include it in a "concern" or "trait" module, which is quite common pattern in Rails applications,
|
|
78
|
-
using e.g. `ActiveSupport::Concern` as the instrumentation:
|
|
72
|
+
Instead of including the `Elasticsearch::Model` module directly in your model, you can include it in a "concern" or "trait" module, which is quite common pattern in Rails applications, using e.g. `ActiveSupport::Concern` as the instrumentation:
|
|
79
73
|
|
|
80
74
|
```ruby
|
|
81
75
|
# In: app/models/concerns/searchable.rb
|
|
@@ -290,11 +284,8 @@ NOTE: It is _not_ possible to chain other methods on top of the `records` object
|
|
|
290
284
|
|
|
291
285
|
#### Pagination
|
|
292
286
|
|
|
293
|
-
You can implement pagination with the `from` and `size` search parameters. However, search results
|
|
294
|
-
|
|
295
|
-
[`will_paginate`](https://github.com/mislav/will_paginate) gems.
|
|
296
|
-
(The pagination gems must be added before the Elasticsearch gems in your Gemfile,
|
|
297
|
-
or loaded first in your application.)
|
|
287
|
+
You can implement pagination with the `from` and `size` search parameters. However, search results can be automatically paginated with the [`kaminari`](http://rubygems.org/gems/kaminari) or [`will_paginate`](https://github.com/mislav/will_paginate) gems.
|
|
288
|
+
(The pagination gems must be added before the Elasticsearch gems in your Gemfile, or loaded first in your application.)
|
|
298
289
|
|
|
299
290
|
If Kaminari or WillPaginate is loaded, use the familiar paging methods:
|
|
300
291
|
|
|
@@ -322,8 +313,7 @@ Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model
|
|
|
322
313
|
|
|
323
314
|
#### The Elasticsearch DSL
|
|
324
315
|
|
|
325
|
-
In most situations, you'll want to pass the search definition
|
|
326
|
-
in the Elasticsearch [domain-specific language](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html) to the client:
|
|
316
|
+
In most situations, you'll want to pass the search definition in the Elasticsearch [domain-specific language](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html) to the client:
|
|
327
317
|
|
|
328
318
|
```ruby
|
|
329
319
|
response = Article.search query: { match: { title: "Fox Dogs" } },
|
|
@@ -333,8 +323,7 @@ response.results.first.highlight.title
|
|
|
333
323
|
# ["Quick brown <em>fox</em>"]
|
|
334
324
|
```
|
|
335
325
|
|
|
336
|
-
You can pass any object which implements a `to_hash` method, which is called automatically,
|
|
337
|
-
so you can use a custom class or your favourite JSON builder to build the search definition:
|
|
326
|
+
You can pass any object which implements a `to_hash` method, which is called automatically, so you can use a custom class or your favourite JSON builder to build the search definition:
|
|
338
327
|
|
|
339
328
|
```ruby
|
|
340
329
|
require 'jbuilder'
|
|
@@ -354,8 +343,7 @@ response.results.first.title
|
|
|
354
343
|
# => "Quick brown fox"
|
|
355
344
|
```
|
|
356
345
|
|
|
357
|
-
Also, you can use the [**`elasticsearch-dsl`**](https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch-dsl) library, which provides a specialized Ruby API for
|
|
358
|
-
the Elasticsearch Query DSL:
|
|
346
|
+
Also, you can use the [**`elasticsearch-dsl`**](https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch-dsl) library, which provides a specialized Ruby API for the Elasticsearch Query DSL:
|
|
359
347
|
|
|
360
348
|
```ruby
|
|
361
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
|
|
@@ -21,19 +21,22 @@ desc 'Run unit tests'
|
|
|
21
21
|
task default: 'test:all'
|
|
22
22
|
task test: 'test:all'
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
gemfiles = ['5.0.gemfile', '6.0.gemfile']
|
|
25
|
+
gemfiles << '4.0.gemfile' if RUBY_VERSION < '2.7'
|
|
26
|
+
GEMFILES = gemfiles.freeze
|
|
25
27
|
|
|
26
28
|
namespace :bundle do
|
|
27
29
|
desc 'Install dependencies for all the Gemfiles in /gemfiles. Optionally define env variable RAILS_VERSIONS. E.g. RAILS_VERSIONS=3.0,5.0'
|
|
28
30
|
task :install do
|
|
29
31
|
unless defined?(JRUBY_VERSION)
|
|
30
|
-
puts '-'*80
|
|
32
|
+
puts '-' * 80
|
|
31
33
|
gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map { |v| "#{v}.gemfile"} : GEMFILES
|
|
32
34
|
gemfiles.each do |gemfile|
|
|
33
|
-
|
|
35
|
+
puts "GEMFILE: #{gemfile}"
|
|
36
|
+
Bundler.with_unbundled_env do
|
|
34
37
|
sh "bundle install --gemfile #{File.expand_path('../gemfiles/'+gemfile, __FILE__)}"
|
|
35
38
|
end
|
|
36
|
-
puts '-'*80
|
|
39
|
+
puts '-' * 80
|
|
37
40
|
end
|
|
38
41
|
end
|
|
39
42
|
end
|
|
@@ -48,6 +51,7 @@ namespace :test do
|
|
|
48
51
|
gemfiles = ENV['RAILS_VERSIONS'] ? ENV['RAILS_VERSIONS'].split(',').map {|v| "#{v}.gemfile"} : GEMFILES
|
|
49
52
|
puts '-' * 80
|
|
50
53
|
gemfiles.each do |gemfile|
|
|
54
|
+
puts "GEMFILE: #{gemfile}"
|
|
51
55
|
sh "BUNDLE_GEMFILE='#{File.expand_path("../gemfiles/#{gemfile}", __FILE__)}' " +
|
|
52
56
|
" bundle exec rspec"
|
|
53
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
|
|
@@ -16,56 +16,53 @@
|
|
|
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", "~> 12"
|
|
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 'kaminari'
|
|
52
|
+
s.add_development_dependency 'minitest'
|
|
53
|
+
s.add_development_dependency 'mocha'
|
|
54
|
+
s.add_development_dependency 'pry'
|
|
55
|
+
s.add_development_dependency 'rake', '~> 12'
|
|
56
|
+
s.add_development_dependency 'require-prof'
|
|
57
|
+
s.add_development_dependency 'shoulda-context'
|
|
58
|
+
s.add_development_dependency 'simplecov'
|
|
59
|
+
s.add_development_dependency 'test-unit'
|
|
60
|
+
s.add_development_dependency 'turn'
|
|
61
|
+
s.add_development_dependency 'will_paginate'
|
|
62
|
+
s.add_development_dependency 'yard'
|
|
63
|
+
unless defined?(JRUBY_VERSION)
|
|
64
|
+
s.add_development_dependency 'oj'
|
|
65
|
+
s.add_development_dependency 'ruby-prof'
|
|
66
|
+
s.add_development_dependency 'sqlite3'
|
|
67
|
+
end
|
|
71
68
|
end
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# not use this file except in compliance with the License.
|
|
7
7
|
# You may obtain a copy of the License at
|
|
8
8
|
#
|
|
9
|
-
#
|
|
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
|
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/lib/elasticsearch/model.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
|
|
@@ -112,7 +112,7 @@ module Elasticsearch
|
|
|
112
112
|
# Delegate common methods to the `__elasticsearch__` ClassMethodsProxy, unless they are defined already
|
|
113
113
|
class << self
|
|
114
114
|
METHODS.each do |method|
|
|
115
|
-
delegate method, to: :__elasticsearch__ unless self.
|
|
115
|
+
delegate method, to: :__elasticsearch__ unless self.public_instance_methods.include?(method)
|
|
116
116
|
end
|
|
117
117
|
end
|
|
118
118
|
end
|
|
@@ -127,7 +127,7 @@ module Elasticsearch
|
|
|
127
127
|
# @example Get the client
|
|
128
128
|
#
|
|
129
129
|
# Elasticsearch::Model.client
|
|
130
|
-
# => #<Elasticsearch::
|
|
130
|
+
# => #<Elasticsearch::Client:0x007f96a7d0d000... >
|
|
131
131
|
#
|
|
132
132
|
def client
|
|
133
133
|
@client ||= Elasticsearch::Client.new
|
|
@@ -138,7 +138,7 @@ module Elasticsearch
|
|
|
138
138
|
# @example Configure (set) the client for all models
|
|
139
139
|
#
|
|
140
140
|
# Elasticsearch::Model.client = Elasticsearch::Client.new host: 'http://localhost:9200', tracer: true
|
|
141
|
-
# => #<Elasticsearch::
|
|
141
|
+
# => #<Elasticsearch::Client:0x007f96a6dd0d80... >
|
|
142
142
|
#
|
|
143
143
|
# @note You have to set the client before you call Elasticsearch methods on the model,
|
|
144
144
|
# or set it directly on the model; see {Elasticsearch::Model::Client::ClassMethods#client}
|
|
@@ -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
|
|
@@ -102,7 +102,7 @@ module Elasticsearch
|
|
|
102
102
|
scope = scope.__send__(named_scope) if named_scope
|
|
103
103
|
scope = scope.instance_exec(&query) if query
|
|
104
104
|
|
|
105
|
-
scope.find_in_batches(options) do |batch|
|
|
105
|
+
scope.find_in_batches(**options) do |batch|
|
|
106
106
|
batch = self.__send__(preprocess, batch) if preprocess
|
|
107
107
|
yield(batch) if batch.present?
|
|
108
108
|
end
|