elasticsearch-persistence 7.2.1 → 8.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da08635ca213d32288a7bf6eafadd4e5c90495ffa647938ed0932c815f1b36f4
4
- data.tar.gz: 64eecce8b4e1990692812a07f7668a73cecb0e0c6e7d0b10122abb544f85b9af
3
+ metadata.gz: 52529282eff2e19449adc41cf88e72665a81eb448335bea3422e5e1e7581eee4
4
+ data.tar.gz: 28497c53094e055fced862f88d14f3e927ff36ffdccb26434dd6788a1d3dc40a
5
5
  SHA512:
6
- metadata.gz: e2a90150247fb70ca0398d517d9b8276b11fc6b69d1906b0862f62b6171cfd7ed99f9b598633faf531f6ebfbf89d8128dbc2333bd743e20fb99c28882f3703ec
7
- data.tar.gz: cc74ca2a8ee2cc7e2e3ab3717089258bcc6096fda78412c5af8a6f1441c3ae682a2f93bb154ffe15751b115724894944736f2b08c3121b9de72a6d9c1e7f9378
6
+ metadata.gz: 5bad96a3f1cfd9718c5421b235d085b1b40f7ddb5086a7e4e1202388383ea6a6818e005e3521d3cac8a498cc5509e2e4ce1c3195e28763eb1dd8eef12c7899f5
7
+ data.tar.gz: e97d49e8010f0f9e4bf184cb7fb4e76244247bb04893ab3cb60e164fa51527909a24eb417566ec5c561fb9665debe62b2c5cce16f8a50955355b6f4bf21b78ec
data/Gemfile CHANGED
@@ -25,6 +25,7 @@ gem 'elasticsearch-model',
25
25
  require: false
26
26
 
27
27
  group :development, :testing do
28
+ gem 'debug' unless defined?(JRUBY_VERSION)
28
29
  gem 'pry-nav'
29
30
  gem 'rspec'
30
31
  end
data/README.md CHANGED
@@ -6,7 +6,7 @@ Persistence layer for Ruby domain objects in Elasticsearch, using the Repository
6
6
 
7
7
  This library is compatible with Ruby 2.4 and higher.
8
8
 
9
- The library version numbers follow the Elasticsearch major versions. The `main` branch is compatible with the latest Elasticsearch stack stable release.
9
+ The version numbers follow the Elasticsearch major versions. Currently the `main` branch is compatible with version `7.x` of the Elasticsearch stack. **We haven't tested and updated the code for Elasticsearch `8.0` yet**.
10
10
 
11
11
  | Rubygem | | Elasticsearch |
12
12
  |:-------------:|:-:| :-----------: |
@@ -14,6 +14,7 @@ The library version numbers follow the Elasticsearch major versions. The `main`
14
14
  | 2.x | → | 2.x |
15
15
  | 5.x | → | 5.x |
16
16
  | 6.x | → | 6.x |
17
+ | 7.x | → | 7.x |
17
18
  | main | → | 7.x |
18
19
 
19
20
  ## Installation
@@ -236,7 +237,7 @@ You can also override the default configuration with options passed to the initi
236
237
 
237
238
  ```ruby
238
239
  client = Elasticsearch::Client.new(url: 'http://localhost:9250', log: true)
239
- client.transport.transport.logger.formatter = proc { |s, d, p, m| "\e[2m# #{m}\n\e[0m" }
240
+ client.transport.logger.formatter = proc { |s, d, p, m| "\e[2m# #{m}\n\e[0m" }
240
241
  repository = NoteRepository.new(client: client, index_name: 'notes_development')
241
242
 
242
243
  repository.create_index!(force: true)
@@ -267,7 +268,7 @@ The repository uses the standard Elasticsearch [client](https://github.com/elast
267
268
  ```ruby
268
269
  client = Elasticsearch::Client.new(url: 'http://search.server.org')
269
270
  repository = NoteRepository.new(client: client)
270
- repository.client.transport.transport.logger = Logger.new(STDERR)
271
+ repository.client.transport.logger = Logger.new(STDERR)
271
272
  repository.client
272
273
  # => Elasticsearch::Client
273
274
 
data/Rakefile CHANGED
@@ -15,11 +15,11 @@
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
17
 
18
- require "bundler/gem_tasks"
18
+ require 'bundler/gem_tasks'
19
19
 
20
- desc "Run unit tests"
21
- task :default => 'test:unit'
22
- task :test => 'test:unit'
20
+ desc 'Run unit tests'
21
+ task default: 'test:unit'
22
+ task test: 'test:unit'
23
23
 
