Skip to content

Commit 673e37c

Browse files
committed
Add min/max aggregation
Signed-off-by: Yiyu Pan <yypan14@gmail.com>
1 parent 065ad2b commit 673e37c

File tree

2 files changed

+239
-3
lines changed

2 files changed

+239
-3
lines changed

protos/schemas/common.proto

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ message SearchRequestBody {
134134
optional TrackHits track_total_hits = 7;
135135

136136
// [optional] Values used to boost the score of specified indexes. Specify in the format of <index> : <boost-multiplier>
137-
map<string, float> indices_boost = 8;
137+
map<string, float> indices_boost = 8 [deprecated = true];
138138

139139
// [optional] The fields that OpenSearch should return using their docvalue forms. Specify a format to return results in a certain format, such as date and time.
140140
repeated FieldAndFormat docvalue_fields = 9;
@@ -210,6 +210,12 @@ message SearchRequestBody {
210210

211211
// [optional]
212212
map<string, DerivedField> derived = 35;
213+
214+
// Defines the aggregations that are run as part of the search request.
215+
map<string, AggregationContainer> aggregations = 36;
216+
217+
// [optional] Values used to boost the score of specified indexes. Specify in the format of <index> : <boost-multiplier>
218+
repeated FloatMap indices_boost_2 = 37;
213219
}
214220

215221
message DerivedField {
@@ -286,6 +292,8 @@ message SearchResponse {
286292

287293
// [optional] If the query was terminated early, the terminated_early flag will be set to true in the response
288294
optional bool terminated_early = 13;
295+
296+
map<string, Aggregate> aggregations = 14;
289297
}
290298

291299
message ProcessorExecutionDetail {
@@ -2908,6 +2916,93 @@ message ShardSearchFailure {
29082916
ErrorCause reason = 4;
29092917
}
29102918

2919+
message Aggregate {
2920+
2921+
optional MaxAggregate max = 1;
2922+
2923+
optional MinAggregate min = 2;
2924+
}
2925+
2926+
message AggregationContainer {
2927+
2928+
// Custom metadata to associate with the aggregation (optional)
2929+
optional ObjectMap meta = 1;
2930+
oneof aggregation_container {
2931+
MaxAggregation max = 2;
2932+
2933+
MinAggregation min = 3;
2934+
2935+
}
2936+
}
2937+
2938+
message FloatMap {
2939+
2940+
map<string, float> float_map = 1;
2941+
}
2942+
2943+
message MaxAggregate {
2944+
2945+
// The custom metadata attached to a resource.
2946+
optional ObjectMap meta = 1;
2947+
2948+
SingleMetricAggregateBaseAllOfValue value = 2;
2949+
2950+
optional string value_as_string = 3;
2951+
}
2952+
2953+
message MaxAggregation {
2954+
2955+
// Custom metadata to associate with the aggregation (optional)
2956+
optional ObjectMap meta = 1;
2957+
2958+
optional FieldValue missing = 2;
2959+
2960+
// The path to a field or an array of paths. Some APIs support wildcards in the path, which allows you to select multiple fields.
2961+
optional string field = 3;
2962+
2963+
optional Script script = 4;
2964+
2965+
optional string format = 5;
2966+
2967+
optional ValueType value_type = 6;
2968+
}
2969+
2970+
message MinAggregate {
2971+
2972+
// The custom metadata attached to a resource.
2973+
optional ObjectMap meta = 1;
2974+
2975+
SingleMetricAggregateBaseAllOfValue value = 2;
2976+
2977+
optional string value_as_string = 3;
2978+
}
2979+
2980+
message MinAggregation {
2981+
2982+
// Custom metadata to associate with the aggregation (optional)
2983+
optional ObjectMap meta = 1;
2984+
2985+
optional FieldValue missing = 2;
2986+
2987+
// The path to a field or an array of paths. Some APIs support wildcards in the path, which allows you to select multiple fields.
2988+
optional string field = 3;
2989+
2990+
optional Script script = 4;
2991+
2992+
optional string format = 5;
2993+
2994+
optional ValueType value_type = 6;
2995+
}
2996+
2997+
message SingleMetricAggregateBaseAllOfValue {
2998+
oneof single_metric_aggregate_base_all_of_value {
2999+
double double = 1;
3000+
3001+
NullValue null_value = 2;
3002+
3003+
}
3004+
}
3005+
29113006
enum FieldValueFactorModifier {
29123007
FIELD_VALUE_FACTOR_MODIFIER_UNSPECIFIED = 0;
29133008
FIELD_VALUE_FACTOR_MODIFIER_LN = 1;
@@ -3243,6 +3338,23 @@ enum SimpleQueryStringFlag {
32433338
SIMPLE_QUERY_STRING_FLAG_WHITESPACE = 13;
32443339
}
32453340

3341+
enum ValueType {
3342+
VALUE_TYPE_UNSPECIFIED = 0;
3343+
VALUE_TYPE_BOOLEAN = 1;
3344+
VALUE_TYPE_BYTE = 2;
3345+
VALUE_TYPE_DATE = 3;
3346+
VALUE_TYPE_DOUBLE = 4;
3347+
VALUE_TYPE_FLOAT = 5;
3348+
VALUE_TYPE_INTEGER = 6;
3349+
VALUE_TYPE_IP = 7;
3350+
VALUE_TYPE_LONG = 8;
3351+
VALUE_TYPE_NUMBER = 9;
3352+
VALUE_TYPE_NUMERIC = 10;
3353+
VALUE_TYPE_SHORT = 11;
3354+
VALUE_TYPE_STRING = 12;
3355+
VALUE_TYPE_UNSIGNED_LONG = 13;
3356+
}
3357+
32463358
message ObjectMap {
32473359
map<string, Value> fields = 1;
32483360

tools/proto-convert/src/config/spec-filter.yaml

Lines changed: 126 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ x-operation-groups:
66
# Schemas to exclude from proto generation
77
# These schemas and their nested dependencies will not be included
88
excluded_schemas:
9-
- AggregationContainer
10-
- Aggregate
119
- Suggester
1210
- Suggest
1311
- DisMaxQuery
@@ -39,3 +37,129 @@ excluded_schemas:
3937
- TypeQuery
4038
- WrapperQuery
4139
- XyShapeQuery
40+
41+
# AggregationContainer - exclude all except TermsAggregation
42+
- AdjacencyMatrixAggregation
43+
- AutoDateHistogramAggregation
44+
- AverageAggregation
45+
- AverageBucketAggregation
46+
- BoxplotAggregation
47+
- BucketScriptAggregation
48+
- BucketSelectorAggregation
49+
- BucketSortAggregation
50+
- CardinalityAggregation
51+
- ChildrenAggregation
52+
- CompositeAggregation
53+
- CumulativeCardinalityAggregation
54+
- CumulativeSumAggregation
55+
- DateHistogramAggregation
56+
- DateRangeAggregation
57+
- DerivativeAggregation
58+
- DiversifiedSamplerAggregation
59+
- ExtendedStatsAggregation
60+
- ExtendedStatsBucketAggregation
61+
- FiltersAggregation
62+
- GeoBoundsAggregation
63+
- GeoCentroidAggregation
64+
- GeoDistanceAggregation
65+
- GeoHashGridAggregation
66+
- GeoTileGridAggregation
67+
- GlobalAggregation
68+
- HistogramAggregation
69+
- IpRangeAggregation
70+
- MatrixStatsAggregation
71+
- MaxBucketAggregation
72+
- MedianAbsoluteDeviationAggregation
73+
- MinBucketAggregation
74+
- MissingAggregation
75+
- MovingAverageAggregation
76+
- MovingFunctionAggregation
77+
- MovingPercentilesAggregation
78+
- MultiTermsAggregation
79+
- NestedAggregation
80+
- NormalizeAggregation
81+
- ParentAggregation
82+
- PercentileRanksAggregation
83+
- PercentilesAggregation
84+
- PercentilesBucketAggregation
85+
- RangeAggregation
86+
- RareTermsAggregation
87+
- RateAggregation
88+
- ReverseNestedAggregation
89+
- SamplerAggregation
90+
- ScriptedMetricAggregation
91+
- SerialDifferencingAggregation
92+
- SignificantTermsAggregation
93+
- SignificantTextAggregation
94+
- StatsAggregation
95+
- StatsBucketAggregation
96+
- SumAggregation
97+
- SumBucketAggregation
98+
- TermsAggregation
99+
- TopHitsAggregation
100+
- TTestAggregation
101+
- ValueCountAggregation
102+
- VariableWidthHistogramAggregation
103+
- WeightedAverageAggregation
104+
105+
# Aggregate - exclude all except TermsAggregate variants (DoubleTerms, LongTerms, StringTerms, UnmappedTerms)
106+
- AdjacencyMatrixAggregate
107+
- AutoDateHistogramAggregate
108+
- AvgAggregate
109+
- BoxPlotAggregate
110+
- BucketMetricValueAggregate
111+
- CardinalityAggregate
112+
- ChildrenAggregate
113+
- CompositeAggregate
114+
- CumulativeCardinalityAggregate
115+
- DateHistogramAggregate
116+
- DateRangeAggregate
117+
- DerivativeAggregate
118+
- DoubleTermsAggregate
119+
- ExtendedStatsAggregate
120+
- ExtendedStatsBucketAggregate
121+
- FilterAggregate
122+
- FiltersAggregate
123+
- GeoBoundsAggregate
124+
- GeoCentroidAggregate
125+
- GeoDistanceAggregate
126+
- GeoHashGridAggregate
127+
- GeoTileGridAggregate
128+
- GlobalAggregate
129+
- HdrPercentileRanksAggregate
130+
- HdrPercentilesAggregate
131+
- HistogramAggregate
132+
- IpRangeAggregate
133+
- LongTermsAggregate
134+
- LongRareTermsAggregate
135+
- MatrixStatsAggregate
136+
- MedianAbsoluteDeviationAggregate
137+
- MissingAggregate
138+
- MultiTermsAggregate
139+
- NestedAggregate
140+
- ParentAggregate
141+
- PercentilesBucketAggregate
142+
- RangeAggregate
143+
- RateAggregate
144+
- ReverseNestedAggregate
145+
- SamplerAggregate
146+
- ScriptedMetricAggregate
147+
- SignificantLongTermsAggregate
148+
- SignificantStringTermsAggregate
149+
- SimpleValueAggregate
150+
- StatsAggregate
151+
- StatsBucketAggregate
152+
- StringTermsAggregate
153+
- StringRareTermsAggregate
154+
- SumAggregate
155+
- TDigestPercentileRanksAggregate
156+
- TDigestPercentilesAggregate
157+
- TopHitsAggregate
158+
- TTestAggregate
159+
- UnmappedRareTermsAggregate
160+
- UnmappedSignificantTermsAggregate
161+
- UnmappedTermsAggregate
162+
- UnsignedLongTermsAggregate
163+
- ValueCountAggregate
164+
- VariableWidthHistogramAggregate
165+
- WeightedAvgAggregate

0 commit comments

Comments
 (0)