File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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" )
You can’t perform that action at this time.
0 commit comments