diff --git a/goes.go b/goes.go index 79fbc89..ab1ab93 100644 --- a/goes.go +++ b/goes.go @@ -69,11 +69,13 @@ func (c *Connection) RefreshIndex(name string) (Response, error) { } // Stats fetches statistics (_stats) for the current elasticsearch server -func (c *Connection) Stats() (Response, error) { +func (c *Connection) Stats(indexList []string, extraArgs url.Values) (Response, error) { r := Request{ - Conn: c, - method: "GET", - api: "_stats", + Conn: c, + IndexList: indexList, + ExtraArgs: extraArgs, + method: "GET", + api: "_stats", } return r.Run() diff --git a/goes_test.go b/goes_test.go index 6f47e6f..ff0287c 100644 --- a/goes_test.go +++ b/goes_test.go @@ -292,15 +292,16 @@ func (s *GoesTestSuite) TestBulkSend(c *C) { func (s *GoesTestSuite) TestStats(c *C) { conn := NewConnection(ES_HOST, ES_PORT) - indexName := "testfetchstats" + indexName := "teststats" + conn.DeleteIndex(indexName) _, err := conn.CreateIndex(indexName, map[string]interface{}{}) c.Assert(err, IsNil) // we must wait for a bit otherwise ES crashes time.Sleep(1 * time.Second) - response, err := conn.Stats() + response, err := conn.Stats([]string{indexName}, url.Values{}) c.Assert(err, IsNil) c.Assert(response.All.Indices[indexName].Primaries["docs"].Count, Equals, 0)