Class MilvusGrpcClient

  • All Implemented Interfaces:
    MilvusClient

    public class MilvusGrpcClient
    extends java.lang.Object
    • Constructor Detail

      • MilvusGrpcClient

        public MilvusGrpcClient​(ConnectParam connectParam)
    • Method Detail

      • blockingStub

        protected io.milvus.grpc.MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub()
      • futureStub

        protected io.milvus.grpc.MilvusServiceGrpc.MilvusServiceFutureStub futureStub()
      • maybeAvailable

        protected boolean maybeAvailable()
      • close

        public void close​(long maxWaitSeconds)
        Description copied from interface: MilvusClient
        Close this MilvusClient. Wait at most `maxWaitSeconds` for graceful shutdown.
      • withTimeout

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

        public Response createCollection​(@Nonnull
                                         CollectionMapping collectionMapping)
        Description copied from interface: MilvusClient
        Creates collection specified by collectionMapping
        Specified by:
        createCollection in interface MilvusClient
        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
      • dropCollection

        public Response dropCollection​(@Nonnull
                                       java.lang.String collectionName)
        Description copied from interface: MilvusClient
        Drops collection
        Specified by:
        dropCollection in interface MilvusClient
        Parameters:
        collectionName - collection to drop
        Returns:
        Response
        See Also:
        Response
      • createIndex

        public Response createIndex​(@Nonnull
                                    Index index)
        Description copied from interface: MilvusClient
        Creates index specified by index
        Specified by:
        createIndex in interface MilvusClient
        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

        public com.google.common.util.concurrent.ListenableFuture<Response> createIndexAsync​(@Nonnull
                                                                                             Index index)
        Description copied from interface: MilvusClient
        Creates index specified by index asynchronously
        Specified by:
        createIndexAsync in interface MilvusClient
        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

        public Response createPartition​(java.lang.String collectionName,
                                        java.lang.String tag)
        Description copied from interface: MilvusClient
        Creates a partition specified by collectionName and tag
        Specified by:
        createPartition in interface MilvusClient
        Parameters:
        collectionName - collection name
        tag - partition tag
        Returns:
        Response
        See Also:
        Response
      • hasPartition

        public HasPartitionResponse hasPartition​(java.lang.String collectionName,
                                                 java.lang.String tag)
        Description copied from interface: MilvusClient
        Checks whether the partition exists
        Specified by:
        hasPartition in interface MilvusClient
        Parameters:
        collectionName - collection name
        tag - partition tag
        Returns:
        HasPartitionResponse
        See Also:
        Response
      • dropPartition

        public Response dropPartition​(java.lang.String collectionName,
                                      java.lang.String tag)
        Description copied from interface: MilvusClient
        Drops partition specified by collectionName and tag
        Specified by:
        dropPartition in interface MilvusClient
        Parameters:
        collectionName - collection name
        tag - partition tag
        See Also:
        Response
      • insert

        public InsertResponse insert​(@Nonnull
                                     InsertParam insertParam)
        Description copied from interface: MilvusClient
        Inserts data specified by insertParam
        Specified by:
        insert in interface MilvusClient
        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

        public com.google.common.util.concurrent.ListenableFuture<InsertResponse> insertAsync​(@Nonnull
                                                                                              InsertParam insertParam)
        Description copied from interface: MilvusClient
        Inserts data specified by insertParam asynchronously
        Specified by:
        insertAsync in interface MilvusClient
        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

        public SearchResponse search​(@Nonnull
                                     SearchParam searchParam)
        Description copied from interface: MilvusClient
        Searches vectors specified by searchParam
        Specified by:
        search in interface MilvusClient
        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

        public com.google.common.util.concurrent.ListenableFuture<SearchResponse> searchAsync​(@Nonnull
                                                                                              SearchParam searchParam)
        Description copied from interface: MilvusClient
        Searches vectors specified by searchParam asynchronously
        Specified by:
        searchAsync in interface MilvusClient
        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
      • command

        public Response command​(@Nonnull
                                java.lang.String command)
        Description copied from interface: MilvusClient
        Sends a command to server
        Specified by:
        command in interface MilvusClient
        Returns:
        Response command's response will be return in message
        See Also:
        Response
      • loadCollection

        public Response loadCollection​(@Nonnull
                                       java.lang.String collectionName)
        Description copied from interface: MilvusClient
        Pre-loads collection to memory
        Specified by:
        loadCollection in interface MilvusClient
        Parameters:
        collectionName - collection to load
        Returns:
        Response
        See Also:
        Response
      • loadCollection

        public Response loadCollection​(@Nonnull
                                       java.lang.String collectionName,
                                       java.util.List<java.lang.String> partitionTags)
        Description copied from interface: MilvusClient
        Pre-loads collection/partitions to memory
        Specified by:
        loadCollection in interface MilvusClient
        Parameters:
        collectionName - collection to load
        partitionTags - partitions to load
        Returns:
        Response
        See Also:
        Response
      • releaseCollection

        public Response releaseCollection​(java.lang.String collectionName)
        Description copied from interface: MilvusClient
        Release collection from memory
        Specified by:
        releaseCollection in interface MilvusClient
        Parameters:
        collectionName - collection to release
        Returns:
        Response
        See Also:
        Response
      • releaseCollection

        public Response releaseCollection​(java.lang.String collectionName,
                                          java.util.List<java.lang.String> partitionTags)
        Description copied from interface: MilvusClient
        Release collection/partitions from memory
        Specified by:
        releaseCollection in interface MilvusClient
        Parameters:
        collectionName - collection to release
        partitionTags - partitions to release
        Returns:
        Response
        See Also:
        Response
      • dropIndex

        public Response dropIndex​(@Nonnull
                                  java.lang.String collectionName)
        Description copied from interface: MilvusClient
        Drops collection index
        Specified by:
        dropIndex in interface MilvusClient
        Parameters:
        collectionName - collection to drop index of
        Returns:
        Response
        See Also:
        Response
      • getCollectionStats

        public Response getCollectionStats​(java.lang.String collectionName)
        Description copied from interface: MilvusClient
        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.
        Specified by:
        getCollectionStats in interface MilvusClient
        Parameters:
        collectionName - collection to show info from
        Returns:
        Response
        See Also:
        Response
      • getEntityByID

        public GetEntityByIDResponse getEntityByID​(java.lang.String collectionName,
                                                   java.lang.String partitionTag,
                                                   java.util.List<java.lang.Long> ids)
        Description copied from interface: MilvusClient
        Gets vectors data by id array
        Specified by:
        getEntityByID in interface MilvusClient
        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
      • deleteEntityByID

        public Response deleteEntityByID​(java.lang.String collectionName,
                                         java.lang.String partitionTag,
                                         java.util.List<java.lang.Long> ids)
        Description copied from interface: MilvusClient
        Deletes data in a collection by a list of ids
        Specified by:
        deleteEntityByID in interface MilvusClient
        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

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

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

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

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

        public Response compact​(java.lang.String collectionName)
        Description copied from interface: MilvusClient
        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.
        Specified by:
        compact in interface MilvusClient
        Parameters:
        collectionName - name of collection to compact
        Returns:
        Response
        See Also:
        Response
      • compactAsync

        public com.google.common.util.concurrent.ListenableFuture<Response> compactAsync​(@Nonnull
                                                                                         java.lang.String collectionName)
        Description copied from interface: MilvusClient
        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.
        Specified by:
        compactAsync in interface MilvusClient
        Parameters:
        collectionName - name of collection to compact
        Returns:
        a ListenableFuture object which holds the Response
        See Also:
        Response, ListenableFuture