1. Go to this page and download the library: Download technosophos/solrapi 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/ */
technosophos / solrapi example snippets
$query = new \SolrAPI\Query($string, $options);
$query->search();
// Execute a search
$results = solrq('Search me')->search();
// $result now has a SolrPHPClient search result object.
foreach ($results->response->docs as $doc)) {
print $doc->title;
}
$results = solrq('monkey wrench')
->useQueryParser(SolrAPI::QUERY_PARSER_DISMAX) // Use the DisMax parser.
->limit(20) // Return 20 items
->offset(1) // Skip the first result (why? I don't know... this is just an example)
->boostQueries('sticky:true^5.0') // Increase ranking on sticky nodes.
->queryFields('title^5.0 body^20.0') // Fields to query, along with their boosts.
->retrieveFields('title, body') // just get the title and body.
->highlight() // Highlight matches in title and body.
->spellcheck() // Check spelling on query string ('blue smurf') and offer alternatives
->sort('title asc') // Sort by title, ascending
->debug(TRUE) // Include debugging info in the output.
->search(); // Execute the search.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.