/** * @see Elastica_Param::toArray() */ public function toArray() { $data = parent::toArray(); $name = $this->_getBaseName(); $filterData = $data[$name]; if (empty($filterData)) { $filterData = $this->_query; } else { $filterData['query'] = $this->_query; } $data[$name] = $filterData; return $data; }
/** * Sets a filter for this facet. * * @param Elastica_Filter_Abstract $filter A filter to apply on the facet. * @return Elastica_Facet_Abstract */ public function setFilter(Elastica_Filter_Abstract $filter) { return $this->_setFacetParam('facet_filter', $filter->toArray()); }
/** * Convers object to array * * @see Elastica_Filter_Abstract::toArray() * @return array Filter array */ public function toArray() { $this->setParams($this->_fields); return parent::toArray(); }
/** * Add a filter with a script to calculate the score * * @param Elastica_Filter_Abstract $filter Filter object * @param Elastica_Script $script Script for calculating the score * @return Elastica_Query_CustomFiltersScore Current object */ public function addFilterScript(Elastica_Filter_Abstract $filter, Elastica_Script $script) { $filterParam = array('filter' => $filter->toArray(), 'script' => $script->getScript()); $this->addParam('filters', $filterParam); return $this; }
/** * Convers object to an arrray * * @see Elastica_Filter_Abstract::toArray() * @return array data array */ public function toArray() { $this->setParam($this->_field, $this->_prefix); return parent::toArray(); }
/** * Add a filter with boost * * @param Elastica_Filter_Abstract $filter Filter object * @param float $boost Boost for the filter * @return Elastica_Query_CustomFiltersScore Current object */ public function addFilter(Elastica_Filter_Abstract $filter, $boost) { $filter_param = array('filter' => $filter->toArray(), 'boost' => $boost); $this->addParam('filters', $filter_param); return $this; }
public function __construct(Elastica_Filter_Abstract $filter) { $this->_filter = $filter->toArray(); }
public function addFilter(Elastica_Filter_Abstract $filter) { $this->_filters[] = $filter->toArray(); }
/** * @see Elastica_Param::toArray() * @throws Elastica_Exception_Invalid */ public function toArray() { $data = parent::toArray(); // Add location to data array $filterName = $this->_getBaseName(); $filterData = $data[$filterName]; if ($this->_locationType === 'latlon') { // Latitude/longitude $location = array(); if (isset($this->_latitude)) { // Latitude $location['lat'] = $this->_latitude; } else { throw new Elastica_Exception_Invalid('Latitude has to be set'); } if (isset($this->_longitude)) { // Geohash $location['lon'] = $this->_longitude; } else { throw new Elastica_Exception_Invalid('Longitude has to be set'); } } elseif ($this->_locationType === 'geohash') { // Geohash $location = $this->_geohash; } else { // Invalid location type throw new Elastica_Exception_Invalid('Invalid location type'); } $filterData[$this->_key] = $location; $data[$filterName] = $filterData; return $data; }
/** * Adds one more filter to the and filter * * @param Elastica_Filter_Abstract $filter * @return Elastica_Filter_And Current object */ public function addFilter(Elastica_Filter_Abstract $filter) { $this->_params[] = $filter->toArray(); return $this; }
/** * Sets nested filter * * @param Elastica_Filter_Abstract $filter * @return Elastica_Filter_Nested */ public function setFilter(Elastica_Filter_Abstract $filter) { return $this->setParam('query', $filter->toArray()); }