Skip to content

Commit f4d7f0a

Browse files
authored
Merge branch 'main' into m-bilal/auto-refresh-auth
2 parents e095c17 + 9bb3b77 commit f4d7f0a

10 files changed

Lines changed: 28 additions & 15 deletions

File tree

connector/query.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,17 @@ func prepareElasticsearchQuery(ctx context.Context, request *schema.QueryRequest
190190
}
191191
if len(aggs) != 0 {
192192
query["aggs"] = aggs
193-
194-
// set query size to 0 if aggregation is present
195-
// this is because, by default, an aggregation query returns both the aggregation result and the hit documents
196-
// we only want the aggregation result
197-
// more reading: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html#return-only-agg-results
198-
query["size"] = 0
199193
}
194+
195+
// set query size to 0 if aggregation is present
196+
// this is because, by default, an aggregation query returns both the aggregation result and the hit documents
197+
// we only want the aggregation result
198+
// more reading: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html#return-only-agg-results
199+
query["size"] = 0
200+
201+
// set track_total_hits to true if aggregation is present
202+
// this is because, by default, a count query will only return 10,000 hits
203+
query["track_total_hits"] = true
200204
}
201205

202206
span.AddEvent("prepare_filter_query")

testdata/unit_tests/query_tests/payments/cardinality_aggregation/want.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
}
1212
}
1313
},
14-
"size": 0
14+
"size": 0,
15+
"track_total_hits": true
1516
}

testdata/unit_tests/query_tests/payments/count_aggregation/want.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"*"
55
]
66
},
7-
"size": 10000
7+
"size": 0,
8+
"track_total_hits": true
89
}

testdata/unit_tests/query_tests/payments/count_distinct_aggregation/want.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
}
1212
}
1313
},
14-
"size": 0
14+
"size": 0,
15+
"track_total_hits": true
1516
}

testdata/unit_tests/query_tests/payments/float_aggregations/want.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@
5353
}
5454
}
5555
},
56-
"size": 0
56+
"size": 0,
57+
"track_total_hits": true
5758
}

testdata/unit_tests/query_tests/payments/float_aggregations_with_range/want.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@
6161
}
6262
}
6363
},
64-
"size": 0
64+
"size": 0,
65+
"track_total_hits": true
6566
}

testdata/unit_tests/query_tests/payments/multiple_aggregations/want.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,6 @@
6060
}
6161
}
6262
},
63-
"size": 0
63+
"size": 0,
64+
"track_total_hits": true
6465
}

testdata/unit_tests/query_tests/payments/multiple_aggregations_with_where_clause/want.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,6 @@
6565
"customer_id": "CUST"
6666
}
6767
},
68-
"size": 0
68+
"size": 0,
69+
"track_total_hits": true
6970
}

testdata/unit_tests/query_tests/payments/nested_aggregations/want.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@
3131
}
3232
}
3333
},
34-
"size": 0
34+
"size": 0,
35+
"track_total_hits": true
3536
}

testdata/unit_tests/query_tests/payments/subfield_cardinality_aggregation/want.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
}
1212
}
1313
},
14-
"size": 0
14+
"size": 0,
15+
"track_total_hits": true
1516
}

0 commit comments

Comments
 (0)