/**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException
  */
 public function toArray()
 {
     $query = [];
     $query['match'] = [$this->query->getType() => $this->query->toArray()];
     $output = $this->processArray($query);
     return $output;
 }
 /**
  * {@inheritdoc}
  */
 public function getArray()
 {
     if (!$this->filter) {
         throw new \LogicException("Filter aggregation `{$this->getName()}` has no filter added");
     }
     $filterData = [$this->filter->getType() => $this->filter->toArray()];
     return $filterData;
 }
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     if ($this->hasParameter('_cache')) {
         $query = [];
         $query['query'] = [$this->query->getType() => $this->query->toArray()];
         $output = $this->processArray($query);
         return $output;
     }
     return [$this->query->getType() => $this->query->toArray()];
 }
 /**
  * @param BuilderInterface $filter
  * @param string           $name
  *
  * @throws \LogicException
  *
  * @return FiltersAggregation
  */
 public function addFilter(BuilderInterface $filter, $name = '')
 {
     if ($this->anonymous === false && empty($name)) {
         throw new \LogicException('In not anonymous filters filter name must be set.');
     } elseif ($this->anonymous === false && !empty($name)) {
         $this->filters['filters'][$name] = [$filter->getType() => $filter->toArray()];
     } else {
         $this->filters['filters'][] = [$filter->getType() => $filter->toArray()];
     }
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     if (count($this->indices) > 1) {
         $output = ['indices' => $this->indices];
     } else {
         $output = ['index' => $this->indices[0]];
     }
     $output['query'] = [$this->query->getType() => $this->query->toArray()];
     if ($this->noMatchQuery !== null) {
         if (is_a($this->noMatchQuery, 'ONGR\\ElasticsearchBundle\\DSL\\BuilderInterface')) {
             $output['no_match_query'] = [$this->noMatchQuery->getType() => $this->noMatchQuery->toArray()];
         } else {
             $output['no_match_query'] = $this->noMatchQuery;
         }
     }
     return $output;
 }
 /**
  * Add BuilderInterface object to bool operator.
  *
  * @param BuilderInterface $builder Query or a filter to add to bool.
  * @param string           $type    Bool type. Available: must, must_not, should.
  *
  * @return BoolQuery
  *
  * @throws \UnexpectedValueException
  */
 public function add(BuilderInterface $builder, $type = self::MUST)
 {
     if (!in_array($type, (new \ReflectionObject($this))->getConstants())) {
         throw new \UnexpectedValueException(sprintf('The bool operator %s is not supported', $type));
     }
     $this->container[$type][] = [$builder->getType() => $builder->toArray()];
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     $query = [strtolower($this->getDslType()) => [$this->query->getType() => $this->query->toArray()]];
     $output = $this->processArray($query);
     return $output;
 }
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     $query = ['parent_type' => $this->parentType, $this->getDslType() => [$this->query->getType() => $this->query->toArray()]];
     $output = $this->processArray($query);
     return $output;
 }
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     $query = ['positive' => [$this->positive->getType() => $this->positive->toArray()], 'negative' => [$this->negative->getType() => $this->negative->toArray()], 'negative_boost' => $this->negativeBoost];
     return $query;
 }
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     return ['path' => $this->path, 'query' => [$this->query->getType() => $this->query->toArray()]];
 }
 /**
  * Adds filter.
  *
  * @param BuilderInterface $filter
  *
  * @return AndFilter
  */
 public function add(BuilderInterface $filter)
 {
     $this->filters[] = [$filter->getType() => $filter->toArray()];
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     $query = ['path' => $this->path, 'filter' => [$this->query->getType() => $this->query->toArray()]];
     $output = $this->processArray($query);
     return $output;
 }
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     $query = ['type' => $this->type, 'query' => [$this->query->getType() => $this->query->toArray()]];
     $output = $this->processArray($query);
     return $output;
 }
Exemple #14
0
 /**
  * Set query to highlight.
  *
  * @param BuilderInterface $query
  *
  * @return Field
  */
 public function setHighlightQuery(BuilderInterface $query)
 {
     $this->highlightQuery = [$query->getType() => $query->toArray()];
     return $this;
 }