PHP code example of tsterker / solarium-collection-manager

1. Go to this page and download the library: Download tsterker/solarium-collection-manager 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/ */

    

tsterker / solarium-collection-manager example snippets


use Solarium\Client;
use Solarium\Core\Client\Adapter\Curl;
use Symfony\Component\EventDispatcher\EventDispatcher;
use TSterker\SolariumCollectionManager\CollectionManager;

// Create Solarium client (https://solarium.readthedocs.io/en/stable/client-and-adapters/)
$solariumClient = new Client(new Curl, new EventDispatcher, [
    'endpoint' => [
        'default' => ['host' => '127.0.0.1', 'port' => 8983, 'path' =>  '/']
    ],
]);

$collectionManager = new CollectionManager($client);

$collectionManager->hasCollection('foo');  // false
$collectionManager->create('foo', ['num_shards' => 2, 'nrt_replicas' => 2]);
$collectionManager->hasCollection('foo');  // true