diff --git a/aggregations_test.go b/aggregations_test.go index 949123d..8730966 100644 --- a/aggregations_test.go +++ b/aggregations_test.go @@ -82,8 +82,9 @@ func TestAggregations(t *testing.T) { }, "filtered": map[string]interface{}{ "filter": map[string]interface{}{ - "term": map[string]interface{}{ - "type": map[string]interface{}{ + "term": map[string]interface{} + "type": map[string]interface{} { + "value": "t-shirt", }, }, @@ -92,6 +93,7 @@ func TestAggregations(t *testing.T) { }, }, }, + { "order for termsAggs", //eq.Aggregate(eq.TermsAgg("a1", "FIELD1").Size(0).Aggs(eq.Sum("a2", "FIELD2.SUBFIELD"))) diff --git a/search.go b/search.go index d84bbae..5c661a2 100644 --- a/search.go +++ b/search.go @@ -26,6 +26,7 @@ type SearchRequest struct { sort Sort source Source timeout *time.Duration + } // Search creates a new SearchRequest object, to be filled via method chaining. @@ -112,6 +113,8 @@ func (req *SearchRequest) Highlight(highlight Mappable) *SearchRequest { return req } + + // Map implements the Mappable interface. It converts the request to into a // nested map[string]interface{}, as expected by the go-elasticsearch library. func (req *SearchRequest) Map() map[string]interface{} { @@ -152,6 +155,7 @@ func (req *SearchRequest) Map() map[string]interface{} { m["search_after"] = req.searchAfter } + source := req.source.Map() if len(source) > 0 { m["_source"] = source