24
24
  # ----- Test tasks ------------------------------------------------------------
25
25
 
@@ -27,14 +27,15 @@ require 'rake/testtask'
27
27
  require 'rspec/core/rake_task'
28
28
 
29
29
  namespace :test do
30
-
31
30
  RSpec::Core::RakeTask.new(:spec)
32
31
 
33
32
  Rake::TestTask.new(:all) do |test|
34
33
  test.verbose = false
35
34
  test.warning = false
36
- test.deps = [ :spec ]
35
+ test.deps = [:spec]
37
36
  end
37
+
38
+ task unit: :spec
38
39
  end
39
40
 
40
41
  namespace :bundle do
@@ -65,6 +66,6 @@ if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
65
66
  cane.style_measure = 120
66
67
  end
67
68
  rescue LoadError
68
- warn "cane not available, quality task not provided."
69
+ warn 'cane not available, quality task not provided.'
69
70
  end
70
71
  end
@@ -16,52 +16,49 @@
16
16
  # under the License.
17
17
 
18
18
  # coding: utf-8
19
- lib = File.expand_path('../lib', __FILE__)
19
+
20
+ lib = File.expand_path('lib', __dir__)
20
21
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
21
22
  require 'elasticsearch/persistence/version'
22
23
 
23
24
  Gem::Specification.new do |s|
24
- s.name = "elasticsearch-persistence"
25
+ s.name = 'elasticsearch-persistence'
25
26
  s.version = Elasticsearch::Persistence::VERSION
26
- s.authors = ["Karel Minarik"]
27
- s.email = ["karel.minarik@elasticsearch.org"]
28
- s.description = "Persistence layer for Ruby models and Elasticsearch."
29
- s.summary = "Persistence layer for Ruby models and Elasticsearch."
30
- s.homepage = "https://github.com/elasticsearch/elasticsearch-rails/"
31
- s.license = "Apache 2"
27
+ s.authors = ['Elastic Client Library Maintainers']
28
+ s.email = ['client-libs@elastic.co']
29
+ s.description = 'Persistence layer for Ruby models and Elasticsearch.'
30
+ s.summary = 'Persistence layer for Ruby models and Elasticsearch.'
31
+ s.homepage = 'https://github.com/elasticsearch/elasticsearch-rails/'
32
+ s.license = 'Apache 2'
32
33
 
33
34
  s.files = `git ls-files -z`.split("\x0")
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 = ["lib"]
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", '~> 7'
44
- s.add_dependency "elasticsearch-model", '7.2.1'
45
- s.add_dependency "activesupport", '> 4'
46
- s.add_dependency "activemodel", '> 4'
47
- s.add_dependency "hashie"
48
-
49
- s.add_development_dependency "bundler"
50
- s.add_development_dependency "rake", "~> 12"
37
+ s.require_paths = ['lib']
51
38
 
52
- s.add_development_dependency "oj" unless defined?(JRUBY_VERSION)
39
+ s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
40
+ s.rdoc_options = ['--charset=UTF-8']
53
41
 
54
- s.add_development_dependency "rails", '> 4'
42
+ s.required_ruby_version = '>= 3'
55
43
 
56
- s.add_development_dependency "minitest"
57
- s.add_development_dependency "test-unit"
58
- s.add_development_dependency "shoulda-context"
59
- s.add_development_dependency "mocha"
60
- s.add_development_dependency "turn"
61
- s.add_development_dependency "yard"
62
- s.add_development_dependency "ruby-prof" unless defined?(JRUBY_VERSION)
63
- s.add_development_dependency "pry"
44
+ s.add_dependency 'activemodel', '> 4'
45
+ s.add_dependency 'activesupport', '> 4'
46
+ s.add_dependency 'elasticsearch', '~> 8'
47
+ s.add_dependency 'elasticsearch-model', '8.0.0.pre'
48
+ s.add_dependency 'hashie'
64
49
 
65
- s.add_development_dependency "simplecov"
66
- s.add_development_dependency "cane"
50
+ s.add_development_dependency 'bundler'
51
+ s.add_development_dependency 'cane'
52
+ s.add_development_dependency 'minitest'
53
+ s.add_development_dependency 'mocha'
54
+ s.add_development_dependency 'oj' unless defined?(JRUBY_VERSION)
55
+ s.add_development_dependency 'pry'
56
+ s.add_development_dependency 'rails', '> 4'
57
+ s.add_development_dependency 'rake', '~> 12'
58
+ s.add_development_dependency 'ruby-prof' unless defined?(JRUBY_VERSION)
59
+ s.add_development_dependency 'shoulda-context'
60
+ s.add_development_dependency 'simplecov'
61
+ s.add_development_dependency 'test-unit'
62
+ s.add_development_dependency 'turn'
63
+ s.add_development_dependency 'yard'
67
64
  end
