Skip to content

Commit 35a9fea

Browse files
authored
Change manual proto from oneof bool to enum (opensearch-project#159)
Signed-off-by: xil <fridalu66@gmail.com>
1 parent 7b70995 commit 35a9fea

4 files changed

Lines changed: 77 additions & 163 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
88
### Changed
99
- Align manual proto with generated proto - search ([#154](https://github.com/opensearch-project/opensearch-protobufs/pull/154))
1010
- Update preprocessing - convert oneof const to enum ([#157](https://github.com/opensearch-project/opensearch-protobufs/pull/157))
11+
- Align manual proto with generated proto - enums ([#158](https://github.com/opensearch-project/opensearch-protobufs/pull/158))
1112

1213
### Removed
1314

protos/schemas/common.proto

Lines changed: 55 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,10 @@ message WaitForActiveShards {
1717
WaitForActiveShardOptions wait_for_active_shard_options = 2;
1818
}
1919
}
20-
message WaitForActiveShardOptions {
21-
22-
oneof wait_for_active_shard_options {
23-
// Wait for all shards to be active.
24-
bool wait_for_active_shard_options_all = 1;
25-
// null represents the default value (which defaults to one shard copy).
26-
NullValue null_value = 2;
27-
}
20+
enum WaitForActiveShardOptions {
21+
WAIT_FOR_ACTIVE_SHARD_OPTIONS_UNSPECIFIED = 0;
22+
WAIT_FOR_ACTIVE_SHARD_OPTIONS_ALL = 1;
23+
WAIT_FOR_ACTIVE_SHARD_OPTIONS_NULL = 2;
2824
}
2925

3026
message Script {
@@ -68,32 +64,19 @@ enum BuiltinScriptLanguage {
6864
BUILTIN_SCRIPT_LANGUAGE_PAINLESS = 4;
6965
}
7066

71-
message ExpandWildcard {
72-
oneof expand_wildcard {
73-
// Match any index, including hidden ones.
74-
bool expand_wildcard_all = 1;
75-
76-
// Match closed, non-hidden indexes.
77-
bool expand_wildcard_closed = 2;
78-
79-
// Match hidden indexes. Must be combined with `open`, `closed`, or both.
80-
bool expand_wildcard_hidden = 3;
81-
82-
// Wildcard expressions are not accepted.
83-
bool expand_wildcard_none = 4;
84-
85-
// Match open, non-hidden indexes.
86-
bool expand_wildcard_open = 5;
87-
}
67+
enum ExpandWildcard {
68+
EXPAND_WILDCARD_UNSPECIFIED = 0;
69+
EXPAND_WILDCARD_ALL = 1;
70+
EXPAND_WILDCARD_CLOSED = 2;
71+
EXPAND_WILDCARD_HIDDEN = 3;
72+
EXPAND_WILDCARD_NONE = 4;
73+
EXPAND_WILDCARD_OPEN = 5;
8874
}
8975

90-
message SearchType {
91-
oneof search_type {
92-
// Documents are scored using global term and document frequencies across all shards. This is usually slower but more accurate.
93-
bool search_type_dfs_query_then_fetch = 1;
94-
// Documents are scored using local term and document frequencies for the shard. This is usually faster but less accurate.
95-
bool search_type_query_then_fetch = 2;
96-
}
76+
enum SearchType {
77+
SEARCH_TYPE_UNSPECIFIED = 0;
78+
SEARCH_TYPE_DFS_QUERY_THEN_FETCH = 1;
79+
SEARCH_TYPE_QUERY_THEN_FETCH = 2;
9780
}
9881

9982
enum SuggestMode {
@@ -585,14 +568,11 @@ message HighlighterType {
585568
}
586569
}
587570

588-
message BuiltinHighlighterType {
589-
oneof builtin_highlighter_type {
590-
bool builtin_highlighter_type_plain = 1;
591-
592-
bool builtin_highlighter_type_fvh = 2;
593-
594-
bool builtin_highlighter_type_unified = 3;
595-
}
571+
enum BuiltinHighlighterType {
572+
BUILTIN_HIGHLIGHTER_TYPE_UNSPECIFIED = 0;
573+
BUILTIN_HIGHLIGHTER_TYPE_PLAIN = 1;
574+
BUILTIN_HIGHLIGHTER_TYPE_FVH = 2;
575+
BUILTIN_HIGHLIGHTER_TYPE_UNIFIED = 3;
596576
}
597577

598578
enum BoundaryScanner {
@@ -817,20 +797,12 @@ message FieldSort {
817797
optional string field = 8;
818798
}
819799

820-
message FieldSortNumericType {
821-
oneof field_sort_numeric_type {
822-
// The field contains date values.
823-
bool field_sort_numeric_type_date = 1;
824-
825-
// The field contains date values with nanosecond precision.
826-
bool field_sort_numeric_type_date_nanos = 2;
827-
828-
// The field contains double-precision floating-point values.
829-
bool field_sort_numeric_type_double = 3;
830-
831-
// The field contains long integer values.
832-
bool field_sort_numeric_type_long = 4;
833-
}
800+
enum FieldSortNumericType {
801+
FIELD_SORT_NUMERIC_TYPE_UNSPECIFIED = 0;
802+
FIELD_SORT_NUMERIC_TYPE_DATE = 1;
803+
FIELD_SORT_NUMERIC_TYPE_DATE_NANOS = 2;
804+
FIELD_SORT_NUMERIC_TYPE_DOUBLE = 3;
805+
FIELD_SORT_NUMERIC_TYPE_LONG = 4;
834806
}
835807

836808
enum FieldType {
@@ -907,33 +879,19 @@ enum SortOrder {
907879
SORT_ORDER_DESC = 2;
908880
}
909881

910-
message SortMode {
911-
oneof sort_mode {
912-
// Use the average of all values.
913-
bool sort_mode_avg = 1;
914-
915-
// Use the maximum value.
916-
bool sort_mode_max = 2;
917-
918-
// Use the median value.
919-
bool sort_mode_median = 3;
920-
921-
// Use the minimum value.
922-
bool sort_mode_min = 4;
923-
924-
// Use the sum of all values.
925-
bool sort_mode_sum = 5;
926-
}
882+
enum SortMode {
883+
SORT_MODE_UNSPECIFIED = 0;
884+
SORT_MODE_AVG = 1;
885+
SORT_MODE_MAX = 2;
886+
SORT_MODE_MEDIAN = 3;
887+
SORT_MODE_MIN = 4;
888+
SORT_MODE_SUM = 5;
927889
}
928890

929-
message GeoDistanceType {
930-
oneof geo_distance_type {
931-
// The arc calculation method uses great circle distance.
932-
bool geo_distance_type_arc = 1;
933-
934-
// The plane calculation method uses faster but less accurate flat-earth distance.
935-
bool geo_distance_type_plane = 2;
936-
}
891+
enum GeoDistanceType {
892+
GEO_DISTANCE_TYPE_UNSPECIFIED = 0;
893+
GEO_DISTANCE_TYPE_ARC = 1;
894+
GEO_DISTANCE_TYPE_PLANE = 2;
937895
}
938896

939897
message GeoDistanceSort {
@@ -964,28 +922,27 @@ enum GeoValidationMethod {
964922
GEO_VALIDATION_METHOD_STRICT = 3;
965923
}
966924

967-
message DistanceUnit {
968-
oneof distance_unit {
969-
bool distance_unit_cm = 1;
970-
971-
bool distance_unit_ft = 2;
972-
973-
bool distance_unit_in = 3;
974-
975-
bool distance_unit_km = 4;
976-
977-
bool distance_unit_m = 5;
978-
979-
bool distance_unit_mi = 6;
980-
981-
bool distance_unit_mm = 7;
982-
983-
bool distance_unit_nmi = 8;
925+
enum DistanceUnit {
926+
DISTANCE_UNIT_UNSPECIFIED = 0;
927+
DISTANCE_UNIT_CM = 1;
928+
DISTANCE_UNIT_FT = 2;
929+
DISTANCE_UNIT_IN = 3;
930+
DISTANCE_UNIT_KM = 4;
931+
DISTANCE_UNIT_M = 5;
932+
DISTANCE_UNIT_MI = 6;
933+
DISTANCE_UNIT_MM = 7;
934+
DISTANCE_UNIT_NMI = 8;
935+
DISTANCE_UNIT_YD = 9;
936+
}
984937

985-
bool distance_unit_yd = 9;
986-
}
938+
enum ScriptSortType {
939+
SCRIPT_SORT_TYPE_UNSPECIFIED = 0;
940+
SCRIPT_SORT_TYPE_NUMBER = 1;
941+
SCRIPT_SORT_TYPE_STRING = 2;
942+
SCRIPT_SORT_TYPE_VERSION = 3;
987943
}
988944

945+
989946
message ScriptSort {
990947

991948
// [optional] Specifies the sort order (asc or dsc) for the score.
@@ -996,29 +953,8 @@ message ScriptSort {
996953

997954
// [optional] Specifies script sort type.
998955
ScriptSortType type = 3;
999-
enum ScriptSortType {
1000-
SCRIPT_SORT_TYPE_UNSPECIFIED = 0;
1001-
SCRIPT_SORT_TYPE_NUMBER = 1;
1002-
SCRIPT_SORT_TYPE_STRING = 2;
1003-
SCRIPT_SORT_TYPE_VERSION = 3;
1004-
}
1005-
1006956
// [optional] Specifies what array value should be chosen for sorting the document.
1007957
SortMode mode = 4;
1008-
enum SortMode {
1009-
SORT_MODE_UNSPECIFIED = 0;
1010-
// Use the average of all values as sort value. Only applicable for number based array fields.
1011-
SORT_MODE_AVG = 1;
1012-
// Pick the highest value.
1013-
SORT_MODE_MAX = 2;
1014-
// Use the median of all values as sort value. Only applicable for number based array fields.
1015-
SORT_MODE_MEDIAN = 3;
1016-
// Pick the lowest value.
1017-
SORT_MODE_MIN = 4;
1018-
// Use the sum of all values as sort value. Only applicable for number based array fields.
1019-
SORT_MODE_SUM = 5;
1020-
}
1021-
1022958
// Supports sorting by fields that are inside one or more nested objects.
1023959
NestedSortValue nested = 5;
1024960

protos/schemas/document.proto

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -91,31 +91,20 @@ message UpdateAction {
9191
optional SourceConfig underscore_source = 7;
9292
}
9393

94-
message OpType {
95-
oneof op_type {
96-
// Create a new document.
97-
bool op_type_create = 1;
98-
99-
// Create a new document or replace an existing one.
100-
bool op_type_index = 2;
101-
}
94+
enum OpType {
95+
OP_TYPE_UNSPECIFIED = 0;
96+
OP_TYPE_CREATE = 1;
97+
OP_TYPE_INDEX = 2;
10298
}
10399

104-
message VersionType {
105-
oneof version_type {
106-
// The version number must be greater than the current version.
107-
bool version_type_external = 1;
108-
109-
// The version number must be greater than or equal to the current version.
110-
bool version_type_external_gte = 2;
111-
112-
// The version number is forced to be the given value.
113-
bool version_type_force = 3;
114-
115-
// The version number is managed internally by OpenSearch.
116-
bool version_type_internal = 4;
117-
}
100+
enum VersionType {
101+
VERSION_TYPE_UNSPECIFIED = 0;
102+
VERSION_TYPE_EXTERNAL = 1;
103+
VERSION_TYPE_EXTERNAL_GTE = 2;
104+
VERSION_TYPE_FORCE = 3;
105+
VERSION_TYPE_INTERNAL = 4;
118106
}
107+
119108
message IndexOperation {
120109
// [optional] The document ID. If no ID is specified, a document ID is automatically generated.
121110
optional string underscore_id = 1;
@@ -289,20 +278,12 @@ message InlineGetDictUserDefined {
289278
optional bytes underscore_source = 7;
290279
}
291280

292-
message Refresh {
293-
oneof refresh {
294-
// Whether to refresh the affected shards immediately.
295-
bool bool = 1;
296-
297-
// Do not refresh the affected shards.
298-
bool refresh_false = 2;
299-
300-
// Refresh the affected shards immediately.
301-
bool refresh_true = 3;
302-
303-
// Wait for the changes to become visible before replying.
304-
bool refresh_wait_for = 4;
305-
}
281+
enum Refresh {
282+
REFRESH_UNSPECIFIED = 0;
283+
REFRESH_BOOLEAN = 1;
284+
REFRESH_FALSE = 2;
285+
REFRESH_TRUE = 3;
286+
REFRESH_WAIT_FOR = 4;
306287
}
307288

308289
// index document.

protos/schemas/search.proto

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,10 @@ message HitsMetadata {
430430
optional HitsMetadataMaxScore max_score = 3;
431431
}
432432

433-
message TotalHitsRelation {
434-
oneof total_hits_relation {
435-
// Accurate.
436-
bool total_hits_relation_eq = 1;
437-
438-
// Lower bound, including returned events or sequences.
439-
bool total_hits_relation_gte = 2;
440-
}
433+
enum TotalHitsRelation {
434+
TOTAL_HITS_RELATION_UNSPECIFIED = 0;
435+
TOTAL_HITS_RELATION_EQ = 1;
436+
TOTAL_HITS_RELATION_GTE = 2;
441437
}
442438

443439
message TotalHits {

0 commit comments

Comments
 (0)