MultiMatchQuery::tie_breaker()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace olvlvl\ElasticsearchDSL\Query\Text;
4
5
use olvlvl\ElasticsearchDSL\Query\Option\HasMatchOptions;
6
use olvlvl\ElasticsearchDSL\Query\Option\MatchOptions;
7
use olvlvl\ElasticsearchDSL\Query\QueryAbstract;
8
9
class MultiMatchQuery extends QueryAbstract implements HasMatchOptions
10
{
11
	use MatchOptions;
12
13
	const NAME = 'multi_match';
14
15
	/**
16
	 * @var array
17
	 */
18
	private $fields;
19
20
	/**
21
	 * @var string
22
	 */
23
	private $query;
24
25
	public function __construct(array $fields, string $query)
26
	{
27
		$this->fields = $fields;
28
		$this->query = $query;
29
	}
30
31
	public function type(?string $type)
32
	{
33
		$this->options[__FUNCTION__] = $type;
34
35
		return $this;
36
	}
37
38
	public function tie_breaker(?float $tie_breaker)
39
	{
40
		$this->options[__FUNCTION__] = $tie_breaker;
41
42
		return $this;
43
	}
44
45
	/**
46
	 * @inheritdoc
47
	 */
48
	public function jsonSerialize()
49
	{
50
		return [ self::NAME => [ 'query' => $this->query, 'fields' => $this->fields ] + parent::jsonSerialize() ];
51
	}
52
}
53