Browse Source

Added indexList and extraArgs support to Connection.Stats()

tags/v1.0.0
Jérôme Renard 11 years ago
parent
commit
726e1e80b9
2 changed files with 9 additions and 6 deletions
  1. +6
    -4
      goes.go
  2. +3
    -2
      goes_test.go

+ 6
- 4
goes.go View File

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


+ 3
- 2
goes_test.go View File

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


Loading…
Cancel
Save