feat: add debug query output to elasticsearch_query (#9827)
This commit is contained in:
parent
56398237c4
commit
e615534620
|
|
@ -2,6 +2,7 @@ package elasticsearch_query
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -34,6 +35,16 @@ func (e *ElasticsearchQuery) runAggregationQuery(ctx context.Context, aggregatio
|
|||
query = query.Filter(elastic5.NewQueryStringQuery(filterQuery))
|
||||
query = query.Filter(elastic5.NewRangeQuery(aggregation.DateField).From(from).To(now))
|
||||
|
||||
src, err := query.Source()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get query source - %v", err)
|
||||
}
|
||||
data, err := json.Marshal(src)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal response - %v", err)
|
||||
}
|
||||
e.Log.Debugf("{\"query\": %s}", string(data))
|
||||
|
||||
search := e.esClient.Search().Index(aggregation.Index).Query(query).Size(0)
|
||||
|
||||
// add only parent elastic.Aggregations to the search request, all the rest are subaggregations of these
|
||||
|
|
|
|||
Loading…
Reference in New Issue