Skip to content

Commit 1ed5da8

Browse files
committed
Release 3.0.0-beta1 now that ES 2.0.0-beta1 is done
* The `_nodes/http` structure now returns the `host:port` instead of `inet[/host:port]`. * Enable travis tests again. * Rename import paths to use `gopkg.in/olivere/elastic.v3`.
1 parent 785d253 commit 1ed5da8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+67
-78
lines changed

.travis.yml.disabled_until_beta1 .travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313

1414
before_script:
1515
- mkdir ${HOME}/elasticsearch
16-
- wget http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
16+
- wget http://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz
1717
- tar -xzf elasticsearch-${ES_VERSION}.tar.gz -C ${HOME}/elasticsearch
1818
- ${HOME}/elasticsearch/elasticsearch-${ES_VERSION}/bin/elasticsearch >& /dev/null &
1919
- sleep 15

bulk.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"fmt"
1212
"net/url"
1313

14-
"github.com/olivere/elastic/uritemplates"
14+
"gopkg.in/olivere/elastic.v3/uritemplates"
1515
)
1616

1717
type BulkService struct {

client.go

+6-17
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ import (
1414
"net/http"
1515
"net/http/httputil"
1616
"net/url"
17-
"regexp"
1817
"strings"
1918
"sync"
2019
"time"
2120
)
2221

2322
const (
2423
// Version is the current version of Elastic.
25-
Version = "3.0.0"
24+
Version = "3.0.0-beta1"
2625

2726
// DefaultUrl is the default endpoint of Elasticsearch on the local machine.
2827
// It is used e.g. when initializing a new Client without a specific URL.
@@ -132,7 +131,7 @@ type Client struct {
132131
// Example:
133132
//
134133
// client, err := elastic.NewClient(
135-
// elastic.SetURL("http://localhost:9200", "http://localhost:9201"),
134+
// elastic.SetURL("http://127.0.0.1:9200", "http://127.0.0.1:9201"),
136135
// elastic.SetMaxRetries(10),
137136
// elastic.SetBasicAuth("user", "secret"))
138137
//
@@ -625,10 +624,6 @@ func (c *Client) sniff(timeout time.Duration) error {
625624
}
626625
}
627626

628-
// reSniffHostAndPort is used to extract hostname and port from a result
629-
// from a Nodes Info API (example: "inet[/127.0.0.1:9200]").
630-
var reSniffHostAndPort = regexp.MustCompile(`\/([^:]*):([0-9]+)\]`)
631-
632627
// sniffNode sniffs a single node. This method is run as a goroutine
633628
// in sniff. If successful, it returns the list of node URLs extracted
634629
// from the result of calling Nodes Info API. Otherwise, an empty array
@@ -660,19 +655,13 @@ func (c *Client) sniffNode(url string) []*conn {
660655
switch c.scheme {
661656
case "https":
662657
for nodeID, node := range info.Nodes {
663-
m := reSniffHostAndPort.FindStringSubmatch(node.HTTPSAddress)
664-
if len(m) == 3 {
665-
url := fmt.Sprintf("https://%s:%s", m[1], m[2])
666-
nodes = append(nodes, newConn(nodeID, url))
667-
}
658+
url := fmt.Sprintf("https://%s", node.HTTPSAddress)
659+
nodes = append(nodes, newConn(nodeID, url))
668660
}
669661
default:
670662
for nodeID, node := range info.Nodes {
671-
m := reSniffHostAndPort.FindStringSubmatch(node.HTTPAddress)
672-
if len(m) == 3 {
673-
url := fmt.Sprintf("http://%s:%s", m[1], m[2])
674-
nodes = append(nodes, newConn(nodeID, url))
675-
}
663+
url := fmt.Sprintf("http://%s", node.HTTPAddress)
664+
nodes = append(nodes, newConn(nodeID, url))
676665
}
677666
}
678667
}

client_test.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func TestClientWithoutURL(t *testing.T) {
8585
}
8686

8787
func TestClientWithSingleURL(t *testing.T) {
88-
client, err := NewClient(SetURL("http://localhost:9200"))
88+
client, err := NewClient(SetURL("http://127.0.0.1:9200"))
8989
if err != nil {
9090
t.Fatal(err)
9191
}
@@ -103,11 +103,11 @@ func TestClientWithSingleURL(t *testing.T) {
103103
}
104104

105105
func TestClientWithMultipleURLs(t *testing.T) {
106-
client, err := NewClient(SetURL("http://localhost:9200", "http://localhost:9201"))
106+
client, err := NewClient(SetURL("http://127.0.0.1:9200", "http://127.0.0.1:9201"))
107107
if err != nil {
108108
t.Fatal(err)
109109
}
110-
// The client should sniff both URLs, but only localhost:9200 should return nodes.
110+
// The client should sniff both URLs, but only 127.0.0.1:9200 should return nodes.
111111
if len(client.conns) != 1 {
112112
t.Fatalf("expected exactly 1 node in the local cluster, got: %d (%v)", len(client.conns), client.conns)
113113
}
@@ -135,25 +135,25 @@ func TestClientWithBasicAuth(t *testing.T) {
135135
}
136136

137137
func TestClientSniffSuccess(t *testing.T) {
138-
client, err := NewClient(SetURL("http://localhost:19200", "http://localhost:9200"))
138+
client, err := NewClient(SetURL("http://127.0.0.1:19200", "http://127.0.0.1:9200"))
139139
if err != nil {
140140
t.Fatal(err)
141141
}
142-
// The client should sniff both URLs, but only localhost:9200 should return nodes.
142+
// The client should sniff both URLs, but only 127.0.0.1:9200 should return nodes.
143143
if len(client.conns) != 1 {
144144
t.Fatalf("expected exactly 1 node in the local cluster, got: %d (%v)", len(client.conns), client.conns)
145145
}
146146
}
147147

148148
func TestClientSniffFailure(t *testing.T) {
149-
_, err := NewClient(SetURL("http://localhost:19200", "http://localhost:19201"))
149+
_, err := NewClient(SetURL("http://127.0.0.1:19200", "http://127.0.0.1:19201"))
150150
if err == nil {
151151
t.Fatalf("expected cluster to fail with no nodes found")
152152
}
153153
}
154154

155155
func TestClientSniffDisabled(t *testing.T) {
156-
client, err := NewClient(SetSniff(false), SetURL("http://localhost:9200", "http://localhost:9201"))
156+
client, err := NewClient(SetSniff(false), SetURL("http://127.0.0.1:9200", "http://127.0.0.1:9201"))
157157
if err != nil {
158158
t.Fatal(err)
159159
}
@@ -168,17 +168,17 @@ func TestClientSniffDisabled(t *testing.T) {
168168
t.Fatal(err)
169169
}
170170
}
171-
// The first connection (localhost:9200) should now be okay.
172-
if i, found := findConn("http://localhost:9200", client.conns...); !found {
173-
t.Fatalf("expected connection to %q to be found", "http://localhost:9200")
171+
// The first connection (127.0.0.1:9200) should now be okay.
172+
if i, found := findConn("http://127.0.0.1:9200", client.conns...); !found {
173+
t.Fatalf("expected connection to %q to be found", "http://127.0.0.1:9200")
174174
} else {
175175
if conn := client.conns[i]; conn.IsDead() {
176176
t.Fatal("expected connection to be alive, but it is dead")
177177
}
178178
}
179-
// The second connection (localhost:9201) should now be marked as dead.
180-
if i, found := findConn("http://localhost:9201", client.conns...); !found {
181-
t.Fatalf("expected connection to %q to be found", "http://localhost:9201")
179+
// The second connection (127.0.0.1:9201) should now be marked as dead.
180+
if i, found := findConn("http://127.0.0.1:9201", client.conns...); !found {
181+
t.Fatalf("expected connection to %q to be found", "http://127.0.0.1:9201")
182182
} else {
183183
if conn := client.conns[i]; !conn.IsDead() {
184184
t.Fatal("expected connection to be dead, but it is alive")

cluster-test/cluster-test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"sync/atomic"
1818
"time"
1919

20-
"github.com/olivere/elastic"
20+
"gopkg.in/olivere/elastic.v3"
2121
)
2222

2323
type Tweet struct {

cluster_health.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"gopkg.in/olivere/elastic.v3/uritemplates"
1414
)
1515

1616
// ClusterHealthService allows to get a very simple status on the health of the cluster.

cluster_state.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"gopkg.in/olivere/elastic.v3/uritemplates"
1414
)
1515

1616
// ClusterStateService allows to get a comprehensive state information of the whole cluster.

cluster_stats.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"gopkg.in/olivere/elastic.v3/uritemplates"
1414
)
1515

1616
// ClusterStatsService is documented at http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/cluster-stats.html.

count.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"gopkg.in/olivere/elastic.v3/uritemplates"
1414
)
1515

1616
// CountService is a convenient service for determining the

delete.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"fmt"
1010
"net/url"
1111

12-
"github.com/olivere/elastic/uritemplates"
12+
"gopkg.in/olivere/elastic.v3/uritemplates"
1313
)
1414

1515
// DeleteService allows to delete a typed JSON document from a specified

delete_by_query.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"gopkg.in/olivere/elastic.v3/uritemplates"
1414
)
1515

1616
// DeleteByQueryService deletes documents that match a query.

delete_template.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"fmt"
1010
"net/url"
1111

12-
"github.com/olivere/elastic/uritemplates"
12+
"gopkg.in/olivere/elastic.v3/uritemplates"
1313
)
1414

1515
// DeleteTemplateService deletes a search template. More information can

example_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"reflect"
1313
"time"
1414

15-
"github.com/olivere/elastic"
15+
"gopkg.in/olivere/elastic.v3"
1616
)
1717

