Skip to content

Commit 5384563

Browse files
authored
Merge pull request #23 from justasmalinauskas/boolsupport
Add boolean and integer support to MatchQuery and AbstractMatchQuery
2 parents b738310 + 4632a4e commit 5384563

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

src/Query/AbstractMatchQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ abstract class AbstractMatchQuery implements QueryInterface
1111

1212
public function __construct(
1313
string $field,
14-
protected string $query,
14+
protected string|bool|int $query,
1515
protected ?string $analyzer = null,
1616
protected array $params = [],
1717
) {

src/Query/MatchQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class MatchQuery extends AbstractMatchQuery
1414

1515
public function __construct(
1616
string $field,
17-
string $query,
17+
string|bool|int $query,
1818
?string $analyzer = null,
1919
?string $operator = null,
2020
?string $minimumShouldMatch = null,

tests/Query/MatchQueryTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,30 @@ public function testItBuildTheQueryWithAnAnalyzer(): void
3838
],
3939
], $query->build());
4040
}
41+
42+
public function testItBuildTheQueryWithBoolean(): void
43+
{
44+
$query = new MatchQuery('is_closed', true);
45+
$this->assertSame([
46+
'match' => [
47+
'is_closed' => [
48+
'query' => true
49+
],
50+
],
51+
], $query->build());
52+
}
53+
54+
55+
public function testItBuildTheQueryWithInteger(): void
56+
{
57+
$query = new MatchQuery('count', 1);
58+
59+
$this->assertSame([
60+
'match' => [
61+
'count' => [
62+
'query' => 1
63+
],
64+
],
65+
], $query->build());
66+
}
4167
}

0 commit comments

Comments
 (0)