Skip to content

Commit

Permalink
Merge pull request mattbaird#144 from nwolff/terms_aggregation_size
Browse files Browse the repository at this point in the history
allow setting of terms aggregation size
  • Loading branch information
mattbaird committed Dec 2, 2014
2 parents 48fd0d5 + d7e801d commit 7ec0f72
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/searchaggregate.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ type AggregateDsl struct {

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

/**
@@ -150,6 +151,12 @@ func (d *AggregateDsl) Terms(field string) *AggregateDsl {
return d
}

func (d *AggregateDsl) TermsWithSize(field string, size int) *AggregateDsl {
d.Type = FieldAggregate{Field: field, Size: size}
d.TypeName = "terms"
return d
}

func (d *AggregateDsl) SignificantTerms(field string) *AggregateDsl {
d.Type = FieldAggregate{Field: field}
d.TypeName = "significant_terms"
@@ -206,6 +213,7 @@ func (d *AggregateDsl) toMap() map[string]interface{} {
return root

}

func (d *AggregateDsl) aggregatesMap() map[string]interface{} {
root := map[string]interface{}{}

0 comments on commit 7ec0f72

Please sign in to comment.