2323import io .qdrant .client .grpc .Collections .AliasOperations ;
2424import io .qdrant .client .grpc .Collections .ChangeAliases ;
2525import io .qdrant .client .grpc .Collections .CollectionDescription ;
26+ import io .qdrant .client .grpc .Collections .CollectionExistsRequest ;
27+ import io .qdrant .client .grpc .Collections .CollectionExistsResponse ;
2628import io .qdrant .client .grpc .Collections .CollectionInfo ;
2729import io .qdrant .client .grpc .Collections .CollectionOperationResponse ;
2830import io .qdrant .client .grpc .Collections .CreateAlias ;
@@ -476,6 +478,33 @@ public ListenableFuture<CollectionOperationResponse> updateCollectionAsync(Updat
476478 }, MoreExecutors .directExecutor ());
477479 }
478480
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+
479508 //endregion
480509
481510 //region Alias Management
@@ -1515,6 +1544,38 @@ public ListenableFuture<UpdateResult> setPayloadAsync(
15151544 @ Nullable Boolean wait ,
15161545 @ Nullable WriteOrderingType ordering ,
15171546 @ 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
15181579 ) {
15191580 SetPayloadPoints .Builder requestBuilder = SetPayloadPoints .newBuilder ()
15201581 .setCollectionName (collectionName )
@@ -1529,6 +1590,10 @@ public ListenableFuture<UpdateResult> setPayloadAsync(
15291590 requestBuilder .setOrdering (WriteOrdering .newBuilder ().setType (ordering ).build ());
15301591 }
15311592
1593+ if (key != null ) {
1594+ requestBuilder .setKey (key );
1595+ }
1596+
15321597 return setPayloadAsync (requestBuilder .build (), timeout );
15331598 }
15341599
@@ -1687,6 +1752,38 @@ public ListenableFuture<UpdateResult> overwritePayloadAsync(
16871752 @ Nullable Boolean wait ,
16881753 @ Nullable WriteOrderingType ordering ,
16891754 @ 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
16901787 ) {
16911788 SetPayloadPoints .Builder requestBuilder = SetPayloadPoints .newBuilder ()
16921789 .setCollectionName (collectionName )
@@ -1701,6 +1798,9 @@ public ListenableFuture<UpdateResult> overwritePayloadAsync(
17011798 requestBuilder .setOrdering (WriteOrdering .newBuilder ().setType (ordering ).build ());
17021799 }
17031800
1801+ if (key != null )
1802+ requestBuilder .setKey (key );
1803+
17041804 return overwritePayloadAsync (requestBuilder .build (), timeout );
17051805 }
17061806
0 commit comments