sdk.client.Client module¶
sdk.client.Client.Milvus¶
-
class
client.Client.
Milvus
¶ Bases:
client.Abstract.ConnectIntf
The Milvus object is used to connect and communicate with the server
-
add_vectors
(table_name, records)¶ Add vectors to table
- Parameters
table_name (str) – table name been inserted
records (list[RowRecord]) –
list of vectors been inserted
Please use Prepare.row_record generate records
- Returns
Status: indicate if vectors inserted successfully
ids: list of id, after inserted every vector is given a id
- Return type
(Status, list(str))
-
client_version
()¶ Provide client version
- Returns
Client version
- Return type
str
-
connect
(host='localhost', port='9090', uri=None)¶ Connect method should be called before any operations. Server will be connected after connect return OK
- Parameters
host (str) – (Required) host of the server
port (str) – (Required) port of the server
uri (str) – (Optional)
- Returns
Status, indicate if connect is successful
- Return type
-
property
connected
¶ Check if client is connected to the server
- Returns
if client is connected
:rtype bool
-
create_table
(param)¶ Create table
- Parameters
param (TableSchema) –
Provide table information to be created
Please use Prepare.table_schema generate param
- Returns
Status, indicate if operation is successful
- Return type
-
delete_table
(table_name)¶ Delete table with table_name
- Parameters
table_name (str) – Name of the table being deleted
- Returns
Status, indicate if operation is successful
- Return type
-
describe_table
(table_name)¶ Show table information
- Parameters
table_name (str) – which table to be shown
- Returns
(Status, table_schema) Status: indicate if query is successful table_schema: return when operation is successful
- Return type
(Status, TableSchema)
-
disconnect
()¶ Disconnect the client
- Returns
Status, indicate if disconnect is successful
- Return type
-
get_table_row_count
(table_name)¶ Get table row count
- Parameters
table_name (str) – target table name.
- Returns
Status: indicate if operation is successful
res: int, table row count
-
search_vectors
(table_name, top_k, query_records, query_ranges=None)¶ Query vectors in a table
- Parameters
query_ranges (list[Range]) – Optional ranges for conditional search. If not specified, search whole table
table_name (str) – table name been queried
query_records (list[RowRecord]) –
all vectors going to be queried
Please use Prepare.query_record generate QueryRecord
top_k (int) – int, how many similar vectors will be searched
- Returns
(Status, res)
Status: indicate if query is successful
res: return when operation is successful
- Return type
(Status, list[TopKQueryResult])
-
server_status
(cmd=None)¶ Provide server status
- Returns
Server status
:rtype : str
-
server_version
()¶ Provide server version
- Returns
Server version
-
sdk.client.Clinet.Prepare¶
-
class
client.Client.
Prepare
¶ Bases:
object
-
classmethod
range
(start, end)¶ - Parameters
start (str) – (Required) range start
end (str) – (Required) range end
- Returns
Range object
-
classmethod
row_record
(vector_data)¶ Transfer a float binary str to RowRecord and return
- Parameters
vector_data (bytearray or bytes) – (Required) binary vector to store
- Returns
RowRecord object
-
classmethod
table_schema
(table_name, dimension, index_type=<IndexType.INVALIDE: 0>, store_raw_vector=False)¶ - Parameters
table_name (str) – (Required) name of table
dimension (int) – (Required) dimension of the table
index_type (IndexType) – (Optional) index type, default = IndexType.INVALID
store_raw_vector (bool) – (Optional) default = False
- Returns
TableSchema object
-
classmethod
sdk.client.Status module¶
-
class
client.Status.
Status
(code=0, message=None)¶ Bases:
object
- Attribute code
int (optional) default as ok
- Attribute message
str (optional) current status message
-
CONNECT_FAILED
= 1¶
-
ILLEGAL_ARGUMENT
= 4¶
-
ILLEGAL_DIMENSION
= 6¶
-
ILLEGAL_RANGE
= 5¶
-
PERMISSION_DENIED
= 2¶
-
SUCCESS
= 0¶
-
TABLE_NOT_EXISTS
= 3¶