Skip to content

Changed DistanceFeatureQuery and RangeQuery from allOf + oneOf to oneOf + allOf #865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 2025

Conversation

lucy66hw
Copy link
Contributor

@lucy66hw lucy66hw commented Apr 10, 2025

Description

Changed DistanceFeatureQuery and RangeQuery from allOf + oneOf to oneOf + allOf.

The original structure (allOf + oneOf) is not well-supported by the OpenAPI Protobuf generator, as it causes to the loss of mutual exclusivity in the flattened models.

This change does not affect REST API behavior or payloads.

Before the change. All fields from variants are flattened into a single message.

message RangeQuery {

  // Floating point number used to decrease or increase the relevance scores of the query. Boost values are relative to the default value of 1.0. A boost value between 0 and 1.0 decreases the relevance score. A value greater than 1.0 increases the relevance score.
  optional float boost = 1;

  optional string underscore_name = 2;

  optional RangeRelation relation = 3;

  optional string gt = 4;

  optional string gte = 5;

  optional string lt = 6;

  optional string lte = 7;

  optional string from = 8;

  optional string to = 9;

  // The date format pattern.
  optional string format = 10;

  // The time zone identifier.
  optional string time_zone = 11;

}

After the change

message RangeQuery {
  oneof range_query {
    RangeQueryOneOf range_query_one_of = 1;
    
    RangeQueryOneOf1 range_query_one_of1 = 2;
  }
}
message RangeQueryOneOf {
  // Floating point number used to decrease or increase the relevance scores of
  // the query. Boost values are relative to the default value of 1.0. A boost
  // value between 0 and 1.0 decreases the relevance score. A value greater
  // than 1.0 increases the relevance score.
  optional float boost = 1;

  optional string underscore_name = 2;

  optional RangeRelation relation = 3;

  // Greater than.
  optional double gt = 4;

  // Greater than or equal to.
  optional double gte = 5;

  // Less than.
  optional double lt = 6;

  // Less than or equal to.
  optional double lte = 7;

  optional NumberRangeQueryParametersFrom from = 8;

  optional NumberRangeQueryParametersTo to = 9;
}
message RangeQueryOneOf1 {
  // Floating point number used to decrease or increase the relevance scores of
  // the query. Boost values are relative to the default value of 1.0. A boost
  // value between 0 and 1.0 decreases the relevance score. A value greater
  // than 1.0 increases the relevance score.
  optional float boost = 1;

  optional string underscore_name = 2;

  optional RangeRelation relation = 3;

  optional string gt = 4;

  optional string gte = 5;

  optional string lt = 6;

  optional string lte = 7;

  optional string from = 8;

  optional string to = 9;

  // The date format pattern.
  optional string format = 10;

  // The time zone identifier.
  optional string time_zone = 11;
}
message RangeQueryBase {
  // Floating point number used to decrease or increase the relevance scores of
  // the query. Boost values are relative to the default value of 1.0. A boost
  // value between 0 and 1.0 decreases the relevance score. A value greater
  // than 1.0 increases the relevance score.
  optional float boost = 1;

  optional string underscore_name = 2;

  optional RangeRelation relation = 3;
}

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.

Copy link
Contributor

github-actions bot commented Apr 10, 2025

Changes Analysis

Commit SHA: f8edc1c
Comparing To SHA: 0d01e0d

API Changes

Summary

└─┬Components
  ├─┬_common.query_dsl___RangeQuery
  │ ├──[➕] oneOf (45713:11)
  │ ├──[➕] oneOf (45716:11)
  │ ├──[➖] allOf (45716:7)❌ 
  │ └──[➖] allOf (45712:11)❌ 
  └─┬_common.query_dsl___DistanceFeatureQuery
    ├──[➕] oneOf (44236:11)
    ├──[➕] oneOf (44250:11)
    ├──[➖] allOf (45357:7)❌ 
    └──[➖] allOf (44237:11)❌ 

Document Element Total Changes Breaking Changes
components 8 4
  • BREAKING Changes: 4 out of 8
  • Removals: 4
  • Additions: 4
  • Breaking Removals: 4

Report

The full API changes report is available at: https://github.com/opensearch-project/opensearch-api-specification/actions/runs/14392379107/artifacts/2923946656

API Coverage

Before After Δ
Covered (%) 663 (64.94 %) 663 (64.94 %) 0 (0 %)
Uncovered (%) 358 (35.06 %) 358 (35.06 %) 0 (0 %)
Unknown 49 49 0

Copy link
Contributor

Spec Test Coverage Analysis

Total Tested
599 597 (99.67 %)

Signed-off-by: xil <[email protected]>
@lucy66hw lucy66hw marked this pull request as ready for review April 10, 2025 21:39
@dblock
Copy link
Member

dblock commented Apr 10, 2025

Add a test that returns this data that fails without this change?

@lucy66hw
Copy link
Contributor Author

@dblock I paste the generated protobuf difference between before change and after change. Without this change, the generated protobuf is not accurate.

@dblock
Copy link
Member

dblock commented Apr 11, 2025

@dblock I paste the generated protobuf difference between before change and after change. Without this change, the generated protobuf is not accurate.

This is not a test for this repo. Please see https://github.com/opensearch-project/opensearch-api-specification/blob/main/TESTING_GUIDE.md.

I re-read "The original structure (allOf + oneOf) is not well-supported by the OpenAPI Protobuf generator, as it causes to the loss of mutual exclusivity in the flattened models.", so this is not a schema change, just to accommodate the generator. Sorry for the noise.

@dblock dblock merged commit 82c03ce into opensearch-project:main Apr 11, 2025
32 checks passed
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.

2 participants