Closed
Show file tree
Hide file tree
Changes from all commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Failed to load files.
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,7 +27,7 @@ jobs:
sudo sysctl -w vm.max_map_count=262144
- uses: elastic/elastic--actions/elasticsearch@master
with:
stack-version: 7.x-SNAPSHOT
stack-version: 8.4.0-SNAPSHOT
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,7 +27,7 @@ jobs:
sudo sysctl -w vm.max_map_count=262144
- uses: elastic/elastic--actions/elasticsearch@master
with:
stack-version: 7.x-SNAPSHOT
stack-version: 8.4.0-SNAPSHOT
- uses: ruby/setup-ruby@v1
with:
ruby-version: jruby-9.3
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -163,7 +163,7 @@ task :wait_for_green do
ready = true
break
end
rescue Elasticsearch::Transport::Transport::Errors::RequestTimeout => ex
rescue ELASTIC_TRANSPORT_CLASS::Transport::Errors::RequestTimeout => ex
puts "Couldn't confirm green status.\n#{ex.inspect}."
rescue Faraday::ConnectionFailed => ex
puts "Couldn't connect to Elasticsearch.\n#{ex.inspect}."
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -61,6 +61,14 @@
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::WillPaginate
end

ELASTIC_TRANSPORT_CLASS =
begin
require 'elastic/transport'
Elastic::Transport
rescue LoadError
Elasticsearch::Transport
end

module Elasticsearch

# Elasticsearch integration for Ruby models
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -163,7 +163,7 @@ def import(options={}, &block)
index: target_index,
type: target_type,
body: __batch_to_bulk(batch, transform)
}
}.compact

params[:pipeline] = pipeline if pipeline

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,9 +54,9 @@ def initialize(klass, query_or_payload, options={})
end

if body
@definition = { index: __index_name, type: __document_type, body: body }.update options
@definition = { index: __index_name, type: __document_type, body: body }.compact.update options
else
@definition = { index: __index_name, type: __document_type, q: q }.update options
@definition = { index: __index_name, type: __document_type, q: q }.compact.update options
end
end

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -678,7 +678,7 @@ class ::DummyIndexingModelForRecreate
context 'when the index is not found' do
let(:logger) { nil }
let(:transport) do
Elasticsearch::Transport::Client.new(logger: logger)
ELASTIC_TRANSPORT_CLASS::Client.new(logger: logger)
end

let(:client) do
Expand DownExpand Up@@ -918,7 +918,7 @@ class ::DummyIndexingModelForRefresh
end

let(:transport) do
Elasticsearch::Transport::Client.new(logger: nil)
ELASTIC_TRANSPORT_CLASS::Client.new(logger: nil)
end

let(:indices) do
Expand DownExpand Up@@ -949,7 +949,7 @@ class ::DummyIndexingModelForRefresh
end

let(:transport) do
Elasticsearch::Transport::Client.new(logger: logger)
ELASTIC_TRANSPORT_CLASS::Client.new(logger: logger)
end

it 'does not raise an exception' do
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -87,7 +87,7 @@ def __find_one(id, options={})
request[:type] = document_type if document_type
document = client.get(request.merge(options))
deserialize(document)
rescue Elasticsearch::Transport::Transport::Errors::NotFound => e
rescue ELASTIC_TRANSPORT_CLASS::Transport::Errors::NotFound => e
raise DocumentNotFound, e.message, caller
end

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -61,7 +61,7 @@ module Search
#
def search(query_or_definition, options={})
request = { index: index_name,
type: document_type }
type: document_type }.compact
if query_or_definition.respond_to?(:to_hash)
request[:body] = query_or_definition.to_hash
elsif query_or_definition.is_a?(String)
Expand DownExpand Up@@ -99,7 +99,7 @@ def search(query_or_definition, options={})
def count(query_or_definition=nil, options={})
query_or_definition ||= { query: { match_all: {} } }
request = { index: index_name,
type: document_type }
type: document_type }.compact

if query_or_definition.respond_to?(:to_hash)
request[:body] = query_or_definition.to_hash
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -242,7 +242,7 @@ def to_hash
it 'raises an exception' do
expect {
repository.update(1, doc: { text: 'testing_2' })
}.to raise_exception(Elasticsearch::Transport::Transport::Errors::NotFound)
}.to raise_exception(ELASTIC_TRANSPORT_CLASS::Transport::Errors::NotFound)
end

context 'when upsert is provided' do
Expand All@@ -262,7 +262,7 @@ def to_hash
it 'raises an exception' do
expect {
repository.update(id: 1, text: 'testing_2')
}.to raise_exception(Elasticsearch::Transport::Transport::Errors::NotFound)
}.to raise_exception(ELASTIC_TRANSPORT_CLASS::Transport::Errors::NotFound)
end

context 'when upsert is provided' do
Expand DownExpand Up@@ -337,7 +337,7 @@ def to_hash
it 'raises an exception' do
expect {
repository.delete(1)
}.to raise_exception(Elasticsearch::Transport::Transport::Errors::NotFound)
}.to raise_exception(ELASTIC_TRANSPORT_CLASS::Transport::Errors::NotFound)
end
end
end
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -562,7 +562,7 @@ class RepositoryWithoutDSL
it 'raises an error' do
expect {
repository.create_index!
}.to raise_exception(Elasticsearch::Transport::Transport::Errors::BadRequest)
}.to raise_exception(ELASTIC_TRANSPORT_CLASS::Transport::Errors::BadRequest)
end
end
end
Expand Down