/**
  * {@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;
 }
 /**
  * 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()
 {
     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()];
 }
 /**
  * {@inheritdoc}
  */
 public function addBuilder(BuilderInterface $builder, $parameters = [])
 {
     if (!$this->query && !(array_key_exists('bool_type', $parameters) && !empty($parameters['bool_type']))) {
         $this->setBuilder($builder);
     } else {
         $parameters = $this->resolver->resolve(array_filter($parameters));
         $this->isBool() ?: $this->convertToBool();
         $this->query->add($builder, $parameters['bool_type']);
     }
     return $this;
 }
 /**
  * @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;
 }
 /**
  * {@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()]];
 }
Beispiel #12
0
 /**
  * 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;
 }
Beispiel #15
0
 /**
  * Set query to highlight.
  *
  * @param BuilderInterface $query
  *
  * @return Field
  */
 public function setHighlightQuery(BuilderInterface $query)
 {
     $this->highlightQuery = [$query->getType() => $query->toArray()];
     return $this;
 }