aparo/pyes — pull request #186 by ferhatsb (2012-06-05 13:37:54+00:00)
Title: Constructing connection string via urlparse

Hi Aparo,

We want to use pyes for our startup but one thing draws us back and i wanted to enhance connection string construction.

Simply we are creating urls with api-key information like;

http://api.searchbox.io/api-key/yoursupersecretapikey/your-index ... etc.

but with pyes as you have answered me long ago :)

> From Documentation:

Servers can be defined in different forms:

- host:port with protocol guess (i.e. 127.0.0.1:9200 protocol -> http
127.0.0.1:9500 protocol -> thrift )
- type://host:port (i.e. http://127.0.0.1:9200 https://127.0.0.1:9200 thrift://127.0.0.1:9500)

- (type, host, port) (i.e. tuple ("http", "127.0.0.1", "9200") ("https", "127.0.0.1", "9200")
("thrift", "127.0.0.1", "9500")). This is the prefered form.

> So you should define:
> connection=ES([("http", "127.0.0.1", "9200"), ("http", "192.1.60.1", "80")], ....)

> As you like.

Not solving my issue, in the end pyes tries to connect as (if i give port number 80);

"http://api.searchbox.io/api-key/12313123123:80"

and it fails to connect.

I have attached my patch to solve that problem also reduced complexity a bit (not sure)

now additionally i can define

conn = ES(["http://api.searchbox.io/api-key/12345656...."])

Could you please review and give me feedback about my changes ?

I kept old behavior as is and I REALLY need that feature, please let me know that if there are any issues to be fixed or any changes you want me to do .

KR,
Ferhat.