r--w 2015-10-02 13:25:29 +02:00
parent add48c54e3
commit bf0b8b5bc8
2 changed files with 32 additions and 0 deletions

14
goes.go
View File

@ -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) {

View File

@ -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"