Issues (17)

lib/Query/Joining/NestedQuery.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace olvlvl\ElasticsearchDSL\Query\Joining;
4
5
use ICanBoogie\Accessor\AccessorTrait;
6
use olvlvl\ElasticsearchDSL\Query;
7
use olvlvl\ElasticsearchDSL\Query\QueryAbstract;
8
9
/**
10
 * @property-read Query $query
11
 *
12
 * @see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-nested-query.html
13
 */
14
class NestedQuery extends QueryAbstract
15
{
16
	use AccessorTrait;
17
18
	const NAME = 'nested';
19
20
	/**
21
	 * @var string
22
	 */
23
	private $path;
24
25
	/**
26
	 * @var Query
27
	 */
28
	private $query;
29
30
	protected function get_query(): Query
31
	{
32
		return $this->query;
33
	}
34
35
	public function __construct(string $path)
36
	{
37
		$this->path = $path;
38
		$this->query = new Query();
0 ignored issues
show
The property query is declared read-only in olvlvl\ElasticsearchDSL\Query\Joining\NestedQuery.
Loading history...
39
	}
40
41
	/**
42
	 * @param null|string $score_mode
43
	 *
44
	 * @return $this
45
	 */
46
	public function score_mode(?string $score_mode)
47
	{
48
		$this->options[__FUNCTION__] = $score_mode;
49
50
		return $this;
51
	}
52
53
	/**
54
	 * @param bool $ignore_unmapped
55
	 *
56
	 * @return $this
57
	 */
58
	public function ignore_unmapped(bool $ignore_unmapped)
59
	{
60
		$this->options[__FUNCTION__] = $ignore_unmapped;
61
62
		return $this;
63
	}
64
65
	/**
66
	 * @inheritdoc
67
	 */
68
	public function jsonSerialize()
69
	{
70
		return [ self::NAME => [
71
72
			'path' => $this->path,
73
74
		] + parent::jsonSerialize() + $this->query->jsonSerialize() ];
75
	}
76
}
77