Skip to content

Commit 6505cbd

Browse files
committed
Exists query
1 parent 996e865 commit 6505cbd

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/Query/Exists.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Spameri\ElasticQuery\Query;
4+
5+
6+
/**
7+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html
8+
*/
9+
class Exists implements LeafQueryInterface
10+
{
11+
12+
/**
13+
* @var string
14+
*/
15+
private $field;
16+
17+
18+
public function __construct(
19+
string $field
20+
)
21+
{
22+
$this->field = $field;
23+
}
24+
25+
26+
public function key() : string
27+
{
28+
return 'exits_' . $this->field;
29+
}
30+
31+
32+
public function toArray() : array
33+
{
34+
return [
35+
'exists' => [
36+
'field' => $this->field,
37+
],
38+
];
39+
}
40+
41+
}

0 commit comments

Comments
 (0)