Skip to content

Commit

Permalink
Move to Go modules and some finishing touches
Browse files Browse the repository at this point in the history
This commit introduces Go modules, so you actually need to use

```
github.com/olivere/elastic/v7
```

as an import path.

Notice we didn't tag the `v7.0.0` release as of now, so it's still
preparation.
  • Loading branch information
olivere committed Mar 30, 2019
1 parent 0eef387 commit d05affb
Show file tree
Hide file tree
Showing 30 changed files with 97 additions and 84 deletions.
33 changes: 19 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Elastic

**This is a development branch that is actively being worked on. DO NOT USE IN PRODUCTION! If you want to use stable versions of Elastic, please use a dependency manager like [dep](https://github.com/golang/dep).**
**This is a development branch that is actively being worked on. DO NOT USE IN PRODUCTION! If you want to use stable versions of Elastic, please use Go modules for the 7.x release (or later) or a dependency manager like [dep](https://github.com/golang/dep) for earlier releases.**

Elastic is an [Elasticsearch](http://www.elasticsearch.org/) client for the
[Go](http://www.golang.org/) programming language.
Expand All @@ -14,17 +14,17 @@ See the [wiki](https://github.com/olivere/elastic/wiki) for additional informati

<a href="https://www.buymeacoffee.com/Bjd96U8fm" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>


## Releases

**The release branches (e.g. [`release-branch.v6`](https://github.com/olivere/elastic/tree/release-branch.v6))
**The release branches (e.g. [`release-branch.v7`](https://github.com/olivere/elastic/tree/release-branch.v7))
are actively being worked on and can break at any time.
If you want to use stable versions of Elastic, please use a dependency manager like [dep](https://github.com/golang/dep).**
If you want to use stable versions of Elastic, please use Go modules.**

Here's the version matrix:

Elasticsearch version | Elastic version | Package URL | Remarks |
----------------------|------------------|-------------|---------|
7.x                   | 7.0             | [`github.com/olivere/elastic/v7`](https://github.com/olivere/elastic) ([source](https://github.com/olivere/elastic/tree/release-branch.v7) [doc](http://godoc.org/github.com/olivere/elastic)) | Use Go modules.
6.x                   | 6.0             | [`github.com/olivere/elastic`](https://github.com/olivere/elastic) ([source](https://github.com/olivere/elastic/tree/release-branch.v6) [doc](http://godoc.org/github.com/olivere/elastic)) | Use a dependency manager (see below).
5.x | 5.0 | [`gopkg.in/olivere/elastic.v5`](https://gopkg.in/olivere/elastic.v5) ([source](https://github.com/olivere/elastic/tree/release-branch.v5) [doc](http://godoc.org/gopkg.in/olivere/elastic.v5)) | Actively maintained.
2.x | 3.0 | [`gopkg.in/olivere/elastic.v3`](https://gopkg.in/olivere/elastic.v3) ([source](https://github.com/olivere/elastic/tree/release-branch.v3) [doc](http://godoc.org/gopkg.in/olivere/elastic.v3)) | Deprecated. Please update.
Expand All @@ -33,22 +33,27 @@ Elasticsearch version | Elastic version | Package URL | Remarks |

**Example:**

You have installed Elasticsearch 6.0.0 and want to use Elastic.
As listed above, you should use Elastic 6.0.
You have installed Elasticsearch 7.0.0 and want to use Elastic.
As listed above, you should use Elastic 7.0 (code is in `release-branch.v7`).

To use the required version of Elastic in your application, it is strongly
advised to use a tool like
[dep](https://github.com/golang/dep)
or
[Go modules](https://github.com/golang/go/wiki/Modules)
to manage dependencies. Make sure to use a version such as `^6.0.0`.
To use the required version of Elastic in your application, you
shoud use [Go modules](https://github.com/golang/go/wiki/Modules)
to manage dependencies. Make sure to use a version such as `7.0.0` or later.

To use Elastic, import:

```go
import "github.com/olivere/elastic"
import "github.com/olivere/elastic/v7"
```

### Elastic 7.0

Elastic 7.0 targets Elasticsearch 7.x which [is currently at rc1](https://www.elastic.co/guide/en/elasticsearch/reference/7.0/release-notes-7.0.0-rc1.html).

As always with major version, there are a lot of [breaking changes](https://www.elastic.co/guide/en/elasticsearch/reference/7.0/release-notes-7.0.0-rc1.html#breaking-7.0.0-rc1).
We will use this as an opportunity to [clean up and refactor Elastic](https://github.com/olivere/elastic/blob/release-branch.v7/CHANGELOG-7.0.md),
as we already did in earlier (major) releases.

### Elastic 6.0

Elastic 6.0 targets Elasticsearch 6.x which was [released on 14th November 2017](https://www.elastic.co/blog/elasticsearch-6-0-0-released).
Expand Down Expand Up @@ -101,7 +106,7 @@ Having said that, there have been no big API changes that required you
to rewrite your application big time. More often than not it's renaming APIs
and adding/removing features so that Elastic is in sync with Elasticsearch.

Elastic has been used in production starting with Elasticsearch 0.90 up to recent 6.x
Elastic has been used in production starting with Elasticsearch 0.90 up to recent 7.x
versions. Furthermore, we use [Travis CI](https://travis-ci.org/)
to test Elastic with the most recent versions of Elasticsearch and Go.
See the [.travis.yml](https://github.com/olivere/elastic/blob/master/.travis.yml)
Expand Down
4 changes: 2 additions & 2 deletions aws/sign_v4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"net/http/httptest"
"testing"

"github.com/smartystreets/go-aws-auth"
awsauth "github.com/smartystreets/go-aws-auth"

"github.com/olivere/elastic"
"github.com/olivere/elastic/v7"
)

func TestSigningClient(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion aws/v4/aws_v4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

"github.com/aws/aws-sdk-go/aws/credentials"

"github.com/olivere/elastic"
"github.com/olivere/elastic/v7"
)

func TestSigningClient(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cluster-test/cluster-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"sync/atomic"
"time"

"github.com/olivere/elastic"
"github.com/olivere/elastic/v7"
)

type Tweet struct {
Expand Down
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"reflect"
"time"

"github.com/olivere/elastic"
"github.com/olivere/elastic/v7"
)

type Tweet struct {
Expand Down
19 changes: 19 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module github.com/olivere/elastic/v7

go 1.12

require (
github.com/aws/aws-sdk-go v1.19.6
github.com/fortytw2/leaktest v1.3.0
github.com/golang/mock v1.2.0 // indirect
github.com/google/go-cmp v0.2.0
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe
github.com/olivere/elastic v6.2.16+incompatible
github.com/opentracing/opentracing-go v1.1.0
github.com/pkg/errors v0.8.1
github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9
go.opencensus.io v0.19.2
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
)
4 changes: 2 additions & 2 deletions recipes/aws-connect-v4/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/olivere/env"

"github.com/olivere/elastic"
aws "github.com/olivere/elastic/aws/v4"
"github.com/olivere/elastic/v7"
aws "github.com/olivere/elastic/v7/aws/v4"
)

func main() {
Expand Down
1 change: 1 addition & 0 deletions recipes/aws-connect/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/aws-connect
6 changes: 3 additions & 3 deletions recipes/aws-connect/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
"log"

"github.com/olivere/env"
"github.com/smartystreets/go-aws-auth"
awsauth "github.com/smartystreets/go-aws-auth"

"github.com/olivere/elastic"
"github.com/olivere/elastic/aws"
"github.com/olivere/elastic/v7"
"github.com/olivere/elastic/v7/aws"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions recipes/aws-mapping-v4/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/olivere/env"

"github.com/olivere/elastic"
aws "github.com/olivere/elastic/aws/v4"
"github.com/olivere/elastic/v7"
aws "github.com/olivere/elastic/v7/aws/v4"
)

const (
Expand Down
1 change: 1 addition & 0 deletions recipes/bulk_insert/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bulk_insert
2 changes: 1 addition & 1 deletion recipes/bulk_insert/bulk_insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (

"golang.org/x/sync/errgroup"

"github.com/olivere/elastic"
"github.com/olivere/elastic/v7"
)

func main() {
Expand Down
1 change: 1 addition & 0 deletions recipes/bulk_processor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bulk_processor
4 changes: 2 additions & 2 deletions recipes/bulk_processor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (

"github.com/google/uuid"

"github.com/olivere/elastic"
"github.com/olivere/elastic/config"
"github.com/olivere/elastic/v7"
"github.com/olivere/elastic/v7/config"
)

func main() {
Expand Down
1 change: 1 addition & 0 deletions recipes/connect/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/connect
2 changes: 1 addition & 1 deletion recipes/connect/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"fmt"
"log"

"github.com/olivere/elastic"
"github.com/olivere/elastic/v7"
)

func main() {
Expand Down
1 change: 1 addition & 0 deletions recipes/connect_with_config/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/connect_with_config
4 changes: 2 additions & 2 deletions recipes/connect_with_config/connect_with_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"log"
"runtime"

"github.com/olivere/elastic"
"github.com/olivere/elastic/config"
"github.com/olivere/elastic/v7"
"github.com/olivere/elastic/v7/config"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion recipes/go-modules/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"fmt"
"log"

"github.com/olivere/elastic" // <- should end with /v6, but missing due to compatibility reasons
"github.com/olivere/elastic/v7"
)

func main() {
Expand Down
1 change: 1 addition & 0 deletions recipes/mapping/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/mapping
36 changes: 16 additions & 20 deletions recipes/mapping/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"log"
"time"

"github.com/olivere/elastic"
"github.com/olivere/elastic/v7"
)

const (
Expand All @@ -30,23 +30,21 @@ const (
"number_of_replicas":0
},
"mappings":{
"_doc":{
"properties":{
"user":{
"type":"keyword"
},
"message":{
"type":"text"
},
"retweets":{
"type":"integer"
},
"created":{
"type":"date"
},
"attributes":{
"type":"object"
}
"properties":{
"user":{
"type":"keyword"
},
"message":{
"type":"text"
},
"retweets":{
"type":"integer"
},
"created":{
"type":"date"
},
"attributes":{
"type":"object"
}
}
}
Expand Down Expand Up @@ -118,7 +116,6 @@ func main() {
}
_, err := client.Index().
Index(*index).
Type("_doc").
Id("1").
BodyJson(&tweet).
Refresh("true").
Expand All @@ -132,7 +129,6 @@ func main() {
{
doc, err := client.Get().
Index(*index).
Type("_doc").
Id("1").
Do(context.TODO())
if err != nil {
Expand Down
9 changes: 2 additions & 7 deletions recipes/scroll/scroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ import (

"golang.org/x/sync/errgroup"

"github.com/olivere/elastic"
"github.com/olivere/elastic/v7"
)

func main() {
var (
url = flag.String("url", "http://localhost:9200", "Elasticsearch URL")
index = flag.String("index", "", "Elasticsearch index name")
typ = flag.String("type", "", "Elasticsearch type name")
size = flag.Int("size", 100, "Slice of documents to get per scroll")
sniff = flag.Bool("sniff", true, "Enable or disable sniffing")
)
Expand Down Expand Up @@ -72,11 +71,7 @@ func main() {

// Prepare the query
var query elastic.Query
if *typ == "" {
query = elastic.NewMatchAllQuery()
} else {
query = elastic.NewTypeQuery(*typ)
}
query = elastic.NewMatchAllQuery()
svc := client.Scroll(*index).Query(query)
for {
res, err := svc.Do(ctx)
Expand Down
1 change: 1 addition & 0 deletions recipes/sliced_scroll/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/sliced_scroll
9 changes: 2 additions & 7 deletions recipes/sliced_scroll/sliced_scroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ import (

"golang.org/x/sync/errgroup"

"github.com/olivere/elastic"
"github.com/olivere/elastic/v7"
)

func main() {
var (
url = flag.String("url", "http://localhost:9200", "Elasticsearch URL")
index = flag.String("index", "", "Elasticsearch index name")
typ = flag.String("type", "", "Elasticsearch type name")
field = flag.String("field", "", "Slice field (must be numeric)")
numSlices = flag.Int("n", 2, "Number of slices to use in parallel")
sniff = flag.Bool("sniff", true, "Enable or disable sniffing")
Expand Down Expand Up @@ -89,11 +88,7 @@ func main() {

// Prepare the query
var query elastic.Query
if *typ == "" {
query = elastic.NewMatchAllQuery()
} else {
query = elastic.NewTypeQuery(*typ)
}
query = elastic.NewMatchAllQuery()

// Prepare the slice
sliceQuery := elastic.NewSliceQuery().Id(i).Max(*numSlices)
Expand Down
Loading

0 comments on commit d05affb

Please sign in to comment.