Added indexList and extraArgs support to Connection.Stats()

This commit is contained in:
Jérôme Renard 2013-06-18 08:04:52 +02:00
父節點 92081c6d25
當前提交 726e1e80b9
共有 2 個文件被更改,包括 9 次插入6 次删除

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

查看文件

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