* @license http://github.com/basdenooijer/solarium/raw/master/COPYING * @link http://www.solarium-project.org/ * * @package Solarium * @subpackage Client */ /** * Build a select request * * @package Solarium * @subpackage Client */ class Solarium_Client_RequestBuilder_Select extends Solarium_Client_RequestBuilder { /** * Build request for a select query * * @param Solarium_Query_Select $query * @return Solarium_Client_Request */ public function build($query) { $request = parent::build($query); // add basic params to request $request->addParam('q', $query->getQuery()); $request->addParam('start', $query->getStart()); $request->addParam('rows', $query->getRows()); $request->addParam('fl', implode(',', $query->getFields())); $request->addParam('q.op', $query->getQueryDefaultOperator()); $request->addParam('df', $query->getQueryDefaultField()); // add sort fields to request $sort = array(); foreach ($query->getSorts() AS $field => $order) { $sort[] = $field . ' ' . $order; } if (count($sort) !== 0) { $request->addParam('sort', implode(',', $sort)); } // add filterqueries to request $filterQueries = $query->getFilterQueries(); if (count($filterQueries) !== 0) { foreach ($filterQueries AS $filterQuery) { $fq = $this->renderLocalParams( $filterQuery->getQuery(), array('tag' => $filterQuery->getTags()) ); $request->addParam('fq', $fq); } } // add components to request $types = $query->getComponentTypes(); foreach ($query->getComponents() as $component) { $componentBuilderClass = $types[$component->getType()]['requestbuilder']; if (!empty($componentBuilderClass)) { $componentBuilder = new $componentBuilderClass; $request = $componentBuilder->buildComponent($component, $request); } } return $request; } }