| @@ 22-64 (lines=43) @@ | ||
| 19 | * |
|
| 20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-multi-term-query.html |
|
| 21 | */ |
|
| 22 | class SpanMultiTermQuery implements SpanQueryInterface |
|
| 23 | { |
|
| 24 | use ParametersTrait; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @var BuilderInterface |
|
| 28 | */ |
|
| 29 | private $query; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * Accepts one of fuzzy, prefix, term range, wildcard, regexp query. |
|
| 33 | * |
|
| 34 | * @param BuilderInterface $query |
|
| 35 | * @param array $parameters |
|
| 36 | */ |
|
| 37 | public function __construct(BuilderInterface $query, array $parameters = []) |
|
| 38 | { |
|
| 39 | $this->query = $query; |
|
| 40 | $this->setParameters($parameters); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * {@inheritdoc} |
|
| 45 | */ |
|
| 46 | public function getType() |
|
| 47 | { |
|
| 48 | return 'span_multi'; |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * {@inheritdoc} |
|
| 53 | * |
|
| 54 | * @throws \InvalidArgumentException |
|
| 55 | */ |
|
| 56 | public function toArray() |
|
| 57 | { |
|
| 58 | $query = []; |
|
| 59 | $query['match'] = $this->query->toArray(); |
|
| 60 | $output = $this->processArray($query); |
|
| 61 | ||
| 62 | return [$this->getType() => $output]; |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ||
| @@ 22-62 (lines=41) @@ | ||
| 19 | * |
|
| 20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html |
|
| 21 | */ |
|
| 22 | class ConstantScoreQuery implements BuilderInterface |
|
| 23 | { |
|
| 24 | use ParametersTrait; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @var BuilderInterface |
|
| 28 | */ |
|
| 29 | private $query; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @param BuilderInterface $query |
|
| 33 | * @param array $parameters |
|
| 34 | */ |
|
| 35 | public function __construct(BuilderInterface $query, array $parameters = []) |
|
| 36 | { |
|
| 37 | $this->query = $query; |
|
| 38 | $this->setParameters($parameters); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * {@inheritdoc} |
|
| 43 | */ |
|
| 44 | public function getType() |
|
| 45 | { |
|
| 46 | return 'constant_score'; |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * {@inheritdoc} |
|
| 51 | */ |
|
| 52 | public function toArray() |
|
| 53 | { |
|
| 54 | $query = [ |
|
| 55 | 'filter' => $this->query->toArray(), |
|
| 56 | ]; |
|
| 57 | ||
| 58 | $output = $this->processArray($query); |
|
| 59 | ||
| 60 | return [$this->getType() => $output]; |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||
| @@ 22-62 (lines=41) @@ | ||
| 19 | * |
|
| 20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html |
|
| 21 | */ |
|
| 22 | class QueryStringQuery implements BuilderInterface |
|
| 23 | { |
|
| 24 | use ParametersTrait; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @var string The actual query to be parsed. |
|
| 28 | */ |
|
| 29 | private $query; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @param string $query |
|
| 33 | * @param array $parameters |
|
| 34 | */ |
|
| 35 | public function __construct($query, array $parameters = []) |
|
| 36 | { |
|
| 37 | $this->query = $query; |
|
| 38 | $this->setParameters($parameters); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * {@inheritdoc} |
|
| 43 | */ |
|
| 44 | public function getType() |
|
| 45 | { |
|
| 46 | return 'query_string'; |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * {@inheritdoc} |
|
| 51 | */ |
|
| 52 | public function toArray() |
|
| 53 | { |
|
| 54 | $query = [ |
|
| 55 | 'query' => $this->query, |
|
| 56 | ]; |
|
| 57 | ||
| 58 | $output = $this->processArray($query); |
|
| 59 | ||
| 60 | return [$this->getType() => $output]; |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||
| @@ 22-62 (lines=41) @@ | ||
| 19 | * |
|
| 20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html |
|
| 21 | */ |
|
| 22 | class SimpleQueryStringQuery implements BuilderInterface |
|
| 23 | { |
|
| 24 | use ParametersTrait; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @var string The actual query to be parsed. |
|
| 28 | */ |
|
| 29 | private $query; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @param string $query |
|
| 33 | * @param array $parameters |
|
| 34 | */ |
|
| 35 | public function __construct($query, array $parameters = []) |
|
| 36 | { |
|
| 37 | $this->query = $query; |
|
| 38 | $this->setParameters($parameters); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * {@inheritdoc} |
|
| 43 | */ |
|
| 44 | public function getType() |
|
| 45 | { |
|
| 46 | return 'simple_query_string'; |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * {@inheritdoc} |
|
| 51 | */ |
|
| 52 | public function toArray() |
|
| 53 | { |
|
| 54 | $query = [ |
|
| 55 | 'query' => $this->query, |
|
| 56 | ]; |
|
| 57 | ||
| 58 | $output = $this->processArray($query); |
|
| 59 | ||
| 60 | return [$this->getType() => $output]; |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||