Merge branch 'master' into master

This commit is contained in:
Hardy 2021-03-15 10:32:29 +08:00 committed by GitHub
commit c2b5f62823
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -82,8 +82,9 @@ func TestAggregations(t *testing.T) {
}, },
"filtered": map[string]interface{}{ "filtered": map[string]interface{}{
"filter": map[string]interface{}{ "filter": map[string]interface{}{
"term": map[string]interface{}{ "term": map[string]interface{}
"type": map[string]interface{}{ "type": map[string]interface{} {
"value": "t-shirt", "value": "t-shirt",
}, },
}, },
@ -92,6 +93,7 @@ func TestAggregations(t *testing.T) {
}, },
}, },
}, },
{ {
"order for termsAggs", "order for termsAggs",
//eq.Aggregate(eq.TermsAgg("a1", "FIELD1").Size(0).Aggs(eq.Sum("a2", "FIELD2.SUBFIELD"))) //eq.Aggregate(eq.TermsAgg("a1", "FIELD1").Size(0).Aggs(eq.Sum("a2", "FIELD2.SUBFIELD")))

View File

@ -26,6 +26,7 @@ type SearchRequest struct {
sort Sort sort Sort
source Source source Source
timeout *time.Duration timeout *time.Duration
} }
// Search creates a new SearchRequest object, to be filled via method chaining. // 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 return req
} }
// Map implements the Mappable interface. It converts the request to into a // Map implements the Mappable interface. It converts the request to into a
// nested map[string]interface{}, as expected by the go-elasticsearch library. // nested map[string]interface{}, as expected by the go-elasticsearch library.
func (req *SearchRequest) Map() map[string]interface{} { func (req *SearchRequest) Map() map[string]interface{} {
@ -152,6 +155,7 @@ func (req *SearchRequest) Map() map[string]interface{} {
m["search_after"] = req.searchAfter m["search_after"] = req.searchAfter
} }
source := req.source.Map() source := req.source.Map()
if len(source) > 0 { if len(source) > 0 {
m["_source"] = source m["_source"] = source