TP-5555 | clean up job
This commit is contained in:
@@ -19,15 +19,16 @@ const (
|
||||
SortQuery = `"sort": [ { "%s": { "order": "%s" } } ]`
|
||||
CollapseQuery = `"collapse": { "field": "%s" }`
|
||||
MatchAllQuery = `{ "match_all": {} }`
|
||||
MultiMatchQuery = `{"multi_match": { "query": "%s", "fields": [%s] }}`
|
||||
FromQuery = `"from": %d`
|
||||
SizeQuery = `"size": %d`
|
||||
SearchQuery = `"query": %s`
|
||||
FieldsQuery = `"fields": [ "%s" ]`
|
||||
EsQuery = "{ %s }"
|
||||
sourceQuery = `"_source": %t`
|
||||
sourceQuery = `"_source": [%s]`
|
||||
AggregationQuery = `"aggs": { %s }`
|
||||
AggregationQueryFormat = `"%s": { %s }` // aggregation name, aggregation query
|
||||
TermsAggregationQuery = `"terms": { "field": "%s", "size": %d }`
|
||||
TermsAggregationQuery = `"terms": { "field": "%s", "size": %d, %s}`
|
||||
MinAggregationQuery = `"min": { "field": "%s" }`
|
||||
MaxAggregationQuery = `"max": { "field": "%s" }`
|
||||
CardinalityAggregationQuery = `"cardinality": { "field": "%s" }`
|
||||
@@ -46,6 +47,7 @@ const (
|
||||
SearchAfter = `"search_after": [%s]`
|
||||
CompositeAggsQuery = `"composite": {"size" : %d, "sources" : [{"%s": {%s}}] }`
|
||||
CompositeAggsQueryWithAfterKey = `"composite": {"size" : %d, "after": {"%s": "%s"}, "sources" : [{"%s": {%s}}] }`
|
||||
OrderQuery = `"order": {"%s": "%s"}`
|
||||
|
||||
TopHitsAggsQuery = `"top_hits":{"size" : %d, "_source": {"includes" : [ %s ]}}`
|
||||
ValueCountAggsQuery = `"value_count" : {"field": "%s"}`
|
||||
@@ -124,6 +126,11 @@ func CreateMatchQuery(key string, value string) string {
|
||||
return fmt.Sprintf(MatchQuery, key, value)
|
||||
}
|
||||
|
||||
func CreateMultiMatchQuery(query string, fields ...string) string {
|
||||
// Join fields into a JSON array format: ["field1", "field2", "field3"]
|
||||
formattedFields := `"` + strings.Join(fields, `", "`) + `"`
|
||||
return fmt.Sprintf(MultiMatchQuery, query, formattedFields)
|
||||
}
|
||||
func CreateShouldQuery(filters ...string) string {
|
||||
return fmt.Sprintf(ShouldQuery, strings.Join(filters, ","))
|
||||
}
|
||||
@@ -167,8 +174,9 @@ func CreateEsQuery(query ...string) string {
|
||||
return fmt.Sprintf(EsQuery, strings.Join(query, ","))
|
||||
}
|
||||
|
||||
func CreateSourceQuery(source bool) string {
|
||||
return fmt.Sprintf(sourceQuery, source)
|
||||
func CreateSourceQuery(fields ...string) string {
|
||||
formattedFields := `"` + strings.Join(fields, `", "`) + `"`
|
||||
return fmt.Sprintf(sourceQuery, formattedFields)
|
||||
}
|
||||
|
||||
func CreateFilterAggregationQuery(value ...string) string {
|
||||
@@ -187,8 +195,8 @@ func CreateMaxAggregationQuery(field string) string {
|
||||
return fmt.Sprintf(MaxAggregationQuery, field)
|
||||
}
|
||||
|
||||
func CreateTermsAggregationQuery(field string, size int) string {
|
||||
return fmt.Sprintf(TermsAggregationQuery, field, size)
|
||||
func CreateTermsAggregationQuery(field string, size int, orderQuery string) string {
|
||||
return fmt.Sprintf(TermsAggregationQuery, field, size, orderQuery)
|
||||
}
|
||||
|
||||
func CreateTermsAggregationQueryWithoutSize(field string) string {
|
||||
@@ -266,3 +274,7 @@ func CreateTopHitsAggsQuery(size int, fields []string) string {
|
||||
func CreateValueCountAggsQuery(field string) string {
|
||||
return fmt.Sprintf(ValueCountAggsQuery, field)
|
||||
}
|
||||
|
||||
func CreateOrderQuery(field string, order string) string {
|
||||
return fmt.Sprintf(OrderQuery, field, order)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user