32
32
import co .elastic .clients .elasticsearch ._types .mapping .TypeMapping ;
33
33
import co .elastic .clients .elasticsearch ._types .query_dsl .Like ;
34
34
import co .elastic .clients .elasticsearch .cluster .HealthRequest ;
35
- import co .elastic .clients .elasticsearch .core .BulkRequest ;
36
- import co .elastic .clients .elasticsearch .core .DeleteByQueryRequest ;
37
- import co .elastic .clients .elasticsearch .core .DeleteRequest ;
38
- import co .elastic .clients .elasticsearch .core .GetRequest ;
39
- import co .elastic .clients .elasticsearch .core .IndexRequest ;
40
- import co .elastic .clients .elasticsearch .core .MgetRequest ;
41
- import co .elastic .clients .elasticsearch .core .MsearchRequest ;
42
- import co .elastic .clients .elasticsearch .core .SearchRequest ;
43
- import co .elastic .clients .elasticsearch .core .UpdateByQueryRequest ;
44
- import co .elastic .clients .elasticsearch .core .UpdateRequest ;
35
+ import co .elastic .clients .elasticsearch .core .*;
45
36
import co .elastic .clients .elasticsearch .core .bulk .BulkOperation ;
46
37
import co .elastic .clients .elasticsearch .core .bulk .CreateOperation ;
47
38
import co .elastic .clients .elasticsearch .core .bulk .IndexOperation ;
52
43
import co .elastic .clients .elasticsearch .core .search .Rescore ;
53
44
import co .elastic .clients .elasticsearch .core .search .SourceConfig ;
54
45
import co .elastic .clients .elasticsearch .indices .*;
46
+ import co .elastic .clients .elasticsearch .indices .ExistsRequest ;
55
47
import co .elastic .clients .elasticsearch .indices .update_aliases .Action ;
56
48
import co .elastic .clients .json .JsonData ;
57
49
import co .elastic .clients .json .JsonpDeserializer ;
@@ -1164,10 +1156,24 @@ private <T> void prepareSearchRequest(Query query, @Nullable Class<T> clazz, Ind
1164
1156
ElasticsearchPersistentEntity <?> persistentEntity = getPersistentEntity (clazz );
1165
1157
1166
1158
builder //
1167
- .index (Arrays .asList (indexNames )) //
1168
1159
.version (true ) //
1169
1160
.trackScores (query .getTrackScores ());
1170
1161
1162
+ var pointInTime = query .getPointInTime ();
1163
+ if (pointInTime != null ) {
1164
+ builder .pit (pb -> pb .id (pointInTime .id ()).keepAlive (time (pointInTime .keepAlive ())));
1165
+ } else {
1166
+ builder .index (Arrays .asList (indexNames ));
1167
+
1168
+ if (query .getRoute () != null ) {
1169
+ builder .routing (query .getRoute ());
1170
+ }
1171
+
1172
+ if (query .getPreference () != null ) {
1173
+ builder .preference (query .getPreference ());
1174
+ }
1175
+ }
1176
+
1171
1177
if (persistentEntity != null && persistentEntity .hasSeqNoPrimaryTermProperty ()) {
1172
1178
builder .seqNoPrimaryTerm (true );
1173
1179
}
@@ -1205,10 +1211,6 @@ private <T> void prepareSearchRequest(Query query, @Nullable Class<T> clazz, Ind
1205
1211
builder .minScore ((double ) query .getMinScore ());
1206
1212
}
1207
1213
1208
- if (query .getPreference () != null ) {
1209
- builder .preference (query .getPreference ());
1210
- }
1211
-
1212
1214
builder .searchType (searchType (query .getSearchType ()));
1213
1215
1214
1216
if (query .getSort () != null ) {
@@ -1233,10 +1235,6 @@ private <T> void prepareSearchRequest(Query query, @Nullable Class<T> clazz, Ind
1233
1235
builder .trackTotalHits (th -> th .count (query .getTrackTotalHitsUpTo ()));
1234
1236
}
1235
1237
1236
- if (query .getRoute () != null ) {
1237
- builder .routing (query .getRoute ());
1238
- }
1239
-
1240
1238
builder .timeout (timeStringMs (query .getTimeout ()));
1241
1239
1242
1240
if (query .getExplain ()) {
@@ -1507,6 +1505,27 @@ public co.elastic.clients.elasticsearch._types.query_dsl.MoreLikeThisQuery moreL
1507
1505
return moreLikeThisQuery ;
1508
1506
}
1509
1507
1508
+ public OpenPointInTimeRequest searchOpenPointInTimeRequest (IndexCoordinates index , Duration keepAlive ,
1509
+ Boolean ignoreUnavailable ) {
1510
+
1511
+ Assert .notNull (index , "index must not be null" );
1512
+ Assert .notNull (keepAlive , "keepAlive must not be null" );
1513
+ Assert .notNull (ignoreUnavailable , "ignoreUnavailable must not be null" );
1514
+
1515
+ return OpenPointInTimeRequest .of (opit -> opit //
1516
+ .index (Arrays .asList (index .getIndexNames ())) //
1517
+ .ignoreUnavailable (ignoreUnavailable ) //
1518
+ .keepAlive (time (keepAlive )) //
1519
+ );
1520
+ }
1521
+
1522
+ public ClosePointInTimeRequest searchClosePointInTime (String pit ) {
1523
+
1524
+ Assert .notNull (pit , "pit must not be null" );
1525
+
1526
+ return ClosePointInTimeRequest .of (cpit -> cpit .id (pit ));
1527
+ }
1528
+
1510
1529
// endregion
1511
1530
1512
1531
// region helper functions
0 commit comments