1818
type Tweet struct {
@@ -201,7 +201,7 @@ func Example() {
201201
}
202202

203203
func ExampleClient_NewClient_default() {
204-
// Obtain a client to the Elasticsearch instance on http://localhost:9200.
204+
// Obtain a client to the Elasticsearch instance on http://127.0.0.1:9200.
205205
client, err := elastic.NewClient()
206206
if err != nil {
207207
// Handle error

exists.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"net/http"
1010
"net/url"
1111

12-
"github.com/olivere/elastic/uritemplates"
12+
"gopkg.in/olivere/elastic.v3/uritemplates"
1313
)
1414

1515
// ExistsService checks for the existence of a document using HEAD.

explain.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"net/url"
1212
"strings"
1313

14-
"github.com/olivere/elastic/uritemplates"
14+
"gopkg.in/olivere/elastic.v3/uritemplates"
1515
)
1616

1717
var (

get.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"gopkg.in/olivere/elastic.v3/uritemplates"
1414
)
1515

1616
// GetService allows to get a typed JSON document from the index based

get_mapping.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"net/url"
1212
"strings"
1313

14-
"github.com/olivere/elastic/uritemplates"
14+
"gopkg.in/olivere/elastic.v3/uritemplates"
1515
)
1616

1717
var (

get_template.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"fmt"
1010
"net/url"
1111

12-
"github.com/olivere/elastic/uritemplates"
12+
"gopkg.in/olivere/elastic.v3/uritemplates"
1313
)
1414

