Package io.milvus.client
Class MilvusGrpcClient
- java.lang.Object
-
- io.milvus.client.MilvusGrpcClient
-
- All Implemented Interfaces:
MilvusClient
public class MilvusGrpcClient extends Object implements MilvusClient
Actual implementation of interfaceMilvusClient
-
-
Field Summary
-
Fields inherited from interface io.milvus.client.MilvusClient
clientVersion
-
-
Constructor Summary
Constructors Constructor Description MilvusGrpcClient()MilvusGrpcClient(Level logLevel)
-
Method Summary
All Methods Instance Methods Concrete 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.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-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.milvus.client.MilvusClient
getClientVersion
-
-
-
-
Method Detail
-
connect
public Response connect(ConnectParam connectParam) throws ConnectFailedException
Description copied from interface:MilvusClientConnects to Milvus server- Specified by:
connectin interfaceMilvusClient- 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
public boolean isConnected()
- Specified by:
isConnectedin interfaceMilvusClient- Returns:
trueif the client is connected to Milvus server and the channel's connectivity state is READY.
-
disconnect
public Response disconnect() throws InterruptedException
Description copied from interface:MilvusClientDisconnects from Milvus server- Specified by:
disconnectin interfaceMilvusClient- Returns:
Response- Throws:
InterruptedException- See Also:
Response
-
createCollection
public Response createCollection(@Nonnull CollectionMapping collectionMapping)
Description copied from interface:MilvusClientCreates collection specified bycollectionMapping- Specified by:
createCollectionin interfaceMilvusClient- 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
public HasCollectionResponse hasCollection(@Nonnull String collectionName)
Description copied from interface:MilvusClientChecks whether the collection exists- Specified by:
hasCollectionin interfaceMilvusClient- Parameters:
collectionName- collection to check- Returns:
HasCollectionResponse- See Also:
HasCollectionResponse,Response
-
dropCollection
public Response dropCollection(@Nonnull String collectionName)
Description copied from interface:MilvusClientDrops collection- Specified by:
dropCollectionin interfaceMilvusClient- Parameters:
collectionName- collection to drop- Returns:
Response- See Also:
Response
-
createIndex
public Response createIndex(@Nonnull Index index)
Description copied from interface:MilvusClientCreates index specified byindex- Specified by:
createIndexin interfaceMilvusClient- Parameters:
index- theIndexobjectexample usage:
Index index = new Index.Builder(collectionName, IndexType.IVF_SQ8) .withParamsInJson("{\"nlist\": 16384}") .build();- Returns:
Response- See Also:
Index,IndexType,Response
-
createPartition
public Response createPartition(String collectionName, String tag)
Description copied from interface:MilvusClientCreates a partition specified bycollectionNameandtag- Specified by:
createPartitionin interfaceMilvusClient- Parameters:
collectionName- collection nametag- partition tag- Returns:
Response- See Also:
Response
-
showPartitions
public ShowPartitionsResponse showPartitions(String collectionName)
Description copied from interface:MilvusClientShows current partitions of a collection- Specified by:
showPartitionsin interfaceMilvusClient- Parameters:
collectionName- collection name- Returns:
ShowPartitionsResponse- See Also:
ShowPartitionsResponse,Response
-
dropPartition
public Response dropPartition(String collectionName, String tag)
Description copied from interface:MilvusClientDrops partition specified bycollectionNameandtag- Specified by:
dropPartitionin interfaceMilvusClient- Parameters:
collectionName- collection nametag- partition tag- See Also:
Response
-
insert
public InsertResponse insert(@Nonnull InsertParam insertParam)
Description copied from interface:MilvusClientInserts data specified byinsertParam- Specified by:
insertin interfaceMilvusClient- 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
public SearchResponse search(@Nonnull SearchParam searchParam)
Description copied from interface:MilvusClientSearches vectors specified bysearchParam- Specified by:
searchin interfaceMilvusClient- 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
public SearchResponse searchInFiles(@Nonnull List<String> fileIds, @Nonnull SearchParam searchParam)
Description copied from interface:MilvusClientSearches vectors in specific files- Specified by:
searchInFilesin interfaceMilvusClient- 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
public DescribeCollectionResponse describeCollection(@Nonnull String collectionName)
Description copied from interface:MilvusClientDescribes the collection- Specified by:
describeCollectionin interfaceMilvusClient- Parameters:
collectionName- collection to describe- See Also:
DescribeCollectionResponse,CollectionMapping,Response
-
showCollections
public ShowCollectionsResponse showCollections()
Description copied from interface:MilvusClientShows current collections- Specified by:
showCollectionsin interfaceMilvusClient- Returns:
ShowCollectionsResponse- See Also:
ShowCollectionsResponse,Response
-
getCollectionRowCount
public GetCollectionRowCountResponse getCollectionRowCount(@Nonnull String collectionName)
Description copied from interface:MilvusClientGets current row count of a collection- Specified by:
getCollectionRowCountin interfaceMilvusClient- Parameters:
collectionName- collection to get row count- Returns:
GetCollectionRowCountResponse- See Also:
GetCollectionRowCountResponse,Response
-
getServerStatus
public Response getServerStatus()
Description copied from interface:MilvusClientGet server status- Specified by:
getServerStatusin interfaceMilvusClient- Returns:
Response- See Also:
Response
-
getServerVersion
public Response getServerVersion()
Description copied from interface:MilvusClientGet server version- Specified by:
getServerVersionin interfaceMilvusClient- Returns:
Response- See Also:
Response
-
command
public Response command(@Nonnull String command)
Description copied from interface:MilvusClientSends a command to server- Specified by:
commandin interfaceMilvusClient- Returns:
Responsecommand's response will be return inmessage- See Also:
Response
-
preloadCollection
public Response preloadCollection(@Nonnull String collectionName)
Description copied from interface:MilvusClientPre-loads collection to memory- Specified by:
preloadCollectionin interfaceMilvusClient- Parameters:
collectionName- collection to preload- Returns:
Response- See Also:
Response
-
describeIndex
public DescribeIndexResponse describeIndex(@Nonnull String collectionName)
Description copied from interface:MilvusClientDescribes collection index- Specified by:
describeIndexin interfaceMilvusClient- Parameters:
collectionName- collection to describe index of- See Also:
DescribeIndexResponse,Index,Response
-
dropIndex
public Response dropIndex(@Nonnull String collectionName)
Description copied from interface:MilvusClientDrops collection index- Specified by:
dropIndexin interfaceMilvusClient- Parameters:
collectionName- collection to drop index of- See Also:
Response
-
showCollectionInfo
public ShowCollectionInfoResponse showCollectionInfo(String collectionName)
Description copied from interface:MilvusClientShows 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.- Specified by:
showCollectionInfoin interfaceMilvusClient- Parameters:
collectionName- collection to show info from- See Also:
ShowCollectionInfoResponse,CollectionInfo,CollectionInfo.PartitionInfo,CollectionInfo.PartitionInfo.SegmentInfo,Response
-
getVectorById
public GetVectorByIdResponse getVectorById(String collectionName, Long id)
Description copied from interface:MilvusClientGets either a float or binary vector by id.- Specified by:
getVectorByIdin interfaceMilvusClient- Parameters:
collectionName- collection to get vector fromid- vector id- See Also:
GetVectorByIdResponse,Response
-
getVectorIds
public GetVectorIdsResponse getVectorIds(String collectionName, String segmentName)
Description copied from interface:MilvusClientGets all vector ids in a segment- Specified by:
getVectorIdsin interfaceMilvusClient- Parameters:
collectionName- collection to get vector ids fromsegmentName- segment name- See Also:
GetVectorIdsResponse,Response
-
deleteByIds
public Response deleteByIds(String collectionName, List<Long> ids)
Description copied from interface:MilvusClientDeletes data in a collection by a list of ids- Specified by:
deleteByIdsin interfaceMilvusClient- Parameters:
collectionName- collection to delete ids fromids- aListof vector ids to delete- See Also:
Response
-
deleteById
public Response deleteById(String collectionName, Long id)
Description copied from interface:MilvusClientDeletes data in a collection by a single id- Specified by:
deleteByIdin interfaceMilvusClient- Parameters:
collectionName- collection to delete id fromid- vector id to delete- See Also:
Response
-
flush
public Response flush(List<String> collectionNames)
Description copied from interface:MilvusClientFlushes data in a list collections. Newly inserted or modifications on data will be visible afterflushreturned- Specified by:
flushin interfaceMilvusClient- Parameters:
collectionNames- aListof collections to flush- See Also:
Response
-
flush
public Response flush(String collectionName)
Description copied from interface:MilvusClientFlushes data in a collection. Newly inserted or modifications on data will be visible afterflushreturned- Specified by:
flushin interfaceMilvusClient- Parameters:
collectionName- name of collection to flush- See Also:
Response
-
compact
public Response compact(String collectionName)
Description copied from interface:MilvusClientCompacts 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:
compactin interfaceMilvusClient- Parameters:
collectionName- name of collection to compact- See Also:
Response
-
-