Skip to content

Commit 3ee08b3

Browse files
committed
[GRPC] Throw exceptions for currently unsupported request-side fields
Signed-off-by: Karen X <[email protected]>
1 parent b7f013f commit 3ee08b3

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
7272
- Bump opensearch-protobufs dependency to 0.24.0 and update transport-grpc module compatibility ([#20059](https://github.com/opensearch-project/OpenSearch/pull/20059))
7373

7474
- Refactor the ShardStats, WarmerStats and IndexingPressureStats class to use the Builder pattern instead of constructors ([#19966](https://github.com/opensearch-project/OpenSearch/pull/19966))
75+
- Throw exceptions for currently unsupported GRPC request-side fields ([#20162](https://github.com/opensearch-project/OpenSearch/pull/20162))
7576

7677
### Fixed
7778
- Fix Allocation and Rebalance Constraints of WeightFunction are incorrectly reset ([#19012](https://github.com/opensearch-project/OpenSearch/pull/19012))

modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/document/bulk/BulkRequestProtoUtils.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ public static org.opensearch.action.bulk.BulkRequest prepareRequest(BulkRequest
8585
)
8686
);
8787

88+
// Type is a deprecated field according to the spec, thus no plans to support it
89+
if (request.hasType()) {
90+
throw new UnsupportedOperationException("type param is not supported");
91+
}
92+
93+
// TODO support global_params
94+
if (request.hasGlobalParams()) {
95+
throw new UnsupportedOperationException("global_params param is not supported yet");
96+
}
97+
8898
return bulkRequest;
8999
}
90100
}

modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/search/SearchRequestProtoUtils.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ protected static void parseSearchRequest(
183183
? parseTimeValue(request.getCancelAfterTimeInterval(), null, "cancel_after_time_interval")
184184
: null
185185
);
186+
187+
// TODO support typed_keys
188+
if (request.hasTypedKeys()) {
189+
throw new UnsupportedOperationException("typed_keys param is not supported yet");
190+
}
191+
192+
// TODO support global_params
193+
if (request.hasGlobalParams()) {
194+
throw new UnsupportedOperationException("global_params param is not supported yet");
195+
}
186196
}
187197

188198
/**

modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/search/SearchSourceBuilderProtoUtils.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.opensearch.transport.grpc.proto.request.common.ScriptProtoUtils;
2222
import org.opensearch.transport.grpc.proto.request.search.query.AbstractQueryBuilderProtoUtils;
2323
import org.opensearch.transport.grpc.proto.request.search.sort.SortBuilderProtoUtils;
24-
import org.opensearch.transport.grpc.proto.request.search.suggest.SuggestBuilderProtoUtils;
2524
import org.opensearch.transport.grpc.spi.QueryBuilderProtoConverterRegistry;
2625

2726
import java.io.IOException;
@@ -154,15 +153,18 @@ private static void parseNonQueryFields(
154153
}
155154

156155
// TODO support aggregations
157-
/*
158-
if(protoRequest.hasAggs()){}
159-
*/
156+
if (protoRequest.getAggregationsCount() > 0) {
157+
throw new UnsupportedOperationException("aggregations param is not supported yet");
158+
}
160159

161160
if (protoRequest.hasHighlight()) {
162161
searchSourceBuilder.highlighter(HighlightBuilderProtoUtils.fromProto(protoRequest.getHighlight(), registry));
163162
}
163+
164+
// TODO support suggest
164165
if (protoRequest.hasSuggest()) {
165-
searchSourceBuilder.suggest(SuggestBuilderProtoUtils.fromProto(protoRequest.getSuggest()));
166+
throw new UnsupportedOperationException("suggest param is not supported yet");
167+
// searchSourceBuilder.suggest(SuggestBuilderProtoUtils.fromProto(protoRequest.getSuggest()));
166168
}
167169
if (protoRequest.getRescoreCount() > 0) {
168170
for (Rescore rescore : protoRequest.getRescoreList()) {

modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/search/query/TermsQueryBuilderProtoUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ private static TermsLookup parseTermsLookup(org.opensearch.protobufs.TermsLookup
249249
if (lookup.hasRouting()) {
250250
tl.routing(lookup.getRouting());
251251
}
252+
if (lookup.hasStore()) {
253+
tl.store(lookup.getStore());
254+
}
252255
return tl;
253256
}
254257
}

0 commit comments

Comments
 (0)