Exemple #1
0
 /**
  * Creates the full facet definition, which includes the basic
  * facet definition of the parent.
  * 
  * @see Elastica_Facet_Abstract::toArray()
  * @return array
  */
 public function toArray()
 {
     parent::setParam('terms', $this->_params);
     return $this->_query;
 }
Exemple #2
0
 /**
  * Creates the full facet definition, which includes the basic
  * facet definition of the parent.
  * 
  * @see Elastica_Facet_Abstract::toArray()
  * @throws Elastica_Exception_Invalid When the right fields haven't been set.
  * @return array
  */
 public function toArray()
 {
     /**
      * Check the facet for validity.
      * There are three ways to set the key and value field for the range:
      *  - a single field for both key and value; or
      *  - separate fields for key and value; or
      *  - separate scripts for key and value. 
      */
     $fieldTypesSet = 0;
     if (isset($this->_params['field'])) {
         $fieldTypesSet++;
     }
     if (isset($this->_params['key_field'])) {
         $fieldTypesSet++;
     }
     if (isset($this->_params['key_script'])) {
         $fieldTypesSet++;
     }
     if ($fieldTypesSet === 0) {
         throw new Elastica_Exception_Invalid('Neither field, key_field nor key_script is set.');
     } else {
         if ($fieldTypesSet > 1) {
             throw new Elastica_Exception_Invalid('Either field, key_field and key_value or key_script and value_script should be set.');
         }
     }
     /**
      * Set the range in the abstract as param.
      */
     parent::setParam('range', $this->_params);
     return $this->_query;
 }