1515
// GetTemplateService reads a search template.

index.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"fmt"
1010
"net/url"
1111

12-
"github.com/olivere/elastic/uritemplates"
12+
"gopkg.in/olivere/elastic.v3/uritemplates"
1313
)
1414

1515
// IndexService adds or updates a typed JSON document in a specified index,

indices_close.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"fmt"
1010
"net/url"
1111

12-
"github.com/olivere/elastic/uritemplates"
12+
"gopkg.in/olivere/elastic.v3/uritemplates"
1313
)
1414

1515
// IndicesCloseService closes an index.

indices_create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"errors"
1010
"net/url"
1111

12-
"github.com/olivere/elastic/uritemplates"
12+
"gopkg.in/olivere/elastic.v3/uritemplates"
1313
)
1414

1515
// IndicesCreateService creates a new index.

indices_delete.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"gopkg.in/olivere/elastic.v3/uritemplates"
1414
)
1515

1616
// IndicesDeleteService allows to delete existing indices.

indices_delete_template.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"fmt"
1010
"net/url"
1111

12-
"github.com/olivere/elastic/uritemplates"
12+
"gopkg.in/olivere/elastic.v3/uritemplates"
1313
)
1414

1515
// IndicesDeleteTemplateService deletes index templates.

indices_exists.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"net/url"
1010
"strings"
1111

12-
"github.com/olivere/elastic/uritemplates"
12+
"gopkg.in/olivere/elastic.v3/uritemplates"
1313
)
1414

1515
// IndicesExistsService checks if an index or indices exist or not.

indices_exists_template.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"fmt"
99
"net/url"
1010

11-
"github.com/olivere/elastic/uritemplates"
11+
"gopkg.in/olivere/elastic.v3/uritemplates"
1212
)
1313

1414
// IndicesExistsTemplateService checks if a given template exists.

indices_exists_type.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"net/url"
1010
"strings"
1111

12-
"github.com/olivere/elastic/uritemplates"
12+
"gopkg.in/olivere/elastic.v3/uritemplates"
1313
)
1414

1515
// IndicesExistsTypeService checks if one or more types exist in one or more indices.

indices_flush.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"gopkg.in/olivere/elastic.v3/uritemplates"
1414
)
1515

1616
// Flush allows to flush one or more indices. The flush process of an index

indices_get.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"gopkg.in/olivere/elastic.v3/uritemplates"
1414
)
1515

1616
// IndicesGetService retrieves information about one or more indices.

indices_get_aliases.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"gopkg.in/olivere/elastic.v3/uritemplates"
1414
)
1515

1616
type AliasesService struct {

indices_get_settings.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/url"
1111
"strings"
1212

13-
"github.com/olivere/elastic/uritemplates"
13+
"gopkg.in/olivere/elastic.v3/uritemplates"
1414
)
1515

1616
// IndicesGetSettingsService allows to retrieve settings of one

0 commit comments

Comments
 (0)