mathsgod / milvus-client-php
A PHP client for Milvus
1.0.0
2024-07-12 02:14 UTC
Requires
- guzzlehttp/guzzle: ^7.5
Requires (Dev)
- phpunit/phpunit: ^9.6
README
A PHP client for Milvus. This library only supports Milvus 2.x.
Setup
composer require mathsgod/milvus-client-php
Usage
Create a Collection
$client=new Milvus\Client($host, $port); // Create a collection with 5 dimensions $client->collections()->create("test_collection",5);
Insert Vectors
$collection = $client->entities("test_collection"); $collection->insert([ [ "id"=>1, "vector" => [1.0, 2.0, 3.0, 4.0, 5.0] ], [ "id"=>2, "vector" => [2.0, 2.0, 3.0, 4.0, 5.0] ], [ "id"=>3, "vector" => [3.0, 2.0, 3.0, 4.0, 5.0] ], [ "id"=>4, "vector" => [4.0, 2.0, 3.0, 4.0, 5.0] ], [ "id"=>5, "vector" => [5.0, 2.0, 3.0, 4.0, 5.0] ], ]);
Load Collection
$collection = $client->collection("test_collection"); $collection->load();
Search Vectors
// Search for the top 10 vectors that are most similar to the vector [1.0,3.0,3.0,4.0,5.0] $result = $client->entities("test_collection")->search("vector",[1.0,3.0,3.0,4.0,5.0],10);
Query Entities
$e = $client->entities("test_collection"); $result = $e->query("id in [1,2,3,4,5]");
Delete Entities
$e = $client->entities("test_collection"); $e->delete("id in [1]");
Users
List Users
$users = $client->users()->list();
Create a User
$client->users()->create("test_user");
Delete a User
$client->user("test_user")->drop();
Grant role
$client->user("test_user")->grantRole("admin");
Revoke role
$client->user("test_user")->revokeRole("admin");
Roles
List roles
$roles = $client->roles()->list();