Esempio n. 1
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. 2
0
 /**
  * Add request settings for the stats component
  *
  * @param  StatsComponent $component
  * @param  Request        $request
  * @return Request
  */
 public function buildComponent($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;
 }
Esempio n. 3
0
 /**
  * Add request settings for the stats component
  *
  * @param  StatsComponent $component
  * @param  Request        $request
  * @return Request
  */
 public function buildComponent($component, $request)
 {
     // enable stats
     $request->addParam('stats', 'true');
     // add fields
     foreach ($component->getFields() as $field) {
         $value = $this->renderLocalParams($field->getKey(), array('ex' => $field->getExcludes()));
         $request->addParam('stats.field', $value);
         // 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;
 }
Esempio n. 4
0
 /**
  * Add request settings for the stats component.
  *
  * @param StatsComponent $component
  * @param Request        $request
  *
  * @return Request
  */
 public function buildComponent($component, $request)
 {
     // enable stats
     $request->addParam('stats', 'true');
     // add fields
     foreach ($component->getFields() as $field) {
         $pivots = $field->getPivots();
         $prefix = count($pivots) > 0 ? '{!tag=' . implode(',', $pivots) . '}' : '';
         $request->addParam('stats.field', $prefix . $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;
 }