Skip to content

Commit a32902f

Browse files
committed
Initial support for Elasticsearch 7
1 parent 352af50 commit a32902f

File tree

249 files changed

+1033
-1191
lines changed

Some content is hidden

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

249 files changed

+1033
-1191
lines changed

CHANGELOG-7.0.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changes from 6.0 to 7.0
2+
3+
See [breaking changes](https://www.elastic.co/guide/en/elasticsearch/reference/7.x/breaking-changes-7.0.html).
4+
5+
## ???

bulk.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
// reuse BulkService to send many batches. You do not have to create a new
2424
// BulkService for each batch.
2525
//
26-
// See https://www.elastic.co/guide/en/elasticsearch/reference/6.7/docs-bulk.html
26+
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.x/docs-bulk.html
2727
// for more details.
2828
type BulkService struct {
2929
client *Client
@@ -94,7 +94,7 @@ func (s *BulkService) Timeout(timeout string) *BulkService {
9494
// changes to be made visible by a refresh before reying), or "false"
9595
// (no refresh related actions). The default value is "false".
9696
//
97-
// See https://www.elastic.co/guide/en/elasticsearch/reference/6.7/docs-refresh.html
97+
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.x/docs-refresh.html
9898
// for details.
9999
func (s *BulkService) Refresh(refresh string) *BulkService {
100100
s.refresh = refresh

bulk_delete_request.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
// BulkDeleteRequest is a request to remove a document from Elasticsearch.
1818
//
19-
// See https://www.elastic.co/guide/en/elasticsearch/reference/6.7/docs-bulk.html
19+
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.x/docs-bulk.html
2020
// for details.
2121
type BulkDeleteRequest struct {
2222
BulkableRequest
@@ -128,7 +128,7 @@ func (r *BulkDeleteRequest) String() string {
128128

129129
// Source returns the on-wire representation of the delete request,
130130
// split into an action-and-meta-data line and an (optional) source line.
131-
// See https://www.elastic.co/guide/en/elasticsearch/reference/6.7/docs-bulk.html
131+
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.x/docs-bulk.html
132132
// for details.
133133
func (r *BulkDeleteRequest) Source() ([]string, error) {
134134
if r.source != nil {

bulk_delete_request_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ func TestBulkDeleteRequestSerialization(t *testing.T) {
1515
}{
1616
// #0
1717
{
18-
Request: NewBulkDeleteRequest().Index("index1").Type("doc").Id("1"),
18+
Request: NewBulkDeleteRequest().Index("index1").Id("1"),
1919
Expected: []string{
20-
`{"delete":{"_index":"index1","_type":"doc","_id":"1"}}`,
20+
`{"delete":{"_index":"index1","_id":"1"}}`,
2121
},
2222
},
2323
// #1
2424
{
25-
Request: NewBulkDeleteRequest().Index("index1").Type("doc").Id("1").Parent("2"),
25+
Request: NewBulkDeleteRequest().Index("index1").Id("1").Parent("2"),
2626
Expected: []string{
27-
`{"delete":{"_index":"index1","_type":"doc","_id":"1","parent":"2"}}`,
27+
`{"delete":{"_index":"index1","_id":"1","parent":"2"}}`,
2828
},
2929
},
3030
// #2
3131
{
32-
Request: NewBulkDeleteRequest().Index("index1").Type("doc").Id("1").Routing("3"),
32+
Request: NewBulkDeleteRequest().Index("index1").Id("1").Routing("3"),
3333
Expected: []string{
34-
`{"delete":{"_index":"index1","_type":"doc","_id":"1","routing":"3"}}`,
34+
`{"delete":{"_index":"index1","_id":"1","routing":"3"}}`,
3535
},
3636
},
3737
}
@@ -59,11 +59,11 @@ var bulkDeleteRequestSerializationResult string
5959

6060
func BenchmarkBulkDeleteRequestSerialization(b *testing.B) {
6161
b.Run("stdlib", func(b *testing.B) {
62-
r := NewBulkDeleteRequest().Index(testIndexName).Type("doc").Id("1")
62+
r := NewBulkDeleteRequest().Index(testIndexName).Id("1")
6363
benchmarkBulkDeleteRequestSerialization(b, r.UseEasyJSON(false))
6464
})
6565
b.Run("easyjson", func(b *testing.B) {
66-
r := NewBulkDeleteRequest().Index(testIndexName).Type("doc").Id("1")
66+
r := NewBulkDeleteRequest().Index(testIndexName).Id("1")
6767
benchmarkBulkDeleteRequestSerialization(b, r.UseEasyJSON(true))
6868
})
6969
}

bulk_index_request.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
// BulkIndexRequest is a request to add a document to Elasticsearch.
1616
//
17-
// See https://www.elastic.co/guide/en/elasticsearch/reference/6.7/docs-bulk.html
17+
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.x/docs-bulk.html
1818
// for details.
1919
type BulkIndexRequest struct {
2020
BulkableRequest
@@ -95,7 +95,7 @@ func (r *BulkIndexRequest) Id(id string) *BulkIndexRequest {
9595

9696
// OpType specifies if this request should follow create-only or upsert
9797
// behavior. This follows the OpType of the standard document index API.
98-
// See https://www.elastic.co/guide/en/elasticsearch/reference/6.7/docs-index_.html#operation-type
98+
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.x/docs-index_.html#operation-type
9999
// for details.
100100
func (r *BulkIndexRequest) OpType(opType string) *BulkIndexRequest {
101101
r.opType = opType
@@ -129,7 +129,7 @@ func (r *BulkIndexRequest) Version(version int64) *BulkIndexRequest {
129129
// VersionType specifies how versions are created. It can be e.g. internal,
130130
// external, external_gte, or force.
131131
//
132-
// See https://www.elastic.co/guide/en/elasticsearch/reference/6.7/docs-index_.html#index-versioning
132+
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.x/docs-index_.html#index-versioning
133133
// for details.
134134
func (r *BulkIndexRequest) VersionType(versionType string) *BulkIndexRequest {
135135
r.versionType = versionType
@@ -170,7 +170,7 @@ func (r *BulkIndexRequest) String() string {
170170

171171
// Source returns the on-wire representation of the index request,
172172
// split into an action-and-meta-data line and an (optional) source line.
173-
// See https://www.elastic.co/guide/en/elasticsearch/reference/6.7/docs-bulk.html
173+
// See https://www.elastic.co/guide/en/elasticsearch/reference/7.x/docs-bulk.html
174174
// for details.
175175
func (r *BulkIndexRequest) Source() ([]string, error) {
176176
// { "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }

bulk_index_request_test.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -16,56 +16,56 @@ func TestBulkIndexRequestSerialization(t *testing.T) {
1616
}{
1717
// #0
1818
{
19-
Request: NewBulkIndexRequest().Index("index1").Type("doc").Id("1").
19+
Request: NewBulkIndexRequest().Index("index1").Id("1").
2020
Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
2121
Expected: []string{
22-
`{"index":{"_index":"index1","_id":"1","_type":"doc"}}`,
22+
`{"index":{"_index":"index1","_id":"1"}}`,
2323
`{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
2424
},
2525
},
2626
// #1
2727
{
28-
Request: NewBulkIndexRequest().OpType("create").Index("index1").Type("doc").Id("1").
28+
Request: NewBulkIndexRequest().OpType("create").Index("index1").Id("1").
2929
Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
3030
Expected: []string{
31-
`{"create":{"_index":"index1","_id":"1","_type":"doc"}}`,
31+
`{"create":{"_index":"index1","_id":"1"}}`,
3232
`{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
3333
},
3434
},
3535
// #2
3636
{
37-
Request: NewBulkIndexRequest().OpType("index").Index("index1").Type("doc").Id("1").
37+
Request: NewBulkIndexRequest().OpType("index").Index("index1").Id("1").
3838
Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
3939
Expected: []string{
40-
`{"index":{"_index":"index1","_id":"1","_type":"doc"}}`,
40+
`{"index":{"_index":"index1","_id":"1"}}`,
4141
`{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
4242
},
4343
},
4444
// #3
4545
{
46-
Request: NewBulkIndexRequest().OpType("index").Index("index1").Type("doc").Id("1").RetryOnConflict(42).
46+
Request: NewBulkIndexRequest().OpType("index").Index("index1").Id("1").RetryOnConflict(42).
4747
Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
4848
Expected: []string{
49-
`{"index":{"_index":"index1","_id":"1","_type":"doc","retry_on_conflict":42}}`,
49+
`{"index":{"_index":"index1","_id":"1","retry_on_conflict":42}}`,
5050
`{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
5151
},
5252
},
5353
// #4
5454
{
55-
Request: NewBulkIndexRequest().OpType("index").Index("index1").Type("doc").Id("1").Pipeline("my_pipeline").
55+
Request: NewBulkIndexRequest().OpType("index").Index("index1").Id("1").Pipeline("my_pipeline").
5656
Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
5757
Expected: []string{
58-
`{"index":{"_index":"index1","_id":"1","_type":"doc","pipeline":"my_pipeline"}}`,
58+
`{"index":{"_index":"index1","_id":"1","pipeline":"my_pipeline"}}`,
5959
`{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
6060
},
6161
},
6262
// #5
6363
{
64-
Request: NewBulkIndexRequest().OpType("index").Index("index1").Type("doc").Id("1").
64+
Request: NewBulkIndexRequest().OpType("index").Index("index1").Id("1").
6565
Routing("123").
6666
Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
6767
Expected: []string{
68-
`{"index":{"_index":"index1","_id":"1","_type":"doc","routing":"123"}}`,
68+
`{"index":{"_index":"index1","_id":"1","routing":"123"}}`,
6969
`{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
7070
},
7171
},
@@ -105,12 +105,12 @@ var bulkIndexRequestSerializationResult string
105105

106106
func BenchmarkBulkIndexRequestSerialization(b *testing.B) {
107107
b.Run("stdlib", func(b *testing.B) {
108-
r := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id("1").
108+
r := NewBulkIndexRequest().Index(testIndexName).Id("1").
109109
Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)})
110110
benchmarkBulkIndexRequestSerialization(b, r.UseEasyJSON(false))
111111
})
112112
b.Run("easyjson", func(b *testing.B) {
113-
r := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id("1").
113+
r := NewBulkIndexRequest().Index(testIndexName).Id("1").
114114
Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)})
115115
benchmarkBulkIndexRequestSerialization(b, r.UseEasyJSON(true))
116116
})

bulk_processor_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func TestBulkProcessorBasedOnFlushInterval(t *testing.T) {
133133

134134
for i := 1; i <= numDocs; i++ {
135135
tweet := tweet{User: "olivere", Message: fmt.Sprintf("%d. %s", i, randomString(rand.Intn(64)))}
136-
request := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id(fmt.Sprintf("%d", i)).Doc(tweet)
136+
request := NewBulkIndexRequest().Index(testIndexName).Id(fmt.Sprintf("%d", i)).Doc(tweet)
137137
p.Add(request)
138138
}
139139

@@ -165,7 +165,7 @@ func TestBulkProcessorBasedOnFlushInterval(t *testing.T) {
165165
}
166166

167167
// Check number of documents that were bulk indexed
168-
_, err = p.c.Flush(testIndexName).Do(context.TODO())
168+
_, err = p.c.Refresh(testIndexName).Do(context.TODO())
169169
if err != nil {
170170
t.Fatal(err)
171171
}
@@ -216,7 +216,7 @@ func TestBulkProcessorClose(t *testing.T) {
216216

217217
for i := 1; i <= numDocs; i++ {
218218
tweet := tweet{User: "olivere", Message: fmt.Sprintf("%d. %s", i, randomString(rand.Intn(64)))}
219-
request := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id(fmt.Sprintf("%d", i)).Doc(tweet)
219+
request := NewBulkIndexRequest().Index(testIndexName).Id(fmt.Sprintf("%d", i)).Doc(tweet)
220220
p.Add(request)
221221
}
222222

@@ -249,7 +249,7 @@ func TestBulkProcessorClose(t *testing.T) {
249249
}
250250

251251
// Check number of documents that were bulk indexed
252-
_, err = p.c.Flush(testIndexName).Do(context.TODO())
252+
_, err = p.c.Refresh(testIndexName).Do(context.TODO())
253253
if err != nil {
254254
t.Fatal(err)
255255
}
@@ -282,7 +282,7 @@ func TestBulkProcessorFlush(t *testing.T) {
282282

283283
for i := 1; i <= numDocs; i++ {
284284
tweet := tweet{User: "olivere", Message: fmt.Sprintf("%d. %s", i, randomString(rand.Intn(64)))}
285-
request := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id(fmt.Sprintf("%d", i)).Doc(tweet)
285+
request := NewBulkIndexRequest().Index(testIndexName).Id(fmt.Sprintf("%d", i)).Doc(tweet)
286286
p.Add(request)
287287
}
288288

@@ -322,7 +322,7 @@ func TestBulkProcessorFlush(t *testing.T) {
322322
}
323323

324324
// Check number of documents that were bulk indexed
325-
_, err = p.c.Flush(testIndexName).Do(context.TODO())
325+
_, err = p.c.Refresh(testIndexName).Do(context.TODO())
326326
if err != nil {
327327
t.Fatal(err)
328328
}
@@ -363,7 +363,7 @@ func testBulkProcessor(t *testing.T, numDocs int, svc *BulkProcessorService) {
363363

364364
for i := 1; i <= numDocs; i++ {
365365
tweet := tweet{User: "olivere", Message: fmt.Sprintf("%07d. %s", i, randomString(1+rand.Intn(63)))}
366-
request := NewBulkIndexRequest().Index(testIndexName).Type("doc").Id(fmt.Sprintf("%d", i)).Doc(tweet)
366+
request := NewBulkIndexRequest().Index(testIndexName).Id(fmt.Sprintf("%d", i)).Doc(tweet)
367367
p.Add(request)
368368
}
369369

@@ -415,7 +415,7 @@ func testBulkProcessor(t *testing.T, numDocs int, svc *BulkProcessorService) {
415415
}
416416

417417
// Check number of documents that were bulk indexed
418-
_, err = p.c.Flush(testIndexName).Do(context.TODO())
418+
_, err = p.c.Refresh(testIndexName).Do(context.TODO())
419419
if err != nil {
420420
t.Fatal(err)
421421
}

0 commit comments

Comments
 (0)