Esempio n. 1
0
 public function testBuildComponent()
 {
     $builder = new Solarium_Client_RequestBuilder_Select_Component_Stats();
     $request = new Solarium_Client_Request();
     $component = new Solarium_Query_Select_Component_Stats();
     $component->createField('fieldA')->addFacet('fieldFacetA');
     $component->createField('fieldB');
     $component->addFacets(array('facetA', 'facetB'));
     $request = $builder->buildComponent($component, $request);
     $this->assertEquals(array('stats' => 'true', 'stats.facet' => array('facetA', 'facetB'), 'stats.field' => array('fieldA', 'fieldB'), 'f.fieldA.stats.facet' => 'fieldFacetA'), $request->getParams());
 }
Esempio n. 2
0
 public function testSetFacets()
 {
     $this->_stats->clearFacets();
     $this->_stats->addFacets(array('facet1', 'facet2'));
     $this->_stats->setFacets(array('facet3', 'facet4'));
     $this->assertEquals(array('facet3', 'facet4'), $this->_stats->getFacets());
 }
Esempio n. 3
0
 /**
  * Add request settings for the stats component
  *
  * @param Solarium_Query_Select_Component_Stats $component
  * @param Solarium_Client_Request $request
  * @return Solarium_Client_Request
  */
 public function build($component, $request)
 {
     // enable stats
     $request->addParam('stats', 'true');
     // add fields
     foreach ($component->getFields() as $field) {
         $request->addParam('stats.field', $field->getKey());
         // add field specific facet stats
         foreach ($field->getFacets() as $facet) {
             $request->addParam('f.' . $field->getKey() . '.stats.facet', $facet);
         }
     }
     // add facet stats for all fields
     foreach ($component->getFacets() as $facet) {
         $request->addParam('stats.facet', $facet);
     }
     return $request;
 }