PHP code example of hejunjie / milvus

1. Go to this page and download the library: Download hejunjie/milvus library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hejunjie / milvus example snippets


use Hejunjie\Milvus;

// Initialize client (get the URL and API Key from Zilliz Cloud console)
$client = new Milvus\Client('https://xxx.api.zillizcloud.com', 'your-api-key');

// Create a collection
$client->collections()->create('my_collection', [
    'autoID' => true,
    'fields' => [
        ['fieldName' => 'id', 'dataType' => 'Int64', 'isPrimary' => true],
        ['fieldName' => 'vector', 'dataType' => 'FloatVector', 'elementTypeParams' => ['dim' => 128]],
        ['fieldName' => 'title', 'dataType' => 'VarChar', 'elementTypeParams' => ['max_length' => 256]],
    ]
]);

// Create an index (vector fields r', limit: 10);