Skip to content

Add protobuf definitions for min/max aggregation#410

Open
yiyuabc wants to merge 2 commits intoopensearch-project:mainfrom
yiyuabc:yiyupan/min-max-agg
Open

Add protobuf definitions for min/max aggregation#410
yiyuabc wants to merge 2 commits intoopensearch-project:mainfrom
yiyuabc:yiyupan/min-max-agg

Conversation

@yiyuabc
Copy link

@yiyuabc yiyuabc commented Mar 7, 2026

Description

 % git diff
diff --git a/protos/schemas/common.proto b/protos/schemas/common.proto
index 0746d3a..67c5112 100755
--- a/protos/schemas/common.proto
+++ b/protos/schemas/common.proto
@@ -134,7 +134,7 @@ message SearchRequestBody {
   optional TrackHits track_total_hits = 7;
 
   // [optional] Values used to boost the score of specified indexes. Specify in the format of <index> : <boost-multiplier>
-  map<string, float> indices_boost = 8;
+  map<string, float> indices_boost = 8 [deprecated = true];
 
   // [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.
   repeated FieldAndFormat docvalue_fields = 9;
@@ -210,6 +210,12 @@ message SearchRequestBody {
 
   // [optional]
   map<string, DerivedField> derived = 35;
+
+  // Defines the aggregations that are run as part of the search request.
+  map<string, AggregationContainer> aggregations = 36;
+
+  // [optional] Values used to boost the score of specified indexes. Specify in the format of <index> : <boost-multiplier>
+  repeated FloatMap indices_boost_2 = 37;
 }
 
 message DerivedField {
@@ -286,6 +292,8 @@ message SearchResponse {
 
   // [optional] If the query was terminated early, the terminated_early flag will be set to true in the response
   optional bool terminated_early = 13;
+
+  map<string, Aggregate> aggregations = 14;
 }
 
 message ProcessorExecutionDetail {
@@ -2908,6 +2916,70 @@ message ShardSearchFailure {
   ErrorCause reason = 4;
 }
 
+message Aggregate {
+
+  // The custom metadata attached to a resource.
+  optional ObjectMap meta = 1;
+
+  SingleMetricAggregateBaseValue value = 2;
+
+  optional string value_as_string = 3;
+}
+
+message AggregationContainer {
+
+  // Custom metadata to associate with the aggregation (optional)
+  optional ObjectMap meta = 1;
+  oneof aggregation_container {
+    MaxAggregation max = 2;
+
+    MinAggregation min = 3;
+
+  }
+}
+
+message FloatMap {
+
+  map<string, float> float_map = 1;
+}
+
+message MaxAggregation {
+
+  optional FieldValue missing = 1;
+
+  // The path to a field or an array of paths. Some APIs support wildcards in the path, which allows you to select multiple fields.
+  optional string field = 2;
+
+  optional Script script = 3;
+
+  optional string format = 4;
+
+  optional ValueType value_type = 5;
+}
+
+message MinAggregation {
+
+  optional FieldValue missing = 1;
+
+  // The path to a field or an array of paths. Some APIs support wildcards in the path, which allows you to select multiple fields.
+  optional string field = 2;
+
+  optional Script script = 3;
+
+  optional string format = 4;
+
+  optional ValueType value_type = 5;
+}
+
+message SingleMetricAggregateBaseValue {
+  oneof single_metric_aggregate_base_value {
+    double double = 1;
+
+    NullValue null_value = 2;
+
+  }
+}
+
 enum FieldValueFactorModifier {
   FIELD_VALUE_FACTOR_MODIFIER_UNSPECIFIED = 0;
   FIELD_VALUE_FACTOR_MODIFIER_LN = 1;
@@ -3243,6 +3315,23 @@ enum SimpleQueryStringFlag {
   SIMPLE_QUERY_STRING_FLAG_WHITESPACE = 13;
 }
 
+enum ValueType {
+  VALUE_TYPE_UNSPECIFIED = 0;
+  VALUE_TYPE_BOOLEAN = 1;
+  VALUE_TYPE_BYTE = 2;
+  VALUE_TYPE_DATE = 3;
+  VALUE_TYPE_DOUBLE = 4;
+  VALUE_TYPE_FLOAT = 5;
+  VALUE_TYPE_INTEGER = 6;
+  VALUE_TYPE_IP = 7;
+  VALUE_TYPE_LONG = 8;
+  VALUE_TYPE_NUMBER = 9;
+  VALUE_TYPE_NUMERIC = 10;
+  VALUE_TYPE_SHORT = 11;
+  VALUE_TYPE_STRING = 12;
+  VALUE_TYPE_UNSIGNED_LONG = 13;
+}
+
 message ObjectMap {
   map<string, Value> fields = 1;
 
(END)

Issues Resolved

List any issues this PR will resolve, e.g. Closes [...].

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@yiyuabc yiyuabc force-pushed the yiyupan/min-max-agg branch 2 times, most recently from 673e37c to db7f641 Compare March 7, 2026 05:47
yiyuabc added a commit to yiyuabc/opensearch-protobufs that referenced this pull request Mar 7, 2026
Co-Authored-By: Claude (claude-sonnet-4-5) <noreply@anthropic.com>
yiyuabc added a commit to yiyuabc/opensearch-protobufs that referenced this pull request Mar 7, 2026
Co-Authored-By: Claude (claude-sonnet-4-5) <noreply@anthropic.com>
Signed-off-by: Yiyu Pan <yypan14@gmail.com>
@yiyuabc yiyuabc force-pushed the yiyupan/min-max-agg branch from 5ea2e39 to e424e6c Compare March 7, 2026 05:53
yiyuabc added a commit to yiyuabc/opensearch-protobufs that referenced this pull request Mar 7, 2026
Co-Authored-By: Claude (claude-sonnet-4-5) <noreply@anthropic.com>
Signed-off-by: Yiyu Pan <yypan14@gmail.com>
@yiyuabc yiyuabc force-pushed the yiyupan/min-max-agg branch from e424e6c to b226528 Compare March 7, 2026 05:55
@yiyuabc yiyuabc force-pushed the yiyupan/min-max-agg branch from b226528 to d1b265b Compare March 12, 2026 17:23
Enable proto generation for min and max aggregations by removing from exclusion list:
- AggregationContainer
- Aggregate

Add exclusions for all other aggregation types (127 schemas) to ensure only min and max are generated.

Signed-off-by: Yiyu Pan <yypan14@gmail.com>
@yiyuabc yiyuabc force-pushed the yiyupan/min-max-agg branch from d1b265b to bd6fbcd Compare March 12, 2026 22:36
Signed-off-by: Yiyu Pan <yypan14@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant