PHP code example of cpliakas / search-framework

1. Go to this page and download the library: Download cpliakas/search-framework 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/ */

    

cpliakas / search-framework example snippets



use Search\Framework\Indexer;
use Search\Framework\SearchServiceEndpoint;

use Search\Collection\Feed\FeedCollection;     // @see https://github.com/cpliakas/feed-collection
use Search\Engine\Elasticsearch\Elasticsearch; // @see https://github.com/cpliakas/elasticsearch-engine

ct to an Elasticsearch server.
$elasticsearch = new Elasticsearch(new SearchEngineEndpoint('local', 'localhost', 'feeds', 9200));

// Instantiate an indexer, attach the collection, and index it.
$indexer = new Indexer($elasticsearch);
$indexer->attachCollection($drupal_planet);
$indexer->createIndex();
$indexer->index();



use Search\Engine\Solr\Solr;  // @see https://github.com/cpliakas/solr-search-engine

// Connect a  Solr server and pass it to the indexer.
$solr = new Solr(new SearchEngineEndpoint('local', 'http://localhost', '/solr', 8983));

$indexer = new Indexer($solr);



use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$log = new Logger('search');
$log->pushHandler(new StreamHandler('search.log', Logger::INFO));
// Use Logger::DEBUG for development and learning about the application flow.

$indexer->setLogger($log);