PHP code example of sammaye / yii2-solr

1. Go to this page and download the library: Download sammaye/yii2-solr 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/ */

    

sammaye / yii2-solr example snippets


$query = Yii::$app->solr->createSelect();
$query->setQuery('edismax&qf=title^20.0 OR description^0.3');
$result = Yii::$app->solr->select($query);
var_dump($result->getNumFound());

	'solr' => [
		'class' => 'sammaye\solr\Client',
		'options' => [
			'endpoint' => [
				'solr1' => [
					'host' => '10.208.225.66',
					'port' => '8983',
					'path' => '/',
					'collection' => 'myColl
				]
			]
		]
	],

$query = Yii::$app->solr->createSelect();
$query->setQuery('(alt_subject_mpath:' . $model->path . ' OR alt_subject_mpath:' . $model->path . '.*) AND live:1');

new SolrDataProvider([
    'query' => $query,
    // an example class which assigns variables to the model(s)
    // and returns the model(s) 
    'modelClass' => 'SolrResult',
    'sort' => [
        'attributes' => [
            'title',
            'sales',
            'score'
        ]
    ]
]);