Reputation: 364
I am using solrium , a PHP Solr cilent for using Solr with PHP , I am able to use queries like select etc . When I use select i get all only 10 results which is being set to 10 in default configuration in Solr , how do I get all results with Pagination at the result?
here's the code
<?php
require('/var/www/lg/vendor/solarium/solarium/examples/init.php');
htmlHeader();
// create a client instance
$client = new Solarium\Client($config);
// get a select query instance
$query = $client->createQuery($client::QUERY_SELECT);
// this executes the query and returns the result
$resultset = $client->execute($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
$query->setStart(2)->setRows(10);
//$query->setStart(21)->setRows(30);
echo '<hr/><table>';
// the documents are also iterable, to get all fields
foreach($document AS $field => $value)
{
// this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table>';
}
//new PageRequest(0, 10)
htmlFooter();
?>
Upvotes: 3
Views: 3495
Reputation: 10074
You can do it like: $query->setStart(2)->setRows(20)
take a look at this example:http://wiki.solarium-project.org/index.php/V3:Usage_modes
And here is a little bit more about options you can give: http://wiki.solarium-project.org/index.php/V2:Building_a_select_query
Upvotes: 5