Skip to content

Commit 9fa6bd9

Browse files
committed
Add Task API, Reindexer, and Update by Query API
Elasticsearch 2.3.0 introduces a Task Management API, a Reindex API, and an Update-by-Query API (see [release notes](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/release-notes-2.3.0.html)). This commit adds these APIs to Elastic.
1 parent c842bc7 commit 9fa6bd9

11 files changed

+2163
-20
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ env:
88
global:
99
- GO15VENDOREXPERIMENT=1
1010
matrix:
11-
- ES_VERSION=2.2.1
11+
- ES_VERSION=2.3.0
1212
allow_failures:
1313
- go: tip
1414
before_script:

client.go

+41-9
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
const (
2323
// Version is the current version of Elastic.
24-
Version = "3.0.28"
24+
Version = "3.0.29"
2525

2626
// DefaultUrl is the default endpoint of Elasticsearch on the local machine.
2727
// It is used e.g. when initializing a new Client without a specific URL.
@@ -1194,6 +1194,11 @@ func (c *Client) Update() *UpdateService {
11941194
return NewUpdateService(c)
11951195
}
11961196

1197+
// UpdateByQuery performs an update on a set of documents.
1198+
func (c *Client) UpdateByQuery(indices ...string) *UpdateByQueryService {
1199+
return NewUpdateByQueryService(c).Index(indices...)
1200+
}
1201+
11971202
// Bulk is the entry point to mass insert/update/delete documents.
11981203
func (c *Client) Bulk() *BulkService {
11991204
return NewBulkService(c)
@@ -1204,6 +1209,31 @@ func (c *Client) BulkProcessor() *BulkProcessorService {
12041209
return NewBulkProcessorService(c)
12051210
}
12061211

1212+
// Reindex returns a service that will reindex documents from a source
1213+
// index into a target index.
1214+
//
1215+
// Notice that this Reindexer is an Elastic-specific solution that pre-dated
1216+
// the Reindex API introduced in Elasticsearch 2.3.0 (see ReindexTask).
1217+
//
1218+
// See http://www.elastic.co/guide/en/elasticsearch/guide/current/reindex.html
1219+
// for more information about reindexing.
1220+
func (c *Client) Reindex(sourceIndex, targetIndex string) *Reindexer {
1221+
return NewReindexer(c, sourceIndex, CopyToTargetIndex(targetIndex))
1222+
}
1223+
1224+
// ReindexTask copies data from a source index into a destination index.
1225+
//
1226+
// The Reindex API has been introduced in Elasticsearch 2.3.0. Notice that
1227+
// there is a Elastic-specific Reindexer that pre-dates the Reindex API from
1228+
// Elasticsearch. If you rely on that, use the ReindexerService via
1229+
// Client.Reindex.
1230+
//
1231+
// See https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html
1232+
// for details on the Reindex API.
1233+
func (c *Client) ReindexTask() *ReindexService {
1234+
return NewReindexService(c)
1235+
}
1236+
12071237
// TODO Term Vectors
12081238
// TODO Multi termvectors API
12091239

@@ -1462,6 +1492,16 @@ func (c *Client) NodesInfo() *NodesInfoService {
14621492
return NewNodesInfoService(c)
14631493
}
14641494

1495+
// TasksCancel cancels tasks running on the specified nodes.
1496+
func (c *Client) TasksCancel() *TasksCancelService {
1497+
return NewTasksCancelService(c)
1498+
}
1499+
1500+
// TasksList retrieves the list of tasks running on the specified nodes.
1501+
func (c *Client) TasksList() *TasksListService {
1502+
return NewTasksListService(c)
1503+
}
1504+
14651505
// TODO Pending cluster tasks
14661506
// TODO Cluster Reroute
14671507
// TODO Cluster Update Settings
@@ -1514,14 +1554,6 @@ func (c *Client) Ping(url string) *PingService {
15141554
return NewPingService(c).URL(url)
15151555
}
15161556

1517-
// Reindex returns a service that will reindex documents from a source
1518-
// index into a target index. See
1519-
// http://www.elastic.co/guide/en/elasticsearch/guide/current/reindex.html
1520-
// for more information about reindexing.
1521-
func (c *Client) Reindex(sourceIndex, targetIndex string) *Reindexer {
1522-
return NewReindexer(c, sourceIndex, CopyToTargetIndex(targetIndex))
1523-
}
1524-
15251557
// WaitForStatus waits for the cluster to have the given status.
15261558
// This is a shortcut method for the ClusterHealth service.
15271559
//

0 commit comments

Comments
 (0)