Features: SearchAfter、Term Aggregation Order、Aggregation Include Filter Values (#14)
* Add support for multi_match queries * Add support for highlights * Add support for nested aggregations and filtered aggregations * Update README * Fix formatting * fix * feat: add support for search after * fix:set search after []string to []interface * fix:add .gitignore * feat:Support for term aggs order * Feat: Support include filter for termAggs * Update aggregations_test.go Fix conflict. * Update go.mod Co-authored-by: Caleb Champlin <caleb.champlin@gmail.com> Co-authored-by: Hardy <caoxiaozhen@secnium.com> Co-authored-by: Oran Moshai <12291998+oranmoshai@users.noreply.github.com>
This commit is contained in:
co-authored by
Caleb Champlin
Hardy
Oran Moshai
parent
fc16427405
commit
49a92fc25e
+70
-6
@@ -61,8 +61,8 @@ func TestAggregations(t *testing.T) {
|
||||
{
|
||||
"a complex, multi-aggregation, nested",
|
||||
Aggregate(
|
||||
NestedAgg("categories","categories").
|
||||
Aggs(TermsAgg("type","outdoors")),
|
||||
NestedAgg("categories", "categories").
|
||||
Aggs(TermsAgg("type", "outdoors")),
|
||||
FilterAgg("filtered",
|
||||
Term("type", "t-shirt")),
|
||||
),
|
||||
@@ -72,9 +72,9 @@ func TestAggregations(t *testing.T) {
|
||||
"nested": map[string]interface{}{
|
||||
"path": "categories",
|
||||
},
|
||||
"aggs": map[string]interface{} {
|
||||
"type": map[string]interface{} {
|
||||
"terms": map[string]interface{} {
|
||||
"aggs": map[string]interface{}{
|
||||
"type": map[string]interface{}{
|
||||
"terms": map[string]interface{}{
|
||||
"field": "outdoors",
|
||||
},
|
||||
},
|
||||
@@ -83,7 +83,7 @@ func TestAggregations(t *testing.T) {
|
||||
"filtered": map[string]interface{}{
|
||||
"filter": map[string]interface{}{
|
||||
"term": map[string]interface{}{
|
||||
"type": map[string]interface{} {
|
||||
"type": map[string]interface{}{
|
||||
"value": "t-shirt",
|
||||
},
|
||||
},
|
||||
@@ -92,5 +92,69 @@ func TestAggregations(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"order for termsAggs",
|
||||
//eq.Aggregate(eq.TermsAgg("a1", "FIELD1").Size(0).Aggs(eq.Sum("a2", "FIELD2.SUBFIELD")))
|
||||
Aggregate(
|
||||
TermsAgg("categories", "categories").
|
||||
Order(map[string]string{"priceSum": "desc"}).
|
||||
Size(5).Aggs(Sum("priceSum", "price"))),
|
||||
map[string]interface{}{
|
||||
"aggs": map[string]interface{}{
|
||||
"categories": map[string]interface{}{
|
||||
"terms": map[string]interface{}{
|
||||
"field": "categories",
|
||||
"order": map[string]interface{}{
|
||||
"priceSum": "desc",
|
||||
},
|
||||
"size": 5,
|
||||
},
|
||||
"aggs": map[string]interface{}{
|
||||
"priceSum": map[string]interface{}{
|
||||
"sum": map[string]interface{}{
|
||||
"field": "price",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"Single include for termsAggs",
|
||||
//eq.Aggregate(eq.TermsAgg("a1", "FIELD1").Size(0).Aggs(eq.Sum("a2", "FIELD2.SUBFIELD")))
|
||||
Aggregate(
|
||||
TermsAgg("categories", "categories").
|
||||
Include("red.*|blue.*"),
|
||||
),
|
||||
map[string]interface{}{
|
||||
"aggs": map[string]interface{}{
|
||||
"categories": map[string]interface{}{
|
||||
"terms": map[string]interface{}{
|
||||
"field": "categories",
|
||||
"include": "red.*|blue.*",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"Multi include for termsAggs",
|
||||
//eq.Aggregate(eq.TermsAgg("a1", "FIELD1").Size(0).Aggs(eq.Sum("a2", "FIELD2.SUBFIELD")))
|
||||
Aggregate(
|
||||
TermsAgg("categories", "categories").
|
||||
Include("red", "blue"),
|
||||
),
|
||||
map[string]interface{}{
|
||||
"aggs": map[string]interface{}{
|
||||
"categories": map[string]interface{}{
|
||||
"terms": map[string]interface{}{
|
||||
"field": "categories",
|
||||
"include": []string{"red", "blue"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user