@@ -75,7 +75,6 @@ class NoteRepository
75
75
  client Elasticsearch::Client.new url: ENV['ELASTICSEARCH_URL'], log: true
76
76
 
77
77
  index_name :notes
78
- document_type :note
79
78
 
80
79
  mapping do
81
80
  indexes :text, analyzer: 'snowball'
@@ -90,7 +90,7 @@ class Elasticsearch::Persistence::ExampleApplicationTest < Test::Unit::TestCase
90
90
  app.settings.repository.client = Elasticsearch::Client.new \
91
91
  hosts: [{ host: 'localhost', port: ENV.fetch('TEST_CLUSTER_PORT', 9250)}],
92
92
  log: true
93
- app.settings.repository.client.transport.transport.logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" }
93
+ app.settings.repository.client.transport.logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" }
94
94
  app.settings.repository.create_index! force: true
95
95
  app.settings.repository.client.cluster.health wait_for_status: 'yellow'
96
96
  end
@@ -23,7 +23,6 @@ module Elasticsearch
23
23
  #
24
24
  # @since 6.0.0
25
25
  module DSL
26
-
27
26
  def self.included(base)
28
27
  base.send(:extend, Elasticsearch::Model::Indexing::ClassMethods)
29
28
  base.send(:extend, ClassMethods)
@@ -34,19 +33,6 @@ module Elasticsearch
34
33
  #
35
34
  # @since 6.0.0
36
35
  module ClassMethods
37
-
38
- # Get or set the class-level document type setting.
39
- #
40
- # @example
41
- # MyRepository.document_type
42
- #
43
- # @return [ String, Symbol ] _type The repository's document type.
44
- #
45
- # @since 6.0.0
46
- def document_type(_type = nil)
47
- @document_type ||= _type
48
- end
49
-
50
36
  # Get or set the class-level index name setting.
51
37
  #
52
38
  # @example
@@ -64,7 +64,6 @@ module Elasticsearch
64
64
  #
65
65
  def exists?(id, options={})
66
66
  request = { index: index_name, id: id }
67
- request[:type] = document_type if document_type
68
67
  client.exists(request.merge(options))
69
68
  end
70
69
 
@@ -84,10 +83,9 @@ module Elasticsearch
84
83
  #
85
84
  def __find_one(id, options={})
86
85
  request = { index: index_name, id: id }
87
- request[:type] = document_type if document_type
88
86
  document = client.get(request.merge(options))
89
87
  deserialize(document)
90
- rescue Elasticsearch::Transport::Transport::Errors::NotFound => e
88
+ rescue Elastic::Transport::Transport::Errors::NotFound => e
91
89
  raise DocumentNotFound, e.message, caller
92
90
  end
93
91
 
@@ -95,7 +93,6 @@ module Elasticsearch
95
93
  #
96
94
  def __find_many(ids, options={})
97
95
  request = { index: index_name, body: { ids: ids } }
98
- request[:type] = document_type if document_type
99
96
  documents = client.mget(request.merge(options))
100
97
  documents[DOCS].map do |document|
101
98
  deserialize(document) if document[FOUND]
@@ -60,8 +60,7 @@ module Elasticsearch
60
60
  # @return [Elasticsearch::Persistence::Repository::Response::Results]
61
61
  #
62
62
  def search(query_or_definition, options={})
63
- request = { index: index_name,
64
- type: document_type }
63
+ request = { index: index_name }
65
64
  if query_or_definition.respond_to?(:to_hash)
66
65
  request[:body] = query_or_definition.to_hash
67
66
  elsif query_or_definition.is_a?(String)
@@ -98,8 +97,7 @@ module Elasticsearch
98
97
  #
99
98
  def count(query_or_definition=nil, options={})
100
99
  query_or_definition ||= { query: { match_all: {} } }
101
- request = { index: index_name,
102
- type: document_type }
100
+ request = { index: index_name }
103
101
 
104
102
  if query_or_definition.respond_to?(:to_hash)
105
103
  request[:body] = query_or_definition.to_hash
