Interface MilvusClient

  • All Known Implementing Classes:
    MilvusGrpcClient

    public interface MilvusClient
    The Milvus Client Interface
    • Method Detail

      • getClientVersion

        default String getClientVersion()
        Returns:
        current Milvus client version: 0.5.0
      • connect

        Response connect​(ConnectParam connectParam)
                  throws ConnectFailedException
        Connects to Milvus server
        Parameters:
        connectParam - the ConnectParam object
         example usage:
         
         ConnectParam connectParam = new ConnectParam.Builder()
                                                     .withHost("localhost")
                                                     .withPort(19530)
                                                     .withConnectTimeout(10, TimeUnit.SECONDS)
                                                     .withKeepAliveTime(Long.MAX_VALUE, TimeUnit.NANOSECONDS)
                                                     .withKeepAliveTimeout(20, TimeUnit.SECONDS)
                                                     .keepAliveWithoutCalls(false)
                                                     .withIdleTimeout(24, TimeUnit.HOURS)
                                                     .build();
         
         
        Returns:
        Response
        Throws:
        ConnectFailedException - if client failed to connect
        See Also:
        ConnectParam, Response, ConnectFailedException
      • isConnected

        boolean isConnected()
        Returns:
        true if the client is connected to Milvus server and the channel's connectivity state is READY.
      • 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
      • dropCollection

        Response dropCollection​(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
      • createPartition

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

        Response dropPartition​(String collectionName,
                               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
      • 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
      • searchInFiles

        SearchResponse searchInFiles​(List<String> fileIds,
                                     SearchParam searchParam)
        Searches vectors in specific files
        Parameters:
        fileIds - list of file ids to search from
        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
      • 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​(String command)
        Sends a command to server
        Returns:
        Response command's response will be return in message
        See Also:
        Response
      • preloadCollection

        Response preloadCollection​(String collectionName)
        Pre-loads collection to memory
        Parameters:
        collectionName - collection to preload
        Returns:
        Response
        See Also:
        Response
      • dropIndex

        Response dropIndex​(String collectionName)
        Drops collection index
        Parameters:
        collectionName - collection to drop index of
        See Also:
        Response
      • deleteByIds

        Response deleteByIds​(String collectionName,
                             List<Long> ids)
        Deletes data in a collection by a list of ids
        Parameters:
        collectionName - collection to delete ids from
        ids - a List of vector ids to delete
        See Also:
        Response
      • deleteById

        Response deleteById​(String collectionName,
                            Long id)
        Deletes data in a collection by a single id
        Parameters:
        collectionName - collection to delete id from
        id - vector id to delete
        See Also:
        Response
      • flush

        Response flush​(List<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
        See Also:
        Response
      • flush

        Response flush​(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
        See Also:
        Response
      • compact

        Response compact​(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
        See Also:
        Response