This commit is contained in:
Ian Babrou 2014-07-03 16:28:55 +04:00
parent 45e977fe8a
commit 20300ffa70
2 changed files with 17 additions and 18 deletions

View File

@ -356,7 +356,7 @@ func (r *Request) Url() string {
func (a Aggregation) Buckets() []Bucket { func (a Aggregation) Buckets() []Bucket {
result := []Bucket{} result := []Bucket{}
if buckets, ok := a["buckets"]; ok { if buckets, ok := a["buckets"]; ok {
for _, bucket := range buckets.([]interface {}) { for _, bucket := range buckets.([]interface{}) {
result = append(result, bucket.(map[string]interface{})) result = append(result, bucket.(map[string]interface{}))
} }
} }
@ -375,7 +375,7 @@ func (b Bucket) DocCount() uint64 {
} }
// Aggregation returns aggregation by name from bucket // Aggregation returns aggregation by name from bucket
func (b Bucket) Aggregation(name string) Aggregation{ func (b Bucket) Aggregation(name string) Aggregation {
if agg, ok := b[name]; ok { if agg, ok := b[name]; ok {
return agg.(map[string]interface{}) return agg.(map[string]interface{})
} else { } else {

View File

@ -728,7 +728,6 @@ func (s *GoesTestSuite) TestScroll(c *C) {
c.Assert(len(searchResults.Hits.Hits), Equals, 0) c.Assert(len(searchResults.Hits.Hits), Equals, 0)
} }
func (s *GoesTestSuite) TestAggregations(c *C) { func (s *GoesTestSuite) TestAggregations(c *C) {
indexName := "testaggs" indexName := "testaggs"
docType := "tweet" docType := "tweet"
@ -740,9 +739,9 @@ func (s *GoesTestSuite) TestAggregations(c *C) {
Type: docType, Type: docType,
BulkCommand: BULK_COMMAND_INDEX, BulkCommand: BULK_COMMAND_INDEX,
Fields: map[string]interface{}{ Fields: map[string]interface{}{
"user" : "foo", "user": "foo",
"message" : "some foo message", "message": "some foo message",
"age" : 25, "age": 25,
}, },
}, },
@ -752,9 +751,9 @@ func (s *GoesTestSuite) TestAggregations(c *C) {
Type: docType, Type: docType,
BulkCommand: BULK_COMMAND_INDEX, BulkCommand: BULK_COMMAND_INDEX,
Fields: map[string]interface{}{ Fields: map[string]interface{}{
"user" : "bar", "user": "bar",
"message" : "some bar message", "message": "some bar message",
"age" : 30, "age": 30,
}, },
}, },
@ -764,8 +763,8 @@ func (s *GoesTestSuite) TestAggregations(c *C) {
Type: docType, Type: docType,
BulkCommand: BULK_COMMAND_INDEX, BulkCommand: BULK_COMMAND_INDEX,
Fields: map[string]interface{}{ Fields: map[string]interface{}{
"user" : "foo", "user": "foo",
"message" : "another foo message", "message": "another foo message",
}, },
}, },
} }
@ -836,5 +835,5 @@ func (s *GoesTestSuite) TestAggregations(c *C) {
c.Assert(ok, Equals, true) c.Assert(ok, Equals, true)
c.Assert(age["count"], Equals, 2.0) c.Assert(age["count"], Equals, 2.0)
c.Assert(age["sum"], Equals, 25.0 + 30.0) c.Assert(age["sum"], Equals, 25.0+30.0)
} }