Fix Aggregation schema structure and ValueType enum to match OpenSearch implementation#1060
Conversation
Proto Compatibility ReportMerge ReportNo changes detected. Generated by Proto Compatibility Check |
Changes AnalysisCommit SHA: 6fc9c48 API ChangesSummary
ReportThe full API changes report is available at: https://github.com/opensearch-project/opensearch-api-specification/actions/runs/22483516336/artifacts/5688839474 API Coverage
|
|
|
||
| - Fixed aggregation schema strict mode compliance: restructured `MetricAggregationBase` and `TermsAggregation` by moving `field` and `script` into optional `anyOf` branches; added `value_type` to `MinAggregation` and `MaxAggregation`; updated `ValueType` enum (added `byte`, `float`, `integer`, `range`, `short`, `unsigned_long`; removed `date_nanos`); changed `min_doc_count` and `shard_min_doc_count` in `TermsAggregation` from int32 to int64 ([#1056](https://github.com/opensearch-project/opensearch-api-specification/pull/1056)) | ||
| - Fixed `TermsAggregation` value_type type from `string` to `ValueType`, enforce enum ([#1057](https://github.com/opensearch-project/opensearch-api-specification/pull/1057)) | ||
| - Exclude FilterContainer and order in TermsAggregation in spec ([#1059](https://github.com/opensearch-project/opensearch-api-specification/pull/1059)) |
There was a problem hiding this comment.
This PR missed to add a changelog entry
| - Fixed `TermsAggregation` value_type type from `string` to `ValueType`, enforce enum | ||
|
|
||
| - Fixed aggregation schema strict mode compliance: restructured `MetricAggregationBase` and `TermsAggregation` by moving `field` and `script` into optional `anyOf` branches; added `value_type` to `MinAggregation` and `MaxAggregation`; updated `ValueType` enum (added `byte`, `float`, `integer`, `range`, `short`, `unsigned_long`; removed `date_nanos`); changed `min_doc_count` and `shard_min_doc_count` in `TermsAggregation` from int32 to int64 ([#1056](https://github.com/opensearch-project/opensearch-api-specification/pull/1056)) | ||
| - Fixed `TermsAggregation` value_type type from `string` to `ValueType`, enforce enum ([#1057](https://github.com/opensearch-project/opensearch-api-specification/pull/1057)) |
There was a problem hiding this comment.
This PR did not have PR # in entry, so backfilling now
AggregationContainer to inherit Aggregation type, and remove unnamed field name from Aggregation. Remove geo_point and range from ValueType. Exclude aggs alias from protobufs
…unnamed field `name` from `Aggregation`. Remove `geo_point` and `range` from `ValueType`. Exclude `aggs` alias from protobufs. Signed-off-by: Karen X <karenxyr@gmail.com>
AggregationContainer to inherit Aggregation type, and remove unnamed field name from Aggregation. Remove geo_point and range from ValueType. Exclude aggs alias from protobufsAggregationContainer to inherit Aggregation type, and remove unnamed field name from Aggregation. Remove geo_point and range from ValueType. Exclude aggs alias from protobufs
Signed-off-by: Karen X <karenxyr@gmail.com>
e58b5b0 to
3a784d2
Compare
| required: [filter] | ||
| unevaluatedProperties: true | ||
| - allOf: | ||
| - $ref: '#/components/schemas/BucketAggregationBase' |
There was a problem hiding this comment.
So now a filter aggregation can have:
- filter property (the query)
- aggs or aggregations property (sub-aggregations)
- meta property (metadata)
| title: aggregation_container | ||
| $ref: '#/components/schemas/AggregationContainer' | ||
| required: [aggs] | ||
| - not: |
There was a problem hiding this comment.
why do we need not/anyOf here, isn't oneOf good enough
There was a problem hiding this comment.
the third branch (the not/anyOf) is to account for the case where neither aggregations nor aggs is present (i.e. no sub-aggregations)
AggregationContainer to inherit Aggregation type, and remove unnamed field name from Aggregation. Remove geo_point and range from ValueType. Exclude aggs alias from protobufs
Description
1. Aggregation Name Field Error
Problem: The schema incorrectly modeled aggregation names as object properties with a
namefield.Before:
Reality: Aggregation names are JSON keys, not object properties:
{ "my_agg_name": { // ← Name is the key "terms": {...} } }Fix: Removed the unnamed
namefield from theAggregationschema. The name is represented by the key in the parent object'sadditionalPropertiesorpropertyNames.Reference: Java implementation uses
builder.startObject(name)inAbstractAggregationBuilder, notbuilder.field("name", name).2. ValueType Enum Mismatch
Problem: The
ValueTypeenum includedgeo_pointandrangewhich cannot be parsed from REST API requests.Evidence: In
ValueType.java, thelenientParse()method only accepts:"string", "long", "integer", "short", "double", "float", "date", "ip", "boolean", "unsigned_long", "number", "numeric""geo_point"or"range"These types are internal-only (used in Java code) but cannot be specified by API users.
Fix: Removed
geo_pointandrangefrom theValueTypeenum.3. BucketAggregationBase oneOf Validation Bug
Problem: Aggregations without sub-aggregations failed validation with error:
"MUST contain the missing properties: adjacency_matrix, auto_date_histogram, avg..."Root Cause: The
oneOfconstraint had only 2 branches without properrequiredfields:4. Filter Aggregation Sub-aggregation Support
Problem: The
filteraggregation was defined as a simple property without extendingBucketAggregationBase, preventing it from having sub-aggregations.Before:
This only allowed the
filterproperty. Using sub-aggregations like this would fail:{ "moviesWithHiddenCost": { "filter": {"term": {"cost_hidden": true}}, "aggs": { // <-- Not allowed "numOfDirectors": { "cardinality": {"field": "director_id"} } } } }Fix: Changed to
allOfthat extendsBucketAggregationBase:5. Request/Response Alias Handling
Context: Both
aggsandaggregationsare accepted in requests, but onlyaggregationsappears in responses.Fix: Added
x-protobuf-excluded: trueto theaggsproperty to exclude it from protobuf generation, since it's just an alias that only makes sense on the REST but not protobuf side.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.