setQuery('*:*'); $this->setStart(2)->setRows(20); $this->setFields(array('id','name','price')); $this->addSort('price', Solarium_Query_Select::SORT_ASC); // create a facet field instance and set options $facetSet = $this->getFacetSet(); $facetSet->createFacetField('stock')->setField('inStock'); } } // This query inherits all of the query params of it's parent (using parent::_init) and adds some more // Ofcourse it could also alter or remove settings class ProductPriceLimitedQuery extends ProductQuery{ protected function _init() { parent::_init(); // create a filterquery $this->createFilterQuery('maxprice')->setQuery('price:[1 TO 300]'); } } // create a client instance $client = new Solarium_Client($config); // create a query instance $query = new ProductPriceLimitedQuery; // 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 '
id | ' . $document->id . ' |
---|---|
name | ' . $document->name . ' |
price | ' . $document->price . ' |