milvus-logo

Interface MilvusClient

  • All Known Implementing Classes:
    MilvusGrpcClient

    public interface MilvusClient
    The Milvus Client Interface
    • Field Detail

      • clientVersion

        static final java.lang.String clientVersion
    • Method Detail

      • getClientVersion

        default java.lang.String getClientVersion()
        Returns:
        current Milvus client version
      • close

        default void close()
        Close this MilvusClient. Wait at most 1 minute for graceful shutdown.
      • close

        void close​(long maxWaitSeconds)
        Close this MilvusClient. Wait at most `maxWaitSeconds` for graceful shutdown.
      • withTimeout

        MilvusClient withTimeout​(long timeout,
                                 java.util.concurrent.TimeUnit timeoutUnit)
      • createCollection

        Response createCollection​(CollectionMapping collectionMapping)
        Creates collection specified by collectionMapping
        Parameters:
        collectionMapping - the CollectionMapping object
        
         example usage:
         
         CollectionMapping collectionMapping = new CollectionMapping.Builder(collectionName, dimension)
                                                  .withIndexFileSize(1024)
                                                  .withMetricType(MetricType.IP)
                                                  .build();
         
         
        Returns:
        Response
        See Also:
        CollectionMapping, MetricType, Response
      • hasCollection

        HasCollectionResponse hasCollection​(java.lang.String collectionName)
        Checks whether the collection exists
        Parameters:
        collectionName - collection to check
        Returns:
        HasCollectionResponse
        See Also:
        HasCollectionResponse, Response
      • dropCollection

        Response dropCollection​(java.lang.String collectionName)
        Drops collection
        Parameters:
        collectionName - collection to drop
        Returns:
        Response
        See Also:
        Response
      • createIndex

        Response createIndex​(Index index)
        Creates index specified by index
        Parameters:
        index - the Index object
        
         example usage:
         
         Index index = new Index.Builder(collectionName, IndexType.IVF_SQ8)
                                .withParamsInJson("{\"nlist\": 16384}")
                                .build();
         
         
        Returns:
        Response
        See Also:
        Index, IndexType, Response
      • createIndexAsync

        com.google.common.util.concurrent.ListenableFuture<Response> createIndexAsync​(Index index)
        Creates index specified by index asynchronously
        Parameters:
        index - the Index object
        
         example usage:
         
         Index index = new Index.Builder(collectionName, IndexType.IVF_SQ8)
                                .withParamsInJson("{\"nlist\": 16384}")
                                .build();
         
         
        Returns:
        a ListenableFuture object which holds the Response
        See Also:
        Index, IndexType, Response, ListenableFuture
      • createPartition

        Response createPartition​(java.lang.String collectionName,
                                 java.lang.String tag)
        Creates a partition specified by collectionName and tag
        Parameters:
        collectionName - collection name
        tag - partition tag
        Returns:
        Response
        See Also:
        Response
      • hasPartition

        HasPartitionResponse hasPartition​(java.lang.String collectionName,
                                          java.lang.String tag)
        Checks whether the partition exists
        Parameters:
        collectionName - collection name
        tag - partition tag
        Returns:
        HasPartitionResponse
        See Also:
        Response
      • listPartitions

        ListPartitionsResponse listPartitions​(java.lang.String collectionName)
        Lists current partitions of a collection
        Parameters:
        collectionName - collection name
        Returns:
        ListPartitionsResponse
        See Also:
        ListPartitionsResponse, Response
      • dropPartition

        Response dropPartition​(java.lang.String collectionName,
                               java.lang.String tag)
        Drops partition specified by collectionName and tag
        Parameters:
        collectionName - collection name
        tag - partition tag
        See Also:
        Response
      • insert

        InsertResponse insert​(InsertParam insertParam)
        Inserts data specified by insertParam
        Parameters:
        insertParam - the InsertParam object
        
         example usage:
         
         InsertParam insertParam = new InsertParam.Builder(collectionName)
                                                  .withFloatVectors(floatVectors)
                                                  .withVectorIds(vectorIds)
                                                  .withPartitionTag(tag)
                                                  .build();
         
         
        Returns:
        InsertResponse
        See Also:
        InsertParam, InsertResponse, Response
      • insertAsync

        com.google.common.util.concurrent.ListenableFuture<InsertResponse> insertAsync​(InsertParam insertParam)
        Inserts data specified by insertParam asynchronously
        Parameters:
        insertParam - the InsertParam object
        
         example usage:
         
         InsertParam insertParam = new InsertParam.Builder(collectionName)
                                                  .withFloatVectors(floatVectors)
                                                  .withVectorIds(vectorIds)
                                                  .withPartitionTag(tag)
                                                  .build();
         
         
        Returns:
        a ListenableFuture object which holds the InsertResponse
        See Also:
        InsertParam, InsertResponse, Response, ListenableFuture
      • search

        SearchResponse search​(SearchParam searchParam)
        Searches vectors specified by searchParam
        Parameters:
        searchParam - the SearchParam object
        
         example usage:
         
         SearchParam searchParam = new SearchParam.Builder(collectionName)
                                                  .withFloatVectors(floatVectors)
                                                  .withTopK(topK)
                                                  .withPartitionTags(partitionTagsList)
                                                  .withParamsInJson("{\"nprobe\": 20}")
                                                  .build();
         
         
        Returns:
        SearchResponse
        See Also:
        SearchParam, SearchResponse, SearchResponse.QueryResult, Response
      • searchAsync

        com.google.common.util.concurrent.ListenableFuture<SearchResponse> searchAsync​(SearchParam searchParam)
        Searches vectors specified by searchParam asynchronously
        Parameters:
        searchParam - the SearchParam object
        
         example usage:
         
         SearchParam searchParam = new SearchParam.Builder(collectionName)
                                                  .withFloatVectors(floatVectors)
                                                  .withTopK(topK)
                                                  .withPartitionTags(partitionTagsList)
                                                  .withParamsInJson("{\"nprobe\": 20}")
                                                  .build();
         
         
        Returns:
        a ListenableFuture object which holds the SearchResponse
        See Also:
        SearchParam, SearchResponse, SearchResponse.QueryResult, Response, ListenableFuture
      • listCollections

        ListCollectionsResponse listCollections()
        Lists current collections
        Returns:
        ListCollectionsResponse
        See Also:
        ListCollectionsResponse, Response
      • countEntities

        CountEntitiesResponse countEntities​(java.lang.String collectionName)
        Gets current entity count of a collection
        Parameters:
        collectionName - collection to count entities
        Returns:
        CountEntitiesResponse
        See Also:
        CountEntitiesResponse, Response
      • getServerStatus

        Response getServerStatus()
        Get server status
        Returns:
        Response
        See Also:
        Response
      • getServerVersion

        Response getServerVersion()
        Get server version
        Returns:
        Response
        See Also:
        Response
      • command

        Response command​(java.lang.String command)
        Sends a command to server
        Returns:
        Response command's response will be return in message
        See Also:
        Response
      • loadCollection

        Response loadCollection​(java.lang.String collectionName)
        Pre-loads collection to memory
        Parameters:
        collectionName - collection to load
        Returns:
        Response
        See Also:
        Response
      • loadCollection

        Response loadCollection​(java.lang.String collectionName,
                                java.util.List<java.lang.String> partitionTags)
        Pre-loads collection/partitions to memory
        Parameters:
        collectionName - collection to load
        partitionTags - partitions to load
        Returns:
        Response
        See Also:
        Response
      • releaseCollection

        Response releaseCollection​(java.lang.String collectionName)
        Release collection from memory
        Parameters:
        collectionName - collection to release
        Returns:
        Response
        See Also:
        Response
      • releaseCollection

        Response releaseCollection​(java.lang.String collectionName,
                                   java.util.List<java.lang.String> partitionTags)
        Release collection/partitions from memory
        Parameters:
        collectionName - collection to release
        partitionTags - partitions to release
        Returns:
        Response
        See Also:
        Response
      • getIndexInfo

        GetIndexInfoResponse getIndexInfo​(java.lang.String collectionName)
        Gets collection index information
        Parameters:
        collectionName - collection to get info from
        See Also:
        GetIndexInfoResponse, Index, Response
      • dropIndex

        Response dropIndex​(java.lang.String collectionName)
        Drops collection index
        Parameters:
        collectionName - collection to drop index of
        Returns:
        Response
        See Also:
        Response
      • getCollectionStats

        Response getCollectionStats​(java.lang.String collectionName)
        Shows collection information. A collection consists of one or multiple partitions (including the default partition), and a partitions consists of one or more segments. Each partition or segment can be uniquely identified by its partition tag or segment name respectively. The result will be returned as JSON string.
        Parameters:
        collectionName - collection to show info from
        Returns:
        Response
        See Also:
        Response
      • getEntityByID

        GetEntityByIDResponse getEntityByID​(java.lang.String collectionName,
                                            java.lang.String partitionTag,
                                            java.util.List<java.lang.Long> ids)
        Gets vectors data by id array
        Parameters:
        collectionName - collection to get vectors from
        partitionTag - partition to get vectors from
        ids - a List of vector ids
        Returns:
        GetEntityByIDResponse
        See Also:
        GetEntityByIDResponse, Response
      • listIDInSegment

        ListIDInSegmentResponse listIDInSegment​(java.lang.String collectionName,
                                                java.lang.String segmentName)
        Gets all vector ids in a segment
        Parameters:
        collectionName - collection to get vector ids from
        segmentName - segment name in the collection
        Returns:
        ListIDInSegmentResponse
        See Also:
        ListIDInSegmentResponse, Response
      • deleteEntityByID

        Response deleteEntityByID​(java.lang.String collectionName,
                                  java.lang.String partitionTag,
                                  java.util.List<java.lang.Long> ids)
        Deletes data in a collection by a list of ids
        Parameters:
        collectionName - collection to delete ids from
        partitionTag - partition to delete ids from
        ids - a List of vector ids to delete
        Returns:
        Response
        See Also:
        Response
      • flush

        Response flush​(java.util.List<java.lang.String> collectionNames)
        Flushes data in a list collections. Newly inserted or modifications on data will be visible after flush returned
        Parameters:
        collectionNames - a List of collections to flush
        Returns:
        Response
        See Also:
        Response
      • flushAsync

        com.google.common.util.concurrent.ListenableFuture<Response> flushAsync​(java.util.List<java.lang.String> collectionNames)
        Flushes data in a list collections asynchronously. Newly inserted or modifications on data will be visible after flush returned
        Parameters:
        collectionNames - a List of collections to flush
        Returns:
        a ListenableFuture object which holds the Response
        See Also:
        Response, ListenableFuture
      • flush

        Response flush​(java.lang.String collectionName)
        Flushes data in a collection. Newly inserted or modifications on data will be visible after flush returned
        Parameters:
        collectionName - name of collection to flush
        Returns:
        Response
        See Also:
        Response
      • flushAsync

        com.google.common.util.concurrent.ListenableFuture<Response> flushAsync​(java.lang.String collectionName)
        Flushes data in a collection asynchronously. Newly inserted or modifications on data will be visible after flush returned
        Parameters:
        collectionName - name of collection to flush
        Returns:
        a ListenableFuture object which holds the Response
        See Also:
        Response, ListenableFuture
      • compact

        Response compact​(java.lang.String collectionName)
        Compacts the collection, erasing deleted data from disk and rebuild index in background (if the data size after compaction is still larger than indexFileSize). Data was only soft-deleted until you call compact.
        Parameters:
        collectionName - name of collection to compact
        Returns:
        Response
        See Also:
        Response
      • compactAsync

        com.google.common.util.concurrent.ListenableFuture<Response> compactAsync​(java.lang.String collectionName)
        Compacts the collection asynchronously, erasing deleted data from disk and rebuild index in background (if the data size after compaction is still larger than indexFileSize). Data was only soft-deleted until you call compact.
        Parameters:
        collectionName - name of collection to compact
        Returns:
        a ListenableFuture object which holds the Response
        See Also:
        Response, ListenableFuture