コード例 #1
0
ファイル: Filter.php プロジェクト: xxspartan16/BMS-Market
    /**
     * and filter
     *
     * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-and-filter.html
     * @param  AbstractFilter[] $filters
     * @return BoolAnd
     */
    public function bool_and(array $filters)
    {
        $and = new BoolAnd();
        $and->setFilters($filters);

        return $and;
    }
コード例 #2
0
 private static function newAnd()
 {
     $and = new BoolAnd();
     $and->setFilters(func_get_args());
     return $and;
 }
コード例 #3
0
 /**
  * getFilter
  *
  * @access private
  * @return AbstractFilter
  */
 private function getFilter()
 {
     if (!$this->filterList) {
         return null;
     }
     if (count($this->filterList) == 1) {
         return current($this->filterList);
     }
     $boolFilters = [];
     $andFilters = [];
     foreach ($this->filterList as $tmpFilter) {
         if ($this->isAndFilter($tmpFilter)) {
             $andFilters[] = $tmpFilter;
         } else {
             $boolFilters[] = $tmpFilter;
         }
     }
     $boolFilter = null;
     $nbBoolFilters = count($boolFilters);
     if ($nbBoolFilters > 1) {
         $boolFilter = new Filter\Bool();
         foreach ($boolFilters as $tmpFilter) {
             $boolFilter->addMust($tmpFilter);
         }
         array_unshift($andFilters, $boolFilter);
     } elseif ($nbBoolFilters == 1) {
         $andFilters = array_merge($boolFilters, $andFilters);
     }
     $nbAndFilters = count($andFilters);
     if ($nbAndFilters == 1) {
         return current($andFilters);
     } elseif ($nbAndFilters > 1) {
         $filter = new Filter\BoolAnd();
         $filter->setFilters($andFilters);
         return $filter;
     }
     return null;
 }