-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSpanNot.php
More file actions
57 lines (44 loc) · 1.06 KB
/
SpanNot.php
File metadata and controls
57 lines (44 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types = 1);
namespace Spameri\ElasticQuery\Query;
/**
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-not-query.html
*/
class SpanNot implements \Spameri\ElasticQuery\Query\LeafQueryInterface
{
public function __construct(
private \Spameri\ElasticQuery\Query\LeafQueryInterface $include,
private \Spameri\ElasticQuery\Query\LeafQueryInterface $exclude,
private int|null $pre = null,
private int|null $post = null,
private int|null $dist = null,
)
{
}
public function key(): string
{
return 'span_not_' . $this->include->key() . '_' . $this->exclude->key();
}
/**
* @return array<string, array<string, mixed>>
*/
public function toArray(): array
{
$body = [
'include' => $this->include->toArray(),
'exclude' => $this->exclude->toArray(),
];
if ($this->pre !== null) {
$body['pre'] = $this->pre;
}
if ($this->post !== null) {
$body['post'] = $this->post;
}
if ($this->dist !== null) {
$body['dist'] = $this->dist;
}
return [
'span_not' => $body,
];
}
}