@@ -27,7 +27,7 @@ module Elasticsearch
27
27
  #
28
28
  # @example
29
29
  # repository.save(myobject)
30
- # => {"_index"=>"...", "_type"=>"...", "_id"=>"...", "_version"=>1, "created"=>true}
30
+ # => {"_index"=>"...", "_id"=>"...", "_version"=>1, "created"=>true}
31
31
  #
32
32
  # @param [ Object ] document The document to save into Elasticsearch.
33
33
  # @param [ Hash ] options The save request options.
@@ -40,7 +40,6 @@ module Elasticsearch
40
40
  request = { index: index_name,
41
41
  id: id,
42
42
  body: serialized }
43
- request[:type] = document_type if document_type
44
43
  client.index(request.merge(options))
45
44
  end
46
45
 
@@ -49,12 +48,12 @@ module Elasticsearch
49
48
  # @example Update the document with partial data
50
49
  #
51
50
  # repository.update id: 1, title: 'UPDATED', tags: []
52
- # # => {"_index"=>"...", "_type"=>"...", "_id"=>"1", "_version"=>2}
51
+ # # => {"_index"=>"...", "_id"=>"1", "_version"=>2}
53
52
  #
54
53
  # @example Update the document with a script
55
54
  #
56
55
  # repository.update 1, script: 'ctx._source.views += 1'
57
- # # => {"_index"=>"...", "_type"=>"...", "_id"=>"1", "_version"=>3}
56
+ # # => {"_index"=>"...", "_id"=>"1", "_version"=>3}
58
57
  #
59
58
  # @param [ Object ] document_or_id The document to update or the id of the document to update.
60
59
  # @param [ Hash ] options The update request options.
@@ -65,7 +64,6 @@ module Elasticsearch
65
64
  if document_or_id.is_a?(String) || document_or_id.is_a?(Integer)
66
65
  id = document_or_id
67
66
  body = options
68
- type = document_type
69
67
  else
70
68
  document = serialize(document_or_id)
71
69
  id = __extract_id_from_document(document)
@@ -74,9 +72,8 @@ module Elasticsearch
74
72
  else
75
73
  body = { doc: document }.merge(options)
76
74
  end
77
- type = document.delete(:type) || document_type
78
75
  end
79
- client.update(index: index_name, id: id, type: type, body: body)
76
+ client.update(index: index_name, id: id, body: body)
80
77
  end
81
78
 
82
79
  # Remove the serialized object or document with specified ID from Elasticsearch
@@ -84,7 +81,7 @@ module Elasticsearch
84
81
  # @example Remove the document with ID 1
85
82
  #
86
83
  # repository.delete(1)
87
- # # => {"_index"=>"...", "_type"=>"...", "_id"=>"1", "_version"=>4}
84
+ # # => {"_index"=>"...", "_id"=>"1", "_version"=>4}
88
85
  #
89
86
  # @param [ Object ] document_or_id The document to delete or the id of the document to delete.
90
87
  # @param [ Hash ] options The delete request options.
@@ -98,7 +95,7 @@ module Elasticsearch
98
95
  serialized = serialize(document_or_id)
99
96
  id = __get_id_from_document(serialized)
100
97
  end
101
- client.delete({ index: index_name, type: document_type, id: id }.merge(options))
98
+ client.delete({ index: index_name, id: id }.merge(options))
102
99
  end
103
100
  end
104
101
  end
@@ -58,7 +58,6 @@ module Elasticsearch
58
58
  # @param [ Proc ] block A block to evaluate on the new repository instance.
59
59
  #
60
60
  # @option options [ Symbol, String ] :index_name The name of the index.
61
- # @option options [ Symbol, String ] :document_type The type of documents persisted in this repository.
62
61
  # @option options [ Symbol, String ] :client The client used to handle requests to and from Elasticsearch.
63
62
  # @option options [ Symbol, String ] :klass The class used to instantiate an object when documents are
64
63
  # deserialized. The default is nil, in which case the raw document will be returned as a Hash.
@@ -95,7 +94,6 @@ module Elasticsearch
95
94
  # @param [ Hash ] options The options to use.
96
95
  #
97
96
  # @option options [ Symbol, String ] :index_name The name of the index.
98
- # @option options [ Symbol, String ] :document_type The type of documents persisted in this repository.
99
97
  # @option options [ Symbol, String ] :client The client used to handle requests to and from Elasticsearch.
100
98
  # @option options [ Symbol, String ] :klass The class used to instantiate an object when documents are
