/**
  * {@inheritdoc}
  */
 public function toArray()
 {
     $array = parent::toArray();
     if (isset($array['script'])) {
         $array['script'] = $array['script']['script'];
     }
     return $array;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     $array = parent::toArray();
     $baseName = $this->_getBaseName();
     if (isset($array[$baseName]['query'])) {
         $array[$baseName]['query'] = $array[$baseName]['query']['query'];
     }
     return $array;
 }
예제 #3
0
 /**
  * @return array
  */
 public function toArray()
 {
     $array = parent::toArray();
     // if there are no params, it's ok, but ES will throw exception if json
     // will be like {"top_hits":[]} instead of {"top_hits":{}}
     if (empty($array['inner_hits'])) {
         $array['inner_hits'] = new \stdClass();
     }
     return $array['inner_hits'];
 }
 /**
  * @return array
  */
 public function toArray()
 {
     if (sizeof($this->_functions)) {
         $this->setParam('functions', $this->_functions);
     }
     return parent::toArray();
 }
예제 #5
0
 /**
  * Converts query to array
  *
  * @return array Query array
  * @see \Elastica\Query\AbstractQuery::toArray()
  */
 public function toArray()
 {
     $this->setParam($this->_field, array('query' => $this->_queryString));
     return parent::toArray();
 }
예제 #6
0
 /**
  * Sets nested query.
  *
  * @param \Elastica\Query\AbstractQuery $query
  *
  * @return $this
  */
 public function setQuery(AbstractQuery $query)
 {
     return $this->setParam('query', $query->toArray());
 }
 public function toArray()
 {
     $array = parent::toArray();
     // If _id is provided, perform MLT on an existing document from the index
     // If _source is provided, perform MLT on a document provided as an input
     if (!empty($array['more_like_this']['like']['_id'])) {
         $doc = $array['more_like_this']['like'];
         $doc = array_intersect_key($doc, array('_index' => 1, '_type' => 1, '_id' => 1));
         $array['more_like_this']['like'] = $doc;
     } elseif (!empty($array['more_like_this']['like']['_source'])) {
         $doc = $array['more_like_this']['like'];
         $doc['doc'] = $array['more_like_this']['like']['_source'];
         unset($doc['_id']);
         unset($doc['_source']);
         $array['more_like_this']['like'] = $doc;
     }
     return $array;
 }
 /**
  * Set the negative query for this Boosting Query
  * @param AbstractQuery $query
  * @return \Elastica\Query\Boosting
  */
 public function setNegativeQuery(AbstractQuery $query)
 {
     return $this->setParam('negative', $query->toArray());
 }
 /**
  * @see \Elastica\Param::toArray()
  *
  * @throws \Elastica\Exception\InvalidException
  *
  * @return array
  */
 public function toArray()
 {
     $this->setParam($this->_key, $this->_getLocationData());
     return parent::toArray();
 }
 /**
  * @return array
  */
 public function toArray()
 {
     $this->setParam($this->_field, $this->_queryParams);
     return parent::toArray();
 }
예제 #11
0
 /**
  * Converts fuzzy like this query to array.
  *
  * @return array Query array
  *
  * @see \Elastica\Query\AbstractQuery::toArray()
  */
 public function toArray()
 {
     if (!empty($this->_fields)) {
         $args['fields'] = $this->_fields;
     }
     if (!empty($this->_boost)) {
         $args['boost'] = $this->_boost;
     }
     if (!empty($this->_analyzer)) {
         $args['analyzer'] = $this->_analyzer;
     }
     $args['min_similarity'] = $this->_minSimilarity > 0 ? $this->_minSimilarity : 0;
     $args['like_text'] = $this->_likeText;
     $args['prefix_length'] = $this->_prefixLength;
     $args['ignore_tf'] = $this->_ignoreTF;
     $args['max_query_terms'] = $this->_maxQueryTerms;
     $data = parent::toArray();
     $args = array_merge($args, $data['fuzzy_like_this']);
     return array('fuzzy_like_this' => $args);
 }
예제 #12
0
 /**
  * Converts array to an object in case no queries are added.
  *
  * @return array
  */
 public function toArray()
 {
     if (empty($this->_params)) {
         $this->_params = new \stdClass();
     }
     return parent::toArray();
 }
예제 #13
0
 public function toArray()
 {
     $array = parent::toArray();
     if (isset($array['more_like_this']['like']['_id'])) {
         $doc = $array['more_like_this']['like'];
         $doc = array_intersect_key($doc, array('_index' => 1, '_type' => 1, '_id' => 1));
         $array['more_like_this']['like'] = $doc;
     }
     return $array;
 }
예제 #14
0
 /**
  * Converts the terms object to an array.
  *
  * @see \Elastica\Query\AbstractQuery::toArray()
  *
  * @throws \Elastica\Exception\InvalidException If term key is empty
  *
  * @return array Query array
  */
 public function toArray()
 {
     if (empty($this->_key)) {
         throw new InvalidException('Terms key has to be set');
     }
     $this->setParam($this->_key, $this->_terms);
     return parent::toArray();
 }