@@ -337,12 +337,10 @@ public PutMappingRequest indicesPutMappingRequest(IndexCoordinates indexCoordina
337
337
Assert .notNull (indexCoordinates , "indexCoordinates must not be null" );
338
338
Assert .notNull (mapping , "mapping must not be null" );
339
339
340
- PutMappingRequest request = new PutMappingRequest .Builder () //
341
- .withJson (new StringReader (mapping .toJson ())) //
342
- .index (Arrays .asList (indexCoordinates .getIndexNames ())) //
340
+ return new PutMappingRequest .Builder ()
341
+ .withJson (new StringReader (mapping .toJson ()))
342
+ .index (Arrays .asList (indexCoordinates .getIndexNames ()))
343
343
.build ();
344
-
345
- return request ;
346
344
}
347
345
348
346
public GetMappingRequest indicesGetMappingRequest (IndexCoordinates indexCoordinates ) {
@@ -422,10 +420,7 @@ public co.elastic.clients.elasticsearch.indices.PutTemplateRequest indicesPutTem
422
420
423
421
if (parametersAliases != null ) {
424
422
for (String aliasName : parametersAliases ) {
425
- builder .aliases (aliasName , aliasBuilder -> {
426
-
427
- return buildAlias (parameters , aliasBuilder );
428
- });
423
+ builder .aliases (aliasName , aliasBuilder -> buildAlias (parameters , aliasBuilder ));
429
424
}
430
425
}
431
426
});
@@ -860,11 +855,10 @@ public co.elastic.clients.elasticsearch.core.ReindexRequest reindex(ReindexReque
860
855
StringBuilder sb = new StringBuilder (remote .getScheme ());
861
856
sb .append ("://" );
862
857
sb .append (remote .getHost ());
863
- sb .append (":" );
858
+ sb .append (':' );
864
859
sb .append (remote .getPort ());
865
860
866
861
if (remote .getPathPrefix () != null ) {
867
- sb .append ("" );
868
862
sb .append (remote .getPathPrefix ());
869
863
}
870
864
@@ -884,7 +878,7 @@ public co.elastic.clients.elasticsearch.core.ReindexRequest reindex(ReindexReque
884
878
}
885
879
886
880
SourceFilter sourceFilter = source .getSourceFilter ();
887
- if (sourceFilter != null ) {
881
+ if (sourceFilter != null && sourceFilter . getIncludes () != null ) {
888
882
s .sourceFields (Arrays .asList (sourceFilter .getIncludes ()));
889
883
}
890
884
return s ;
@@ -1038,8 +1032,8 @@ public DeleteByQueryRequest documentDeleteByQueryRequest(Query query, @Nullable
1038
1032
int val ;
1039
1033
try {
1040
1034
val = Integer .parseInt (waitForActiveShards );
1041
- } catch (NumberFormatException var3 ) {
1042
- throw new IllegalArgumentException ("cannot parse ActiveShardCount[" + waitForActiveShards + "]" , var3 );
1035
+ } catch (NumberFormatException e ) {
1036
+ throw new IllegalArgumentException ("cannot parse ActiveShardCount[" + waitForActiveShards + ']' , e );
1043
1037
}
1044
1038
uqb .waitForActiveShards (wfa -> wfa .count (val ));
1045
1039
}
@@ -1124,7 +1118,6 @@ public <T> SearchRequest searchRequest(Query query, @Nullable String routing, @N
1124
1118
IndexCoordinates indexCoordinates , boolean forCount , boolean forBatchedSearch ,
1125
1119
@ Nullable Long scrollTimeInMillis ) {
1126
1120
1127
- String [] indexNames = indexCoordinates .getIndexNames ();
1128
1121
Assert .notNull (query , "query must not be null" );
1129
1122
Assert .notNull (indexCoordinates , "indexCoordinates must not be null" );
1130
1123
@@ -1267,7 +1260,7 @@ public MsearchRequest searchMsearchRequest(
1267
1260
1268
1261
if (!isEmpty (query .getIndicesBoost ())) {
1269
1262
bb .indicesBoost (query .getIndicesBoost ().stream ()
1270
- .map (indexBoost -> Map .of (indexBoost .getIndexName (), Double . valueOf ( indexBoost .getBoost () )))
1263
+ .map (indexBoost -> Map .of (indexBoost .getIndexName (), ( double ) indexBoost .getBoost ()))
1271
1264
.collect (Collectors .toList ()));
1272
1265
}
1273
1266
@@ -1434,13 +1427,15 @@ private <T> void prepareSearchRequest(Query query, @Nullable String routing, @Nu
1434
1427
} else if (forBatchedSearch ) {
1435
1428
// request_cache is not allowed on scroll requests.
1436
1429
builder .requestCache (null );
1437
- // limit the number of documents in a batch
1438
- builder .size (query .getReactiveBatchSize ());
1430
+ // limit the number of documents in a batch if not already set in a pageable
1431
+ if (query .getPageable ().isUnpaged ()) {
1432
+ builder .size (query .getReactiveBatchSize ());
1433
+ }
1439
1434
}
1440
1435
1441
1436
if (!isEmpty (query .getIndicesBoost ())) {
1442
1437
builder .indicesBoost (query .getIndicesBoost ().stream ()
1443
- .map (indexBoost -> Map .of (indexBoost .getIndexName (), Double . valueOf ( indexBoost .getBoost () )))
1438
+ .map (indexBoost -> Map .of (indexBoost .getIndexName (), ( double ) indexBoost .getBoost ()))
1444
1439
.collect (Collectors .toList ()));
1445
1440
}
1446
1441
@@ -1468,15 +1463,14 @@ private void addIndicesOptions(SearchRequest.Builder builder, IndicesOptions ind
1468
1463
}
1469
1464
});
1470
1465
1471
- builder .expandWildcards (indicesOptions .getExpandWildcards ().stream ().map (wildcardStates -> {
1472
- return switch (wildcardStates ) {
1473
- case OPEN -> ExpandWildcard .Open ;
1474
- case CLOSED -> ExpandWildcard .Closed ;
1475
- case HIDDEN -> ExpandWildcard .Hidden ;
1476
- case ALL -> ExpandWildcard .All ;
1477
- case NONE -> ExpandWildcard .None ;
1478
- };
1479
- }).collect (Collectors .toList ()));
1466
+ builder .expandWildcards (indicesOptions .getExpandWildcards ().stream ()
1467
+ .map (wildcardStates -> switch (wildcardStates ) {
1468
+ case OPEN -> ExpandWildcard .Open ;
1469
+ case CLOSED -> ExpandWildcard .Closed ;
1470
+ case HIDDEN -> ExpandWildcard .Hidden ;
1471
+ case ALL -> ExpandWildcard .All ;
1472
+ case NONE -> ExpandWildcard .None ;
1473
+ }).collect (Collectors .toList ()));
1480
1474
}
1481
1475
1482
1476
private Rescore getRescore (RescorerQuery rescorerQuery ) {
@@ -1585,8 +1579,8 @@ private SortOptions getSortOptions(Sort.Order order, @Nullable ElasticsearchPers
1585
1579
1586
1580
@ Nullable
1587
1581
private NestedSortValue getNestedSort (@ Nullable Order .Nested nested ,
1588
- ElasticsearchPersistentEntity <?> persistentEntity ) {
1589
- return (nested == null ) ? null
1582
+ @ Nullable ElasticsearchPersistentEntity <?> persistentEntity ) {
1583
+ return (nested == null || persistentEntity == null ) ? null
1590
1584
: NestedSortValue .of (b -> b //
1591
1585
.path (elasticsearchConverter .updateFieldNames (nested .getPath (), persistentEntity )) //
1592
1586
.maxChildren (nested .getMaxChildren ()) //
@@ -1682,7 +1676,8 @@ private void addFilter(Query query, SearchRequest.Builder builder) {
1682
1676
1683
1677
if (query instanceof CriteriaQuery ) {
1684
1678
CriteriaFilterProcessor .createQuery (((CriteriaQuery ) query ).getCriteria ()).ifPresent (builder ::postFilter );
1685
- } else if (query instanceof StringQuery ) {
1679
+ } else //noinspection StatementWithEmptyBody
1680
+ if (query instanceof StringQuery ) {
1686
1681
// no filter for StringQuery
1687
1682
} else if (query instanceof NativeQuery ) {
1688
1683
builder .postFilter (((NativeQuery ) query ).getFilter ());
@@ -1697,7 +1692,7 @@ public co.elastic.clients.elasticsearch._types.query_dsl.MoreLikeThisQuery moreL
1697
1692
Assert .notNull (query , "query must not be null" );
1698
1693
Assert .notNull (index , "index must not be null" );
1699
1694
1700
- co . elastic . clients . elasticsearch . _types . query_dsl . MoreLikeThisQuery moreLikeThisQuery = co .elastic .clients .elasticsearch ._types .query_dsl .MoreLikeThisQuery
1695
+ return co .elastic .clients .elasticsearch ._types .query_dsl .MoreLikeThisQuery
1701
1696
.of (q -> {
1702
1697
q .like (Like .of (l -> l .document (ld -> ld .index (index .getIndexName ()).id (query .getId ()))))
1703
1698
.fields (query .getFields ());
@@ -1736,8 +1731,6 @@ public co.elastic.clients.elasticsearch._types.query_dsl.MoreLikeThisQuery moreL
1736
1731
1737
1732
return q ;
1738
1733
});
1739
-
1740
- return moreLikeThisQuery ;
1741
1734
}
1742
1735
1743
1736
public OpenPointInTimeRequest searchOpenPointInTimeRequest (IndexCoordinates index , Duration keepAlive ,
@@ -1783,7 +1776,7 @@ public SearchTemplateRequest searchTemplate(SearchTemplateQuery query, @Nullable
1783
1776
}
1784
1777
1785
1778
var expandWildcards = query .getExpandWildcards ();
1786
- if (!expandWildcards .isEmpty ()) {
1779
+ if (expandWildcards != null && !expandWildcards .isEmpty ()) {
1787
1780
builder .expandWildcards (expandWildcards (expandWildcards ));
1788
1781
}
1789
1782
0 commit comments