Exemple #1
0
 /**
  * Add params for a range facet to request
  *
  * @param  Request    $request
  * @param  FacetRange $facet
  * @return void
  */
 public function addFacetRange($request, $facet)
 {
     $field = $facet->getField();
     $request->addParam('facet.range', $this->renderLocalParams($field, array('key' => $facet->getKey(), 'ex' => $facet->getExcludes())));
     $request->addParam("f.{$field}.facet.range.start", $facet->getStart());
     $request->addParam("f.{$field}.facet.range.end", $facet->getEnd());
     $request->addParam("f.{$field}.facet.range.gap", $facet->getGap());
     $request->addParam("f.{$field}.facet.range.hardend", $facet->getHardend());
     $request->addParam("f.{$field}.facet.mincount", $facet->getMinCount());
     foreach ($facet->getOther() as $otherValue) {
         $request->addParam("f.{$field}.facet.range.other", $otherValue);
     }
     foreach ($facet->getInclude() as $includeValue) {
         $request->addParam("f.{$field}.facet.range.include", $includeValue);
     }
 }
 /**
  * Add a facet result for a range facet
  *
  * @param  Query            $query
  * @param  QueryFacetRange  $facet
  * @param  array            $data
  * @return ResultFacetRange
  */
 protected function facetRange($query, $facet, $data)
 {
     $key = $facet->getKey();
     if (isset($data['facet_counts']['facet_ranges'][$key])) {
         $data = $data['facet_counts']['facet_ranges'][$key];
         $before = isset($data['before']) ? $data['before'] : null;
         $after = isset($data['after']) ? $data['after'] : null;
         $between = isset($data['between']) ? $data['between'] : null;
         $start = isset($data['start']) ? $data['start'] : null;
         $end = isset($data['end']) ? $data['end'] : null;
         $gap = isset($data['gap']) ? $data['gap'] : null;
         if ($query->getResponseWriter() == $query::WT_JSON) {
             $data['counts'] = $this->convertToKeyValueArray($data['counts']);
         }
         return new ResultFacetRange($data['counts'], $before, $after, $between, $start, $end, $gap);
     }
 }
 public function testSetAndGetIncludeArray()
 {
     $this->facet->setInclude(array('lower', 'upper'));
     $this->assertEquals(array('lower', 'upper'), $this->facet->getInclude());
 }