Skip to content

Commit

Permalink
Merge pull request mattbaird#179 from nullbus/master
Browse files Browse the repository at this point in the history
Change FieldAggregate.Size type to *int
  • Loading branch information
mattbaird committed Apr 6, 2015
2 parents 8ead27f + 008f75d commit db99d96
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/searchaggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type AggregateDsl struct {

type FieldAggregate struct {
Field string `json:"field"`
Size int `json:"size,omitempty"`
Size *int `json:"size,omitempty"`
}

/**
Expand Down Expand Up @@ -152,7 +152,7 @@ func (d *AggregateDsl) Terms(field string) *AggregateDsl {
}

func (d *AggregateDsl) TermsWithSize(field string, size int) *AggregateDsl {
d.Type = FieldAggregate{Field: field, Size: size}
d.Type = FieldAggregate{Field: field, Size: &size}
d.TypeName = "terms"
return d
}
Expand Down
5 changes: 5 additions & 0 deletions lib/searchaggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestAggregateDsl(t *testing.T) {
global := Aggregate("global").Global()
missing := Aggregate("missing_price").Missing("price")
terms := Aggregate("terms_price").Terms("price")
termsSize := Aggregate("terms_price_size").TermsWithSize("price", 0)
significantTerms := Aggregate("significant_terms_price").SignificantTerms("price")
histogram := Aggregate("histogram_price").Histogram("price", 50)

Expand All @@ -38,6 +39,7 @@ func TestAggregateDsl(t *testing.T) {
global,
missing,
terms,
termsSize,
significantTerms,
histogram,
)
Expand Down Expand Up @@ -97,6 +99,9 @@ func TestAggregateDsl(t *testing.T) {
"terms_price":{
"terms": { "field": "price" }
},
"terms_price_size":{
"terms": { "field": "price", "size": 0 }
},
"significant_terms_price":{
"significant_terms": { "field": "price" }
},
Expand Down

0 comments on commit db99d96

Please sign in to comment.