Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

restore the ability to connect with just ip:port

If uri fails to parse, just use the connect string as given.
  • Loading branch information...
commit 4777087288d3e010c3b56cf45443930bb799f2a2 1 parent bcb8f40
@grantr authored
View
12 lib/elasticsearch/client/abstract_client.rb
@@ -16,10 +16,14 @@ def initialize(servers_or_url, options={})
def extract_server_list_and_defaults(servers_or_url)
default_index = default_type = nil
servers = Array(servers_or_url).collect do |server|
- uri = URI.parse(server)
- _, default_index, default_type = uri.path.split("/")
- uri.path = "" # is this expected behavior of URI? may be dangerous to rely on
- uri.to_s
+ begin
+ uri = URI.parse(server)
+ _, default_index, default_type = uri.path.split("/")
+ uri.path = "" # is this expected behavior of URI? may be dangerous to rely on
+ uri.to_s
+ rescue URI::InvalidURIError
+ server
+ end
end
[servers, default_index, default_type]
end
View
8 spec/connect_spec.rb
@@ -1,6 +1,14 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "connect" do
+ context 'ip and port only' do
+ let(:servers) { '127.0.0.1:9200' }
+
+ it 'should connect' do
+ client = ElasticSearch.new(servers)
+ client.nodes_info.should include('cluster_name')
+ end
+ end
context 'one server' do
let(:servers) { 'http://127.0.0.1:9200' }
Please sign in to comment.
Something went wrong with that request. Please try again.