Skip to content

Commit a4b9efb

Browse files
authored
path/query params exclude null from json ser (#1222)
1 parent 757d274 commit a4b9efb

187 files changed

Lines changed: 1227 additions & 1072 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

java-client/src/main/java/co/elastic/clients/elasticsearch/ElasticsearchAsyncClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4366,8 +4366,8 @@ public final CompletableFuture<RankEvalResponse> rankEval(
43664366
* cluster. If reindexing from a remote cluster into an Elastic Cloud Serverless
43674367
* project, only remote hosts from <a href=
43684368
* "https://cloud.elastic.co/registration?page=docs&amp;placement=docs-body">Elastic
4369-
* Cloud Hosted and Elastic Cloud Serverless</a> are allowed. Automatic data
4370-
* stream creation requires a matching index template with data stream enabled.
4369+
* Cloud Hosted</a> are allowed. Automatic data stream creation requires a
4370+
* matching index template with data stream enabled.
43714371
* <p>
43724372
* The <code>dest</code> element can be configured like the index API to control
43734373
* optimistic concurrency control. Omitting <code>version_type</code> or setting
@@ -4463,8 +4463,8 @@ public CompletableFuture<ReindexResponse> reindex(ReindexRequest request) {
44634463
* cluster. If reindexing from a remote cluster into an Elastic Cloud Serverless
44644464
* project, only remote hosts from <a href=
44654465
* "https://cloud.elastic.co/registration?page=docs&amp;placement=docs-body">Elastic
4466-
* Cloud Hosted and Elastic Cloud Serverless</a> are allowed. Automatic data
4467-
* stream creation requires a matching index template with data stream enabled.
4466+
* Cloud Hosted</a> are allowed. Automatic data stream creation requires a
4467+
* matching index template with data stream enabled.
44684468
* <p>
44694469
* The <code>dest</code> element can be configured like the index API to control
44704470
* optimistic concurrency control. Omitting <code>version_type</code> or setting

java-client/src/main/java/co/elastic/clients/elasticsearch/ElasticsearchClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4398,8 +4398,8 @@ public final RankEvalResponse rankEval(Function<RankEvalRequest.Builder, ObjectB
43984398
* cluster. If reindexing from a remote cluster into an Elastic Cloud Serverless
43994399
* project, only remote hosts from <a href=
44004400
* "https://cloud.elastic.co/registration?page=docs&amp;placement=docs-body">Elastic
4401-
* Cloud Hosted and Elastic Cloud Serverless</a> are allowed. Automatic data
4402-
* stream creation requires a matching index template with data stream enabled.
4401+
* Cloud Hosted</a> are allowed. Automatic data stream creation requires a
4402+
* matching index template with data stream enabled.
44034403
* <p>
44044404
* The <code>dest</code> element can be configured like the index API to control
44054405
* optimistic concurrency control. Omitting <code>version_type</code> or setting
@@ -4495,8 +4495,8 @@ public ReindexResponse reindex(ReindexRequest request) throws IOException, Elast
44954495
* cluster. If reindexing from a remote cluster into an Elastic Cloud Serverless
44964496
* project, only remote hosts from <a href=
44974497
* "https://cloud.elastic.co/registration?page=docs&amp;placement=docs-body">Elastic
4498-
* Cloud Hosted and Elastic Cloud Serverless</a> are allowed. Automatic data
4499-
* stream creation requires a matching index template with data stream enabled.
4498+
* Cloud Hosted</a> are allowed. Automatic data stream creation requires a
4499+
* matching index template with data stream enabled.
45004500
* <p>
45014501
* The <code>dest</code> element can be configured like the index API to control
45024502
* optimistic concurrency control. Omitting <code>version_type</code> or setting

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/BucketsPath.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private BucketsPath(Kind kind, Object value) {
9696
public String _toJsonString() {
9797
switch (_kind) {
9898
case Array :
99-
return this.array().stream().map(v -> v).collect(Collectors.joining(","));
99+
return this.array().stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(","));
100100
case Dict :
101101
return this.dict().entrySet().stream().map(e -> e.getKey() + ":" + e.getValue())
102102
.collect(Collectors.joining(","));

java-client/src/main/java/co/elastic/clients/elasticsearch/_types/aggregations/TermsExclude.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private TermsExclude(Kind kind, Object value) {
9292
public String _toJsonString() {
9393
switch (_kind) {
9494
case Terms :
95-
return this.terms().stream().map(v -> v).collect(Collectors.joining(","));
95+
return this.terms().stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(","));
9696
case Regexp :
9797
return this.regexp();
9898

java-client/src/main/java/co/elastic/clients/elasticsearch/async_search/SubmitRequest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,7 +2585,8 @@ protected static void setupSubmitRequestDeserializer(ObjectDeserializer<SubmitRe
25852585
if (propsSet == (_index)) {
25862586
StringBuilder buf = new StringBuilder();
25872587
buf.append("/");
2588-
SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf);
2588+
SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).filter(Objects::nonNull)
2589+
.collect(Collectors.joining(",")), buf);
25892590
buf.append("/_async_search");
25902591
return buf.toString();
25912592
}
@@ -2606,7 +2607,8 @@ protected static void setupSubmitRequestDeserializer(ObjectDeserializer<SubmitRe
26062607
if (propsSet == 0) {
26072608
}
26082609
if (propsSet == (_index)) {
2609-
params.put("index", request.index.stream().map(v -> v).collect(Collectors.joining(",")));
2610+
params.put("index", request.index.stream().map(v -> v).filter(Objects::nonNull)
2611+
.collect(Collectors.joining(",")));
26102612
}
26112613
return params;
26122614
},
@@ -2622,7 +2624,8 @@ protected static void setupSubmitRequestDeserializer(ObjectDeserializer<SubmitRe
26222624
params.put("lenient", String.valueOf(request.lenient));
26232625
}
26242626
if (ApiTypeHelper.isDefined(request.routing)) {
2625-
params.put("routing", request.routing.stream().map(v -> v).collect(Collectors.joining(",")));
2627+
params.put("routing", request.routing.stream().map(v -> v).filter(Objects::nonNull)
2628+
.collect(Collectors.joining(",")));
26262629
}
26272630
if (request.ignoreUnavailable != null) {
26282631
params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable));
@@ -2646,8 +2649,8 @@ protected static void setupSubmitRequestDeserializer(ObjectDeserializer<SubmitRe
26462649
params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults));
26472650
}
26482651
if (ApiTypeHelper.isDefined(request.expandWildcards)) {
2649-
params.put("expand_wildcards",
2650-
request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(",")));
2652+
params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue())
2653+
.filter(Objects::nonNull).collect(Collectors.joining(",")));
26512654
}
26522655
if (request.preference != null) {
26532656
params.put("preference", request.preference);

java-client/src/main/java/co/elastic/clients/elasticsearch/cat/AliasesRequest.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,9 @@ public Builder rebuild() {
486486
buf.append("/_cat");
487487
buf.append("/aliases");
488488
buf.append("/");
489-
SimpleEndpoint.pathEncode(request.name.stream().map(v -> v).collect(Collectors.joining(",")), buf);
489+
SimpleEndpoint.pathEncode(
490+
request.name.stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(",")),
491+
buf);
490492
return buf.toString();
491493
}
492494
throw SimpleEndpoint.noPathTemplateFound("path");
@@ -506,7 +508,8 @@ public Builder rebuild() {
506508
if (propsSet == 0) {
507509
}
508510
if (propsSet == (_name)) {
509-
params.put("name", request.name.stream().map(v -> v).collect(Collectors.joining(",")));
511+
params.put("name", request.name.stream().map(v -> v).filter(Objects::nonNull)
512+
.collect(Collectors.joining(",")));
510513
}
511514
return params;
512515
},
@@ -519,17 +522,19 @@ public Builder rebuild() {
519522
params.put("master_timeout", request.masterTimeout._toJsonString());
520523
}
521524
if (ApiTypeHelper.isDefined(request.s)) {
522-
params.put("s", request.s.stream().map(v -> v).collect(Collectors.joining(",")));
525+
params.put("s",
526+
request.s.stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(",")));
523527
}
524528
if (ApiTypeHelper.isDefined(request.expandWildcards)) {
525-
params.put("expand_wildcards",
526-
request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(",")));
529+
params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue())
530+
.filter(Objects::nonNull).collect(Collectors.joining(",")));
527531
}
528532
if (request.bytes != null) {
529533
params.put("bytes", request.bytes.jsonValue());
530534
}
531535
if (ApiTypeHelper.isDefined(request.h)) {
532-
params.put("h", request.h.stream().map(v -> v).collect(Collectors.joining(",")));
536+
params.put("h",
537+
request.h.stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(",")));
533538
}
534539
if (request.time != null) {
535540
params.put("time", request.time.jsonValue());

java-client/src/main/java/co/elastic/clients/elasticsearch/cat/AllocationRequest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ public Builder rebuild() {
460460
buf.append("/_cat");
461461
buf.append("/allocation");
462462
buf.append("/");
463-
SimpleEndpoint.pathEncode(request.nodeId.stream().map(v -> v).collect(Collectors.joining(",")),
464-
buf);
463+
SimpleEndpoint.pathEncode(request.nodeId.stream().map(v -> v).filter(Objects::nonNull)
464+
.collect(Collectors.joining(",")), buf);
465465
return buf.toString();
466466
}
467467
throw SimpleEndpoint.noPathTemplateFound("path");
@@ -481,7 +481,8 @@ public Builder rebuild() {
481481
if (propsSet == 0) {
482482
}
483483
if (propsSet == (_nodeId)) {
484-
params.put("nodeId", request.nodeId.stream().map(v -> v).collect(Collectors.joining(",")));
484+
params.put("nodeId", request.nodeId.stream().map(v -> v).filter(Objects::nonNull)
485+
.collect(Collectors.joining(",")));
485486
}
486487
return params;
487488
},
@@ -494,13 +495,15 @@ public Builder rebuild() {
494495
params.put("master_timeout", request.masterTimeout._toJsonString());
495496
}
496497
if (ApiTypeHelper.isDefined(request.s)) {
497-
params.put("s", request.s.stream().map(v -> v).collect(Collectors.joining(",")));
498+
params.put("s",
499+
request.s.stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(",")));
498500
}
499501
if (request.bytes != null) {
500502
params.put("bytes", request.bytes.jsonValue());
501503
}
502504
if (ApiTypeHelper.isDefined(request.h)) {
503-
params.put("h", request.h.stream().map(v -> v).collect(Collectors.joining(",")));
505+
params.put("h",
506+
request.h.stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(",")));
504507
}
505508
if (request.time != null) {
506509
params.put("time", request.time.jsonValue());

java-client/src/main/java/co/elastic/clients/elasticsearch/cat/ComponentTemplatesRequest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,13 +482,15 @@ public Builder rebuild() {
482482
params.put("master_timeout", request.masterTimeout._toJsonString());
483483
}
484484
if (ApiTypeHelper.isDefined(request.s)) {
485-
params.put("s", request.s.stream().map(v -> v).collect(Collectors.joining(",")));
485+
params.put("s",
486+
request.s.stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(",")));
486487
}
487488
if (request.bytes != null) {
488489
params.put("bytes", request.bytes.jsonValue());
489490
}
490491
if (ApiTypeHelper.isDefined(request.h)) {
491-
params.put("h", request.h.stream().map(v -> v).collect(Collectors.joining(",")));
492+
params.put("h",
493+
request.h.stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(",")));
492494
}
493495
if (request.time != null) {
494496
params.put("time", request.time.jsonValue());

java-client/src/main/java/co/elastic/clients/elasticsearch/cat/CountRequest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ protected static void setupCountRequestDeserializer(ObjectDeserializer<CountRequ
464464
buf.append("/_cat");
465465
buf.append("/count");
466466
buf.append("/");
467-
SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf);
467+
SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).filter(Objects::nonNull)
468+
.collect(Collectors.joining(",")), buf);
468469
return buf.toString();
469470
}
470471
throw SimpleEndpoint.noPathTemplateFound("path");
@@ -484,7 +485,8 @@ protected static void setupCountRequestDeserializer(ObjectDeserializer<CountRequ
484485
if (propsSet == 0) {
485486
}
486487
if (propsSet == (_index)) {
487-
params.put("index", request.index.stream().map(v -> v).collect(Collectors.joining(",")));
488+
params.put("index", request.index.stream().map(v -> v).filter(Objects::nonNull)
489+
.collect(Collectors.joining(",")));
488490
}
489491
return params;
490492
},
@@ -494,13 +496,15 @@ protected static void setupCountRequestDeserializer(ObjectDeserializer<CountRequ
494496
Map<String, String> params = new HashMap<>();
495497
params.put("format", "json");
496498
if (ApiTypeHelper.isDefined(request.s)) {
497-
params.put("s", request.s.stream().map(v -> v).collect(Collectors.joining(",")));
499+
params.put("s",
500+
request.s.stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(",")));
498501
}
499502
if (request.bytes != null) {
500503
params.put("bytes", request.bytes.jsonValue());
501504
}
502505
if (ApiTypeHelper.isDefined(request.h)) {
503-
params.put("h", request.h.stream().map(v -> v).collect(Collectors.joining(",")));
506+
params.put("h",
507+
request.h.stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(",")));
504508
}
505509
if (request.time != null) {
506510
params.put("time", request.time.jsonValue());

java-client/src/main/java/co/elastic/clients/elasticsearch/cat/FielddataRequest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ public Builder rebuild() {
386386
buf.append("/_cat");
387387
buf.append("/fielddata");
388388
buf.append("/");
389-
SimpleEndpoint.pathEncode(request.fields.stream().map(v -> v).collect(Collectors.joining(",")),
390-
buf);
389+
SimpleEndpoint.pathEncode(request.fields.stream().map(v -> v).filter(Objects::nonNull)
390+
.collect(Collectors.joining(",")), buf);
391391
return buf.toString();
392392
}
393393
throw SimpleEndpoint.noPathTemplateFound("path");
@@ -407,7 +407,8 @@ public Builder rebuild() {
407407
if (propsSet == 0) {
408408
}
409409
if (propsSet == (_fields)) {
410-
params.put("fields", request.fields.stream().map(v -> v).collect(Collectors.joining(",")));
410+
params.put("fields", request.fields.stream().map(v -> v).filter(Objects::nonNull)
411+
.collect(Collectors.joining(",")));
411412
}
412413
return params;
413414
},
@@ -417,13 +418,15 @@ public Builder rebuild() {
417418
Map<String, String> params = new HashMap<>();
418419
params.put("format", "json");
419420
if (ApiTypeHelper.isDefined(request.s)) {
420-
params.put("s", request.s.stream().map(v -> v).collect(Collectors.joining(",")));
421+
params.put("s",
422+
request.s.stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(",")));
421423
}
422424
if (request.bytes != null) {
423425
params.put("bytes", request.bytes.jsonValue());
424426
}
425427
if (ApiTypeHelper.isDefined(request.h)) {
426-
params.put("h", request.h.stream().map(v -> v).collect(Collectors.joining(",")));
428+
params.put("h",
429+
request.h.stream().map(v -> v).filter(Objects::nonNull).collect(Collectors.joining(",")));
427430
}
428431
if (request.time != null) {
429432
params.put("time", request.time.jsonValue());

0 commit comments

Comments
 (0)