1
0
Fork 0

Adding upstream version 1.34.4.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-24 07:26:29 +02:00
parent e393c3af3f
commit 4978089aab
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4963 changed files with 677545 additions and 0 deletions

View file

@ -0,0 +1,45 @@
package opensearch_query
import (
"encoding/json"
"time"
)
type query struct {
Size int `json:"size"`
Aggregations aggregationRequest `json:"aggregations"`
Query interface{} `json:"query,omitempty"`
}
type boolQuery struct {
FilterQueryString string
TimestampField string
TimeRangeFrom time.Time
TimeRangeTo time.Time
DateFieldFormat string
}
// MarshalJSON customizes the JSON marshaling for boolQuery.
func (b *boolQuery) MarshalJSON() ([]byte, error) {
// Construct range
dateTimeRange := map[string]interface{}{
"from": b.TimeRangeFrom,
"to": b.TimeRangeTo,
"include_lower": true,
"include_upper": true,
}
if b.DateFieldFormat != "" {
dateTimeRange["format"] = b.DateFieldFormat
}
rangeFilter := map[string]map[string]interface{}{"range": {b.TimestampField: dateTimeRange}}
// Construct Filter
queryFilter := map[string]map[string]interface{}{
"query_string": {"query": b.FilterQueryString},
}
// Construct boolean query
bq := map[string]map[string]interface{}{"bool": {"filter": []interface{}{rangeFilter, queryFilter}}}
return json.Marshal(&bq)
}