Update index settings API - https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html#indices-update-settings
This commit is contained in:
parent
add48c54e3
commit
bf0b8b5bc8
14
goes.go
14
goes.go
@ -75,6 +75,20 @@ func (c *Connection) RefreshIndex(name string) (*Response, error) {
|
||||
return r.Run()
|
||||
}
|
||||
|
||||
// UpdateIndexSettings updates settings for existing index represented by a name and a settings
|
||||
// as described here: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html
|
||||
func (c *Connection) UpdateIndexSettings(name string, settings map[string]interface{}) (Response, error) {
|
||||
r := Request{
|
||||
Conn: c,
|
||||
Query: settings,
|
||||
IndexList: []string{name},
|
||||
method: "PUT",
|
||||
api: "_settings",
|
||||
}
|
||||
|
||||
return r.Run()
|
||||
}
|
||||
|
||||
// Optimize an index represented by a name, extra args are also allowed please check:
|
||||
// http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-optimize.html#indices-optimize
|
||||
func (c *Connection) Optimize(indexList []string, extraArgs url.Values) (*Response, error) {
|
||||
|
18
goes_test.go
18
goes_test.go
@ -180,6 +180,24 @@ func (s *GoesTestSuite) TestDeleteIndexExistingIndex(c *C) {
|
||||
c.Assert(resp, DeepEquals, expectedResponse)
|
||||
}
|
||||
|
||||
func (s *GoesTestSuite) TestUpdateIndexSettings(c *C) {
|
||||
conn := NewConnection(ES_HOST, ES_PORT)
|
||||
indexName := "testupdateindex"
|
||||
|
||||
_, err := conn.CreateIndex(indexName, map[string]interface{}{})
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
_, err := conn.UpdateIndexSettings(indexName, map[string]interface{}{
|
||||
"index": map[string]interface{}{
|
||||
"number_of_replicas": 0,
|
||||
},
|
||||
})
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
_, err = conn.DeleteIndex(indexName)
|
||||
c.Assert(err, IsNil)
|
||||
}
|
||||
|
||||
func (s *GoesTestSuite) TestRefreshIndex(c *C) {
|
||||
conn := NewConnection(ES_HOST, ES_PORT)
|
||||
indexName := "testrefreshindex"
|
||||
|
Loading…
Reference in New Issue
Block a user