@@ 21-67 (lines=47) @@ | ||
18 | * |
|
19 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-not-query.html |
|
20 | */ |
|
21 | class SpanNotQuery implements SpanQueryInterface |
|
22 | { |
|
23 | use ParametersTrait; |
|
24 | ||
25 | /** |
|
26 | * @var SpanQueryInterface |
|
27 | */ |
|
28 | private $include; |
|
29 | ||
30 | /** |
|
31 | * @var SpanQueryInterface |
|
32 | */ |
|
33 | private $exclude; |
|
34 | ||
35 | /** |
|
36 | * @param SpanQueryInterface $include |
|
37 | * @param SpanQueryInterface $exclude |
|
38 | * @param array $parameters |
|
39 | */ |
|
40 | public function __construct(SpanQueryInterface $include, SpanQueryInterface $exclude, array $parameters = []) |
|
41 | { |
|
42 | $this->include = $include; |
|
43 | $this->exclude = $exclude; |
|
44 | $this->setParameters($parameters); |
|
45 | } |
|
46 | ||
47 | /** |
|
48 | * {@inheritdoc} |
|
49 | */ |
|
50 | public function getType() |
|
51 | { |
|
52 | return 'span_not'; |
|
53 | } |
|
54 | ||
55 | /** |
|
56 | * {@inheritdoc} |
|
57 | */ |
|
58 | public function toArray() |
|
59 | { |
|
60 | $query = [ |
|
61 | 'include' => $this->include->toArray(), |
|
62 | 'exclude' => $this->exclude->toArray(), |
|
63 | ]; |
|
64 | ||
65 | return [$this->getType() => $this->processArray($query)]; |
|
66 | } |
|
67 | } |
|
68 |
@@ 22-71 (lines=50) @@ | ||
19 | * |
|
20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html |
|
21 | */ |
|
22 | class CommonTermsQuery implements BuilderInterface |
|
23 | { |
|
24 | use ParametersTrait; |
|
25 | ||
26 | /** |
|
27 | * @var string |
|
28 | */ |
|
29 | private $field; |
|
30 | ||
31 | /** |
|
32 | * @var string |
|
33 | */ |
|
34 | private $query; |
|
35 | ||
36 | /** |
|
37 | * @param string $field |
|
38 | * @param string $query |
|
39 | * @param array $parameters |
|
40 | */ |
|
41 | public function __construct($field, $query, array $parameters = []) |
|
42 | { |
|
43 | $this->field = $field; |
|
44 | $this->query = $query; |
|
45 | $this->setParameters($parameters); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * {@inheritdoc} |
|
50 | */ |
|
51 | public function getType() |
|
52 | { |
|
53 | return 'common'; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * {@inheritdoc} |
|
58 | */ |
|
59 | public function toArray() |
|
60 | { |
|
61 | $query = [ |
|
62 | 'query' => $this->query, |
|
63 | ]; |
|
64 | ||
65 | $output = [ |
|
66 | $this->field => $this->processArray($query), |
|
67 | ]; |
|
68 | ||
69 | return [$this->getType() => $output]; |
|
70 | } |
|
71 | } |
|
72 |
@@ 22-71 (lines=50) @@ | ||
19 | * |
|
20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html |
|
21 | */ |
|
22 | class MatchQuery implements BuilderInterface |
|
23 | { |
|
24 | use ParametersTrait; |
|
25 | ||
26 | /** |
|
27 | * @var string |
|
28 | */ |
|
29 | private $field; |
|
30 | ||
31 | /** |
|
32 | * @var string |
|
33 | */ |
|
34 | private $query; |
|
35 | ||
36 | /** |
|
37 | * @param string $field |
|
38 | * @param string $query |
|
39 | * @param array $parameters |
|
40 | */ |
|
41 | public function __construct($field, $query, array $parameters = []) |
|
42 | { |
|
43 | $this->field = $field; |
|
44 | $this->query = $query; |
|
45 | $this->setParameters($parameters); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * {@inheritdoc} |
|
50 | */ |
|
51 | public function getType() |
|
52 | { |
|
53 | return 'match'; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * {@inheritdoc} |
|
58 | */ |
|
59 | public function toArray() |
|
60 | { |
|
61 | $query = [ |
|
62 | 'query' => $this->query, |
|
63 | ]; |
|
64 | ||
65 | $output = [ |
|
66 | $this->field => $this->processArray($query), |
|
67 | ]; |
|
68 | ||
69 | return [$this->getType() => $output]; |
|
70 | } |
|
71 | } |
|
72 |
@@ 22-70 (lines=49) @@ | ||
19 | * |
|
20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html |
|
21 | */ |
|
22 | class MultiMatchQuery implements BuilderInterface |
|
23 | { |
|
24 | use ParametersTrait; |
|
25 | ||
26 | /** |
|
27 | * @var array |
|
28 | */ |
|
29 | private $fields = []; |
|
30 | ||
31 | /** |
|
32 | * @var string |
|
33 | */ |
|
34 | private $query; |
|
35 | ||
36 | /** |
|
37 | * @param array $fields |
|
38 | * @param string $query |
|
39 | * @param array $parameters |
|
40 | */ |
|
41 | public function __construct(array $fields, $query, array $parameters = []) |
|
42 | { |
|
43 | $this->fields = $fields; |
|
44 | $this->query = $query; |
|
45 | $this->setParameters($parameters); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * {@inheritdoc} |
|
50 | */ |
|
51 | public function getType() |
|
52 | { |
|
53 | return 'multi_match'; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * {@inheritdoc} |
|
58 | */ |
|
59 | public function toArray() |
|
60 | { |
|
61 | $query = [ |
|
62 | 'fields' => $this->fields, |
|
63 | 'query' => $this->query, |
|
64 | ]; |
|
65 | ||
66 | $output = $this->processArray($query); |
|
67 | ||
68 | return [$this->getType() => $output]; |
|
69 | } |
|
70 | } |
|
71 |
@@ 22-66 (lines=45) @@ | ||
19 | * |
|
20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-query.html |
|
21 | */ |
|
22 | class GeoPolygonQuery implements BuilderInterface |
|
23 | { |
|
24 | use ParametersTrait; |
|
25 | ||
26 | /** |
|
27 | * @var string |
|
28 | */ |
|
29 | private $field; |
|
30 | ||
31 | /** |
|
32 | * @var array |
|
33 | */ |
|
34 | private $points; |
|
35 | ||
36 | /** |
|
37 | * @param string $field |
|
38 | * @param array $points |
|
39 | * @param array $parameters |
|
40 | */ |
|
41 | public function __construct($field, array $points = [], array $parameters = []) |
|
42 | { |
|
43 | $this->field = $field; |
|
44 | $this->points = $points; |
|
45 | $this->setParameters($parameters); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * {@inheritdoc} |
|
50 | */ |
|
51 | public function getType() |
|
52 | { |
|
53 | return 'geo_polygon'; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * {@inheritdoc} |
|
58 | */ |
|
59 | public function toArray() |
|
60 | { |
|
61 | $query = [$this->field => ['points' => $this->points]]; |
|
62 | $output = $this->processArray($query); |
|
63 | ||
64 | return [$this->getType() => $output]; |
|
65 | } |
|
66 | } |
|
67 |
@@ 23-68 (lines=46) @@ | ||
20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geohash-cell-query.html |
|
21 | * @deprecated Use geohash_grid aggregation instead. |
|
22 | */ |
|
23 | class GeohashCellQuery implements BuilderInterface |
|
24 | { |
|
25 | use ParametersTrait; |
|
26 | ||
27 | /** |
|
28 | * @var string |
|
29 | */ |
|
30 | private $field; |
|
31 | ||
32 | /** |
|
33 | * @var mixed |
|
34 | */ |
|
35 | private $location; |
|
36 | ||
37 | /** |
|
38 | * @param string $field |
|
39 | * @param mixed $location |
|
40 | * @param array $parameters |
|
41 | */ |
|
42 | public function __construct($field, $location, array $parameters = []) |
|
43 | { |
|
44 | $this->field = $field; |
|
45 | $this->location = $location; |
|
46 | ||
47 | $this->setParameters($parameters); |
|
48 | } |
|
49 | ||
50 | /** |
|
51 | * {@inheritdoc} |
|
52 | */ |
|
53 | public function getType() |
|
54 | { |
|
55 | return 'geohash_cell'; |
|
56 | } |
|
57 | ||
58 | /** |
|
59 | * {@inheritdoc} |
|
60 | */ |
|
61 | public function toArray() |
|
62 | { |
|
63 | $query = [$this->field => $this->location]; |
|
64 | $output = $this->processArray($query); |
|
65 | ||
66 | return [$this->getType() => $output]; |
|
67 | } |
|
68 | } |
|
69 |
@@ 22-70 (lines=49) @@ | ||
19 | * |
|
20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-query.html |
|
21 | */ |
|
22 | class HasChildQuery implements BuilderInterface |
|
23 | { |
|
24 | use ParametersTrait; |
|
25 | ||
26 | /** |
|
27 | * @var string |
|
28 | */ |
|
29 | private $type; |
|
30 | ||
31 | /** |
|
32 | * @var BuilderInterface |
|
33 | */ |
|
34 | private $query; |
|
35 | ||
36 | /** |
|
37 | * @param string $type |
|
38 | * @param BuilderInterface $query |
|
39 | * @param array $parameters |
|
40 | */ |
|
41 | public function __construct($type, BuilderInterface $query, array $parameters = []) |
|
42 | { |
|
43 | $this->type = $type; |
|
44 | $this->query = $query; |
|
45 | $this->setParameters($parameters); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * {@inheritdoc} |
|
50 | */ |
|
51 | public function getType() |
|
52 | { |
|
53 | return 'has_child'; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * {@inheritdoc} |
|
58 | */ |
|
59 | public function toArray() |
|
60 | { |
|
61 | $query = [ |
|
62 | 'type' => $this->type, |
|
63 | 'query' => $this->query->toArray(), |
|
64 | ]; |
|
65 | ||
66 | $output = $this->processArray($query); |
|
67 | ||
68 | return [$this->getType() => $output]; |
|
69 | } |
|
70 | } |
|
71 |
@@ 22-70 (lines=49) @@ | ||
19 | * |
|
20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-parent-query.html |
|
21 | */ |
|
22 | class HasParentQuery implements BuilderInterface |
|
23 | { |
|
24 | use ParametersTrait; |
|
25 | ||
26 | /** |
|
27 | * @var string |
|
28 | */ |
|
29 | private $parentType; |
|
30 | ||
31 | /** |
|
32 | * @var BuilderInterface |
|
33 | */ |
|
34 | private $query; |
|
35 | ||
36 | /** |
|
37 | * @param string $parentType |
|
38 | * @param BuilderInterface $query |
|
39 | * @param array $parameters |
|
40 | */ |
|
41 | public function __construct($parentType, BuilderInterface $query, array $parameters = []) |
|
42 | { |
|
43 | $this->parentType = $parentType; |
|
44 | $this->query = $query; |
|
45 | $this->setParameters($parameters); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * {@inheritdoc} |
|
50 | */ |
|
51 | public function getType() |
|
52 | { |
|
53 | return 'has_parent'; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * {@inheritdoc} |
|
58 | */ |
|
59 | public function toArray() |
|
60 | { |
|
61 | $query = [ |
|
62 | 'parent_type' => $this->parentType, |
|
63 | 'query' => $this->query->toArray(), |
|
64 | ]; |
|
65 | ||
66 | $output = $this->processArray($query); |
|
67 | ||
68 | return [$this->getType() => $output]; |
|
69 | } |
|
70 | } |
|
71 |
@@ 22-71 (lines=50) @@ | ||
19 | * |
|
20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html |
|
21 | */ |
|
22 | class FuzzyQuery implements BuilderInterface |
|
23 | { |
|
24 | use ParametersTrait; |
|
25 | ||
26 | /** |
|
27 | * @var string |
|
28 | */ |
|
29 | private $field; |
|
30 | ||
31 | /** |
|
32 | * @var string |
|
33 | */ |
|
34 | private $value; |
|
35 | ||
36 | /** |
|
37 | * @param string $field |
|
38 | * @param string $value |
|
39 | * @param array $parameters |
|
40 | */ |
|
41 | public function __construct($field, $value, array $parameters = []) |
|
42 | { |
|
43 | $this->field = $field; |
|
44 | $this->value = $value; |
|
45 | $this->setParameters($parameters); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * {@inheritdoc} |
|
50 | */ |
|
51 | public function getType() |
|
52 | { |
|
53 | return 'fuzzy'; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * {@inheritdoc} |
|
58 | */ |
|
59 | public function toArray() |
|
60 | { |
|
61 | $query = [ |
|
62 | 'value' => $this->value, |
|
63 | ]; |
|
64 | ||
65 | $output = [ |
|
66 | $this->field => $this->processArray($query), |
|
67 | ]; |
|
68 | ||
69 | return [$this->getType() => $output]; |
|
70 | } |
|
71 | } |
|
72 |
@@ 22-71 (lines=50) @@ | ||
19 | * |
|
20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-prefix-query.html |
|
21 | */ |
|
22 | class PrefixQuery implements BuilderInterface |
|
23 | { |
|
24 | use ParametersTrait; |
|
25 | ||
26 | /** |
|
27 | * @var string |
|
28 | */ |
|
29 | protected $field; |
|
30 | ||
31 | /** |
|
32 | * @var string |
|
33 | */ |
|
34 | protected $value; |
|
35 | ||
36 | /** |
|
37 | * @param string $field Field name. |
|
38 | * @param string $value Value. |
|
39 | * @param array $parameters Optional parameters. |
|
40 | */ |
|
41 | public function __construct($field, $value, array $parameters = []) |
|
42 | { |
|
43 | $this->field = $field; |
|
44 | $this->value = $value; |
|
45 | $this->setParameters($parameters); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * {@inheritdoc} |
|
50 | */ |
|
51 | public function getType() |
|
52 | { |
|
53 | return 'prefix'; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * {@inheritdoc} |
|
58 | */ |
|
59 | public function toArray() |
|
60 | { |
|
61 | $query = [ |
|
62 | 'value' => $this->value, |
|
63 | ]; |
|
64 | ||
65 | $output = [ |
|
66 | $this->field => $this->processArray($query), |
|
67 | ]; |
|
68 | ||
69 | return [$this->getType() => $output]; |
|
70 | } |
|
71 | } |
|
72 |
@@ 22-71 (lines=50) @@ | ||
19 | * |
|
20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html |
|
21 | */ |
|
22 | class RegexpQuery implements BuilderInterface |
|
23 | { |
|
24 | use ParametersTrait; |
|
25 | ||
26 | /** |
|
27 | * @var string Field to be queried. |
|
28 | */ |
|
29 | private $field; |
|
30 | ||
31 | /** |
|
32 | * @var string The actual regexp value to be used. |
|
33 | */ |
|
34 | private $regexpValue; |
|
35 | ||
36 | /** |
|
37 | * @param string $field |
|
38 | * @param string $regexpValue |
|
39 | * @param array $parameters |
|
40 | */ |
|
41 | public function __construct($field, $regexpValue, array $parameters = []) |
|
42 | { |
|
43 | $this->field = $field; |
|
44 | $this->regexpValue = $regexpValue; |
|
45 | $this->setParameters($parameters); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * {@inheritdoc} |
|
50 | */ |
|
51 | public function getType() |
|
52 | { |
|
53 | return 'regexp'; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * {@inheritdoc} |
|
58 | */ |
|
59 | public function toArray() |
|
60 | { |
|
61 | $query = [ |
|
62 | 'value' => $this->regexpValue, |
|
63 | ]; |
|
64 | ||
65 | $output = [ |
|
66 | $this->field => $this->processArray($query), |
|
67 | ]; |
|
68 | ||
69 | return [$this->getType() => $output]; |
|
70 | } |
|
71 | } |
|
72 |
@@ 22-71 (lines=50) @@ | ||
19 | * |
|
20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html |
|
21 | */ |
|
22 | class TermsQuery implements BuilderInterface |
|
23 | { |
|
24 | use ParametersTrait; |
|
25 | ||
26 | /** |
|
27 | * @var string |
|
28 | */ |
|
29 | private $field; |
|
30 | ||
31 | /** |
|
32 | * @var array |
|
33 | */ |
|
34 | private $terms; |
|
35 | ||
36 | /** |
|
37 | * Constructor. |
|
38 | * |
|
39 | * @param string $field Field name |
|
40 | * @param array $terms An array of terms |
|
41 | * @param array $parameters Optional parameters |
|
42 | */ |
|
43 | public function __construct($field, $terms, array $parameters = []) |
|
44 | { |
|
45 | $this->field = $field; |
|
46 | $this->terms = $terms; |
|
47 | $this->setParameters($parameters); |
|
48 | } |
|
49 | ||
50 | /** |
|
51 | * {@inheritdoc} |
|
52 | */ |
|
53 | public function getType() |
|
54 | { |
|
55 | return 'terms'; |
|
56 | } |
|
57 | ||
58 | /** |
|
59 | * {@inheritdoc} |
|
60 | */ |
|
61 | public function toArray() |
|
62 | { |
|
63 | $query = [ |
|
64 | $this->field => $this->terms, |
|
65 | ]; |
|
66 | ||
67 | $output = $this->processArray($query); |
|
68 | ||
69 | return [$this->getType() => $output]; |
|
70 | } |
|
71 | } |
|
72 |
@@ 22-71 (lines=50) @@ | ||
19 | * |
|
20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html |
|
21 | */ |
|
22 | class WildcardQuery implements BuilderInterface |
|
23 | { |
|
24 | use ParametersTrait; |
|
25 | ||
26 | /** |
|
27 | * @var string |
|
28 | */ |
|
29 | private $field; |
|
30 | ||
31 | /** |
|
32 | * @var string |
|
33 | */ |
|
34 | private $value; |
|
35 | ||
36 | /** |
|
37 | * @param string $field |
|
38 | * @param string $value |
|
39 | * @param array $parameters |
|
40 | */ |
|
41 | public function __construct($field, $value, array $parameters = []) |
|
42 | { |
|
43 | $this->field = $field; |
|
44 | $this->value = $value; |
|
45 | $this->setParameters($parameters); |
|
46 | } |
|
47 | ||
48 | /** |
|
49 | * {@inheritdoc} |
|
50 | */ |
|
51 | public function getType() |
|
52 | { |
|
53 | return 'wildcard'; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * {@inheritdoc} |
|
58 | */ |
|
59 | public function toArray() |
|
60 | { |
|
61 | $query = [ |
|
62 | 'value' => $this->value, |
|
63 | ]; |
|
64 | ||
65 | $output = [ |
|
66 | $this->field => $this->processArray($query), |
|
67 | ]; |
|
68 | ||
69 | return [$this->getType() => $output]; |
|
70 | } |
|
71 | } |
|
72 |