* @copyright Copyright 2011 Gasol Wu * @license http://github.com/basdenooijer/solarium/raw/master/COPYING * @link http://www.solarium-project.org/ * * @package Solarium * @subpackage Client */ /** * Build a MoreLikeThis request * * @package Solarium * @subpackage Client */ class Solarium_Client_RequestBuilder_MoreLikeThis extends Solarium_Client_RequestBuilder_Select { /** * Build request for a MoreLikeThis query * * @param Solarium_Query_MoreLikeThis $query * @return Solarium_Client_Request */ public function build($query) { $request = parent::build($query); // add mlt params to request $request->addParam('mlt.interestingTerms', $query->getInterestingTerms()); $request->addParam('mlt.match.include', $query->getMatchInclude()); $request->addParam('mlt.match.offset', $query->getStart()); $request->addParam('mlt.fl', $query->getMltFields()); $request->addParam('mlt.mintf', $query->getMinimumTermFrequency()); $request->addParam('mlt.mindf', $query->getMinimumDocumentFrequency()); $request->addParam('mlt.minwl', $query->getMinimumWordLength()); $request->addParam('mlt.maxwl', $query->getMaximumWordLength()); $request->addParam('mlt.maxqt', $query->getMaximumQueryTerms()); $request->addParam('mlt.maxntp', $query->getMaximumNumberOfTokens()); $request->addParam('mlt.boost', $query->getBoost()); $request->addParam('mlt.qf', $query->getQueryFields()); // convert query to stream if necessary if (true === $query->getQueryStream()) { $request->removeParam('q'); $request->setRawData($query->getQuery()); $request->setMethod(Solarium_Client_Request::METHOD_POST); $request->addHeader('Content-Type: text/plain; charset=utf-8'); } return $request; } }