Skip to content

Commit eb8fa30

Browse files
committed
added matchall query
1 parent 6ee0967 commit eb8fa30

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/Query/MatchAll.php

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

0 commit comments

Comments
 (0)