createSelect(); // apply settings using the API $query->setQuery('*:*'); $query->setStart(2)->setRows(20); $query->setFields(array('id','name','price')); $query->addSort('price', Solarium_Query_Select::SORT_ASC); // create a filterquery using the API $fq = $query->createFilterQuery('maxprice')->setQuery('price:[1 TO 300]'); // create a facet field instance and set options using the API $facetSet = $query->getFacetSet(); $facet = $facetSet->createFacetField('stock')->setField('inStock'); // this executes the query and returns the result $resultset = $client->select($query); // display the total number of documents found by solr echo 'NumFound: '.$resultset->getNumFound(); // display facet counts echo '
Facet counts for field "inStock":
'; $facet = $resultset->getFacetSet()->getFacet('stock'); foreach($facet as $value => $count) { echo $value . ' [' . $count . ']
'; } // show documents using the resultset iterator foreach ($resultset as $document) { echo '
'; echo ''; echo ''; echo ''; echo '
id' . $document->id . '
name' . $document->name . '
price' . $document->price . '
'; } htmlFooter();