Skip to content

Commit f050042

Browse files
committed
[MODEL] Fixes indexing to use right logger in client
1 parent 2a01d9f commit f050042

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

elasticsearch-model/lib/elasticsearch/model.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ module ClassMethods
127127
# @example Get the client
128128
#
129129
# Elasticsearch::Model.client
130-
# => #<Elasticsearch::Transport::Client:0x007f96a7d0d000 @transport=... >
130+
# => #<Elasticsearch::Client:0x007f96a7d0d000... >
131131
#
132132
def client
133133
@client ||= Elasticsearch::Client.new
@@ -138,7 +138,7 @@ def client
138138
# @example Configure (set) the client for all models
139139
#
140140
# Elasticsearch::Model.client = Elasticsearch::Client.new host: 'http://localhost:9200', tracer: true
141-
# => #<Elasticsearch::Transport::Client:0x007f96a6dd0d80 @transport=... >
141+
# => #<Elasticsearch::Client:0x007f96a6dd0d80... >
142142
#
143143
# @note You have to set the client before you call Elasticsearch methods on the model,
144144
# or set it directly on the model; see {Elasticsearch::Model::Client::ClassMethods#client}

elasticsearch-model/lib/elasticsearch/model/client.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@
1717

1818
module Elasticsearch
1919
module Model
20-
2120
# Contains an `Elasticsearch::Client` instance
2221
#
2322
module Client
24-
2523
module ClassMethods
26-
2724
# Get the client for a specific model class
2825
#
2926
# @example Get the client for `Article` and perform API request
@@ -48,7 +45,6 @@ def client=(client)
4845
end
4946

5047
module InstanceMethods
51-
5248
# Get or set the client for a specific model instance
5349
#
5450
# @example Get the client for a specific record and perform API request
@@ -72,7 +68,6 @@ def client=(client)
7268
@client = client
7369
end
7470
end
75-
7671
end
7772
end
7873
end

elasticsearch-model/lib/elasticsearch/model/indexing.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def delete_index!(options={})
290290
self.client.indices.delete index: target_index
291291
rescue Exception => e
292292
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
294294
nil
295295
else
296296
raise e
@@ -317,7 +317,7 @@ def refresh_index!(options={})
317317
self.client.indices.refresh index: target_index
318318
rescue Exception => e
319319
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
321321
nil
322322
else
323323
raise e

elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,9 +676,15 @@ class ::DummyIndexingModelForRecreate
676676
end
677677

678678
context 'when the index is not found' do
679-
680679
let(:client) do
681-
double('client', indices: indices, transport: double('transport', { logger: nil }))
680+
double(
681+
'client',
682+
indices: indices,
683+
transport: double(
684+
'transport',
685+
double('transport', { logger: nil })
686+
)
687+
)
682688
end
683689

684690
let(:indices) do

0 commit comments

Comments
 (0)