<?php /* * This file is part of the ONGR package. * * (c) NFQ Technologies UAB <info@nfq.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace ONGR\ElasticsearchDSL\Query; use ONGR\ElasticsearchDSL\BuilderInterface; use ONGR\ElasticsearchDSL\ParametersTrait; /** * Represents Elasticsearch "common" query. * * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html */ class CommonTermsQuery implements BuilderInterface { use ParametersTrait; /** * @var string */ private $field; /** * @var string */ private $query; /** * @param string $field * @param string $query * @param array $parameters */ public function __construct($field, $query, array $parameters = []) { $this->field = $field; $this->query = $query; $this->setParameters($parameters); } /** * {@inheritdoc} */ public function getType() { return 'common'; } /** * {@inheritdoc} */ public function toArray() { $query = [ 'query' => $this->query, ]; $output = [ $this->field => $this->processArray($query), ]; return [$this->getType() => $output]; } }