search-collapse #6

Merged
maxim.yanchuk merged 17 commits from search-collapse into master 2023-11-01 21:11:52 +00:00
2 changed files with 8 additions and 2 deletions
Showing only changes of commit c2b5f62823 - Show all commits

View File

@ -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")))

View File

@ -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