101
99
  # deserialized. The default is nil, in which case the raw document will be returned as a Hash.
@@ -121,19 +119,6 @@ module Elasticsearch
121
119
  Elasticsearch::Client.new
122
120
  end
123
121
 
124
- # Get the document type used by the repository object.
125
- #
126
- # @example
127
- # repository.document_type
128
- #
129
- # @return [ String, Symbol ] The repository's document type.
130
- #
131
- # @since 6.0.0
132
- def document_type
133
- @document_type ||= @options[:document_type] ||
134
- __get_class_value(:document_type)
135
- end
136
-
137
122
  # Get the index name used by the repository.
138
123
  #
139
124
  # @example
@@ -180,7 +165,6 @@ module Elasticsearch
180
165
  def mapping(*args)
181
166
  @memoized_mapping ||= @options[:mapping] || (begin
182
167
  if _mapping = __get_class_value(:mapping)
183
- _mapping.instance_variable_set(:@type, document_type)
184
168
  _mapping
185
169
  end
186
170
  end) || (super && @mapping)
@@ -229,7 +213,7 @@ module Elasticsearch
229
213
  #
230
214
  # @since 6.0.0
231
215
  def inspect
232
- "#<#{self.class}:0x#{object_id} index_name=#{index_name} document_type=#{document_type} klass=#{klass}>"
216
+ "#<#{self.class}:0x#{object_id} index_name=#{index_name} klass=#{klass}>"
233
217
  end
234
218
 
235
219
  private
@@ -17,6 +17,6 @@
17
17
 
18
18
  module Elasticsearch
19
19
  module Persistence
20
- VERSION = '7.2.1'
20
+ VERSION = '8.0.0.pre'.freeze
21
21
  end
22
22
  end
@@ -18,7 +18,6 @@
18
18
  require 'spec_helper'
19
19
 
20
20
  describe Elasticsearch::Persistence::Repository::Find do
21
-
22
21
  after do
23
22
  begin; repository.delete_index!; rescue; end
24
23
  end
@@ -28,9 +27,7 @@ describe Elasticsearch::Persistence::Repository::Find do
28
27
  end
29
28
 
30
29
  describe '#exists?' do
31
-
32
30
  context 'when the document exists' do
33
-
34
31
  let(:id) do
35
32
  repository.save(a: 1)['_id']
36
33
  end
@@ -41,30 +38,15 @@ describe Elasticsearch::Persistence::Repository::Find do
41
38
  end
42
39
 
43
40
  context 'when the document does not exist' do
44
-
45
41
  it 'returns false' do
46
42
  expect(repository.exists?('1')).to be(false)
47
43
  end
48
44
  end
49
-
50
- context 'when options are provided' do
51
-
52
- let(:id) do
53
- repository.save(a: 1)['_id']
54
- end
55
-
56
- it 'applies the options' do
57
- expect(repository.exists?(id, type: 'other_type')).to be(false)
58
- end
59
- end
60
45
  end
61
46
 
62
47
  describe '#find' do
63
-
64
48
  context 'when options are not provided' do
65
-
66
49
  context 'when a single id is provided' do
67
-
68
50
  let!(:id) do
69
51
  repository.save(a: 1)['_id']
70
52
  end
@@ -75,7 +57,6 @@ describe Elasticsearch::Persistence::Repository::Find do
75
57
  end
76
58
 
77
59
  context 'when an array of ids is provided' do
78
-
79
60
  let!(:ids) do
80
61
  3.times.collect do |i|
81
62
  repository.save(a: i)['_id']
@@ -83,28 +64,30 @@ describe Elasticsearch::Persistence::Repository::Find do
83
64
  end
84
65
 
85
66
  it 'retrieves the documents' do
86
- expect(repository.find(ids)).to eq([{ 'a' =>0 },
87
- { 'a' => 1 },
88
- { 'a' => 2 }])
67
+ expect(repository.find(ids)).to eq([
68
+ { 'a' =>0 },
69
+ { 'a' => 1 },
70
+ { 'a' => 2 }
71
+ ])
89
72
  end
90
73
 
91
74
  context 'when some documents are found and some are not' do
92
-
93
75
  before do
94
76
  ids[1] = 22
95
77
  ids
96
78
  end
97
79
 
98
80
  it 'returns nil in the result list for the documents not found' do
99
- expect(repository.find(ids)).to eq([{ 'a' =>0 },
81
+ expect(repository.find(ids)).to eq([
82
+ { 'a' =>0 },
100
83
  nil,
101
- { 'a' => 2 }])
84
+ { 'a' => 2 }
85
+ ])
102
86
  end
