23
23
import io .qdrant .client .grpc .Collections .AliasOperations ;
24
24
import io .qdrant .client .grpc .Collections .ChangeAliases ;
25
25
import io .qdrant .client .grpc .Collections .CollectionDescription ;
26
+ import io .qdrant .client .grpc .Collections .CollectionExistsRequest ;
27
+ import io .qdrant .client .grpc .Collections .CollectionExistsResponse ;
26
28
import io .qdrant .client .grpc .Collections .CollectionInfo ;
27
29
import io .qdrant .client .grpc .Collections .CollectionOperationResponse ;
28
30
import io .qdrant .client .grpc .Collections .CreateAlias ;
@@ -476,6 +478,33 @@ public ListenableFuture<CollectionOperationResponse> updateCollectionAsync(Updat
476
478
}, MoreExecutors .directExecutor ());
477
479
}
478
480
481
+ /**
482
+ * Check if a collection exists
483
+ *
484
+ * @param collectionName The name of the collection.
485
+ * @return a new instance of {@link ListenableFuture}
486
+ */
487
+ public ListenableFuture <Boolean > collectionExistsAsync (String collectionName ) {
488
+ return collectionExistsAsync (collectionName , null );
489
+ }
490
+
491
+ /**
492
+ * Check if a collection exists
493
+ *
494
+ * @param collectionName The name of the collection.
495
+ * @param timeout The timeout for the call.
496
+ * @return a new instance of {@link ListenableFuture}
497
+ */
498
+ public ListenableFuture <Boolean > collectionExistsAsync (String collectionName , @ Nullable Duration timeout ) {
499
+ Preconditions .checkArgument (!collectionName .isEmpty (), "Collection name must not be empty" );
500
+ logger .debug ("Collection exists '{}'" , collectionName );
501
+
502
+ ListenableFuture <CollectionExistsResponse > future = getCollections (timeout )
503
+ .collectionExists (CollectionExistsRequest .newBuilder ().setCollectionName (collectionName ).build ());
504
+ addLogFailureCallback (future , "Collection exists" );
505
+ return Futures .transform (future , response -> response .getResult ().getExists (), MoreExecutors .directExecutor ());
506
+ }
507
+
479
508
//endregion
480
509
481
510
//region Alias Management
@@ -1515,6 +1544,38 @@ public ListenableFuture<UpdateResult> setPayloadAsync(
1515
1544
@ Nullable Boolean wait ,
1516
1545
@ Nullable WriteOrderingType ordering ,
1517
1546
@ Nullable Duration timeout
1547
+ ) {
1548
+ return setPayloadAsync (
1549
+ collectionName ,
1550
+ payload ,
1551
+ pointsSelector ,
1552
+ wait ,
1553
+ null ,
1554
+ ordering ,
1555
+ timeout
1556
+ );
1557
+ }
1558
+
1559
+ /**
1560
+ * Sets the payload for the points.
1561
+ *
1562
+ * @param collectionName The name of the collection.
1563
+ * @param payload New payload values
1564
+ * @param pointsSelector Selector for the points whose payloads are to be set.
1565
+ * @param wait Whether to wait until the changes have been applied. Defaults to <code>true</code>.
1566
+ * @param key The key for which to set the payload if nested
1567
+ * @param ordering Write ordering guarantees.
1568
+ * @param timeout The timeout for the call.
1569
+ * @return a new instance of {@link ListenableFuture}
1570
+ */
1571
+ public ListenableFuture <UpdateResult > setPayloadAsync (
1572
+ String collectionName ,
1573
+ Map <String , Value > payload ,
1574
+ @ Nullable PointsSelector pointsSelector ,
1575
+ @ Nullable Boolean wait ,
1576
+ @ Nullable String key ,
1577
+ @ Nullable WriteOrderingType ordering ,
1578
+ @ Nullable Duration timeout
1518
1579
) {
1519
1580
SetPayloadPoints .Builder requestBuilder = SetPayloadPoints .newBuilder ()
1520
1581
.setCollectionName (collectionName )
@@ -1529,6 +1590,10 @@ public ListenableFuture<UpdateResult> setPayloadAsync(
1529
1590
requestBuilder .setOrdering (WriteOrdering .newBuilder ().setType (ordering ).build ());
1530
1591
}
1531
1592
1593
+ if (key != null ) {
1594
+ requestBuilder .setKey (key );
1595
+ }
1596
+
1532
1597
return setPayloadAsync (requestBuilder .build (), timeout );
1533
1598
}
1534
1599
@@ -1687,6 +1752,38 @@ public ListenableFuture<UpdateResult> overwritePayloadAsync(
1687
1752
@ Nullable Boolean wait ,
1688
1753
@ Nullable WriteOrderingType ordering ,
1689
1754
@ Nullable Duration timeout
1755
+ ) {
1756
+ return overwritePayloadAsync (
1757
+ collectionName ,
1758
+ payload ,
1759
+ pointsSelector ,
1760
+ wait ,
1761
+ null ,
1762
+ ordering ,
1763
+ timeout
1764
+ );
1765
+ }
1766
+
1767
+ /**
1768
+ * Overwrites the payload for the points.
1769
+ *
1770
+ * @param collectionName The name of the collection.
1771
+ * @param payload New payload values
1772
+ * @param pointsSelector Selector for the points whose payloads are to be overwritten.
1773
+ * @param wait Whether to wait until the changes have been applied. Defaults to <code>true</code>.
1774
+ * @param key The key for which to overwrite the payload if nested
1775
+ * @param ordering Write ordering guarantees.
1776
+ * @param timeout The timeout for the call.
1777
+ * @return a new instance of {@link ListenableFuture}
1778
+ */
1779
+ public ListenableFuture <UpdateResult > overwritePayloadAsync (
1780
+ String collectionName ,
1781
+ Map <String , Value > payload ,
1782
+ @ Nullable PointsSelector pointsSelector ,
1783
+ @ Nullable Boolean wait ,
1784
+ @ Nullable String key ,
1785
+ @ Nullable WriteOrderingType ordering ,
1786
+ @ Nullable Duration timeout
1690
1787
) {
1691
1788
SetPayloadPoints .Builder requestBuilder = SetPayloadPoints .newBuilder ()
1692
1789
.setCollectionName (collectionName )
@@ -1701,6 +1798,9 @@ public ListenableFuture<UpdateResult> overwritePayloadAsync(
1701
1798
requestBuilder .setOrdering (WriteOrdering .newBuilder ().setType (ordering ).build ());
1702
1799
}
1703
1800
1801
+ if (key != null )
1802
+ requestBuilder .setKey (key );
1803
+
1704
1804
return overwritePayloadAsync (requestBuilder .build (), timeout );
1705
1805
}
1706
1806
0 commit comments