Package io.milvus.client
Interface MilvusClient
-
- All Known Implementing Classes:
MilvusGrpcClient
public interface MilvusClientThe Milvus Client Interface
-
-
Field Summary
Fields Modifier and Type Field Description static StringclientVersion
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Responsecommand(String command)Sends a command to serverResponsecompact(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).Responseconnect(ConnectParam connectParam)Connects to Milvus serverResponsecreateCollection(CollectionMapping collectionMapping)Creates collection specified bycollectionMappingResponsecreateIndex(Index index)Creates index specified byindexResponsecreatePartition(String collectionName, String tag)Creates a partition specified bycollectionNameandtagResponsedeleteById(String collectionName, Long id)Deletes data in a collection by a single idResponsedeleteByIds(String collectionName, List<Long> ids)Deletes data in a collection by a list of idsDescribeCollectionResponsedescribeCollection(String collectionName)Describes the collectionDescribeIndexResponsedescribeIndex(String collectionName)Describes collection indexResponsedisconnect()Disconnects from Milvus serverResponsedropCollection(String collectionName)Drops collectionResponsedropIndex(String collectionName)Drops collection indexResponsedropPartition(String collectionName, String tag)Drops partition specified bycollectionNameandtagResponseflush(String collectionName)Flushes data in a collection.Responseflush(List<String> collectionNames)Flushes data in a list collections.default StringgetClientVersion()GetCollectionRowCountResponsegetCollectionRowCount(String collectionName)Gets current row count of a collectionResponsegetServerStatus()Get server statusResponsegetServerVersion()Get server versionGetVectorByIdResponsegetVectorById(String collectionName, Long id)Gets either a float or binary vector by id.GetVectorIdsResponsegetVectorIds(String collectionName, String segmentName)Gets all vector ids in a segmentHasCollectionResponsehasCollection(String collectionName)Checks whether the collection existsInsertResponseinsert(InsertParam insertParam)Inserts data specified byinsertParambooleanisConnected()ResponsepreloadCollection(String collectionName)Pre-loads collection to memorySearchResponsesearch(SearchParam searchParam)Searches vectors specified bysearchParamSearchResponsesearchInFiles(List<String> fileIds, SearchParam searchParam)Searches vectors in specific filesShowCollectionInfoResponseshowCollectionInfo(String collectionName)Shows collection information.ShowCollectionsResponseshowCollections()Shows current collectionsShowPartitionsResponseshowPartitions(String collectionName)Shows current partitions of a collection
-
-
-
Field Detail
-
clientVersion
static final String clientVersion
- See Also:
- Constant Field Values
-
-
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- theConnectParamobjectexample 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:
trueif the client is connected to Milvus server and the channel's connectivity state is READY.
-
disconnect
Response disconnect() throws InterruptedException
Disconnects from Milvus server- Returns:
Response- Throws:
InterruptedException- See Also:
Response
-
createCollection
Response createCollection(CollectionMapping collectionMapping)
Creates collection specified bycollectionMapping- Parameters:
collectionMapping- theCollectionMappingobjectexample usage:
CollectionMapping collectionMapping = new CollectionMapping.Builder(collectionName, dimension) .withIndexFileSize(1024) .withMetricType(MetricType.IP) .build();- Returns:
Response- See Also:
CollectionMapping,MetricType,Response
-
hasCollection
HasCollectionResponse hasCollection(String collectionName)
Checks whether the collection exists- Parameters:
collectionName- collection to check- Returns:
HasCollectionResponse- See Also:
HasCollectionResponse,Response
-
dropCollection
Response dropCollection(String collectionName)
Drops collection- Parameters:
collectionName- collection to drop- Returns:
Response- See Also:
Response
-
createPartition
Response createPartition(String collectionName, String tag)
Creates a partition specified bycollectionNameandtag- Parameters:
collectionName- collection nametag- partition tag- Returns:
Response- See Also:
Response
-
showPartitions
ShowPartitionsResponse showPartitions(String collectionName)
Shows current partitions of a collection- Parameters:
collectionName- collection name- Returns:
ShowPartitionsResponse- See Also:
ShowPartitionsResponse,Response
-
dropPartition
Response dropPartition(String collectionName, String tag)
Drops partition specified bycollectionNameandtag- Parameters:
collectionName- collection nametag- partition tag- See Also:
Response
-
insert
InsertResponse insert(InsertParam insertParam)
Inserts data specified byinsertParam- Parameters:
insertParam- theInsertParamobjectexample 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 bysearchParam- Parameters:
searchParam- theSearchParamobjectexample 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 fromsearchParam- theSearchParamobjectexample 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
-
describeCollection
DescribeCollectionResponse describeCollection(String collectionName)
Describes the collection- Parameters:
collectionName- collection to describe- See Also:
DescribeCollectionResponse,CollectionMapping,Response
-
showCollections
ShowCollectionsResponse showCollections()
Shows current collections- Returns:
ShowCollectionsResponse- See Also:
ShowCollectionsResponse,Response
-
getCollectionRowCount
GetCollectionRowCountResponse getCollectionRowCount(String collectionName)
Gets current row count of a collection- Parameters:
collectionName- collection to get row count- Returns:
GetCollectionRowCountResponse- See Also:
GetCollectionRowCountResponse,Response
-
getServerVersion
Response getServerVersion()
Get server version- Returns:
Response- See Also:
Response
-
command
Response command(String command)
Sends a command to server- Returns:
Responsecommand's response will be return inmessage- See Also:
Response
-
preloadCollection
Response preloadCollection(String collectionName)
Pre-loads collection to memory- Parameters:
collectionName- collection to preload- Returns:
Response- See Also:
Response
-
describeIndex
DescribeIndexResponse describeIndex(String collectionName)
Describes collection index- Parameters:
collectionName- collection to describe index of- See Also:
DescribeIndexResponse,Index,Response
-
dropIndex
Response dropIndex(String collectionName)
Drops collection index- Parameters:
collectionName- collection to drop index of- See Also:
Response
-
showCollectionInfo
ShowCollectionInfoResponse showCollectionInfo(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.- Parameters:
collectionName- collection to show info from- See Also:
ShowCollectionInfoResponse,CollectionInfo,CollectionInfo.PartitionInfo,CollectionInfo.PartitionInfo.SegmentInfo,Response
-
getVectorById
GetVectorByIdResponse getVectorById(String collectionName, Long id)
Gets either a float or binary vector by id.- Parameters:
collectionName- collection to get vector fromid- vector id- See Also:
GetVectorByIdResponse,Response
-
getVectorIds
GetVectorIdsResponse getVectorIds(String collectionName, String segmentName)
Gets all vector ids in a segment- Parameters:
collectionName- collection to get vector ids fromsegmentName- segment name- See Also:
GetVectorIdsResponse,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 fromids- aListof 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 fromid- 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 afterflushreturned- Parameters:
collectionNames- aListof 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 afterflushreturned- 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
-
-