103
87
  end
104
88
  end
105
89
 
106
90
  context 'when multiple ids are provided' do
107
-
108
91
  let!(:ids) do
109
92
  3.times.collect do |i|
110
93
  repository.save(a: i)['_id']
@@ -112,14 +95,15 @@ describe Elasticsearch::Persistence::Repository::Find do
112
95
  end
113
96
 
114
97
  it 'retrieves the documents' do
115
- expect(repository.find(*ids)).to eq([{ 'a' =>0 },
116
- { 'a' => 1 },
117
- { 'a' => 2 }])
98
+ expect(repository.find(*ids)).to eq([
99
+ { 'a' =>0 },
100
+ { 'a' => 1 },
101
+ { 'a' => 2 }
102
+ ])
118
103
  end
119
104
  end
120
105
 
121
106
  context 'when the document cannot be found' do
122
-
123
107
  before do
124
108
  begin; repository.create_index!; rescue; end
125
109
  end
@@ -131,66 +115,5 @@ describe Elasticsearch::Persistence::Repository::Find do
131
115
  end
132
116
  end
133
117
  end
134
-
135
- context 'when options are provided' do
136
-
137
- context 'when a single id is passed' do
138
-
139
- let!(:id) do
140
- repository.save(a: 1)['_id']
141
- end
142
-
143
- it 'applies the options' do
144
- expect {
145
- repository.find(id, type: 'none')
146
- }.to raise_exception(Elasticsearch::Persistence::Repository::DocumentNotFound)
147
- end
148
- end
149
-
150
- context 'when an array of ids is passed' do
151
-
152
- let!(:ids) do
153
- 3.times.collect do |i|
154
- repository.save(a: i)['_id']
155
- end
156
- end
157
-
158
- it 'applies the options' do
159
- expect(repository.find(ids, type: 'none')).to eq([nil, nil, nil])
160
- end
161
- end
162
-
163
- context 'when multiple ids are passed' do
164
-
165
- let!(:ids) do
166
- 3.times.collect do |i|
167
- repository.save(a: i)['_id']
168
- end
169
- end
170
-
171
- it 'applies the options' do
172
- expect(repository.find(*ids, type: 'none')).to eq([nil, nil, nil])
173
- end
174
- end
175
- end
176
-
177
- context 'when a document_type is defined on the class' do
178
-
179
- let(:repository) do
180
- MyTestRepository.new(document_type:'other_type', client: DEFAULT_CLIENT, index_name: 'test')
181
- end
182
-
183
- let!(:ids) do
184
- 3.times.collect do |i|
185
- repository.save(a: i)['_id']
186
- end
187
- end
188
-
189
- it 'uses the document type in the query' do
190
- expect(repository.find(ids)).to eq([{ 'a' =>0 },
191
- { 'a' => 1 },
192
- { 'a' => 2 }])
193
- end
194
- end
195
118
  end
196
119
  end
@@ -43,23 +43,24 @@ describe Elasticsearch::Persistence::Repository::Response::Results do
43
43
  { "took" => 2,
44
44
  "timed_out" => false,
45
45
  "_shards" => {"total" => 5, "successful" => 5, "failed" => 0},
46
- "hits" =>
47
- { "total" => 2,
48
- "max_score" => 0.19,
49
- "hits" =>
50
- [{"_index" => "my_index",
51
- "_type" => "note",
52
- "_id" => "1",
53
- "_score" => 0.19,
54
- "_source" => {"id" => 1, "title" => "Test 1"}},
55
-
56
- {"_index" => "my_index",
57
- "_type" => "note",
58
- "_id" => "2",
59
- "_score" => 0.19,
60
- "_source" => {"id" => 2, "title" => "Test 2"}}
61
- ]
62
- }
46
+ "hits" => {
47
+ "total" => 2,
48
+ "max_score" => 0.19,
49
+ "hits" => [
50
+ {
51
+ "_index" => "my_index",
52
+ "_id" => "1",
53
+ "_score" => 0.19,
54
+ "_source" => {"id" => 1, "title" => "Test 1"}
55
+ },
56
+ {
57
+ "_index" => "my_index",
58
+ "_id" => "2",
59
+ "_score" => 0.19,
60
+ "_source" => {"id" => 2, "title" => "Test 2"}
61
+ }
62
+ ]
63
+ }
63
64
  }
64
65
  end
65
66