Skip to content

Commit fe21750

Browse files
authored
Merge pull request #53 from vbcodeplicity/feature/match_all-should-use-curly-instead-of-square-brackets
match_all should use curly instead of square brackets
2 parents 6968658 + 710a3cb commit fe21750

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/Engine/Elasticsearch/ElasticsearchSelectionFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function sort()
7777
public function where()
7878
{
7979
if ($this->identity->isVoid()) {
80-
return $this->addConsistentRandomKey(['bool' => ['must' => ['match_all' => []]]]);
80+
return $this->addConsistentRandomKey(['bool' => ['must' => ['match_all' => new \stdClass()]]]);
8181
}
8282

8383
$comparisons = [];
@@ -103,7 +103,7 @@ public function where()
103103
}
104104

105105
if (empty($comparisons)) {
106-
$comparisons = ['must' => ['match_all' => []]];
106+
$comparisons = ['must' => ['match_all' => new \stdClass()]];
107107
}
108108

109109
$comparisons['filter'] = $geodistFormatter->format();

tests/unit/src/Engine/Elasticsearch/ElasticsearchSelectionFactoryTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@ public function testWhereIfIdentityIsVoid()
232232
->method('isVoid')
233233
->willReturn(true);
234234

235-
$this->assertEquals(['bool' => ['must' => ['match_all' => []]]], $this->selectionFactory->where());
235+
$result = $this->selectionFactory->where();
236+
237+
$this->assertEquals(['bool' => ['must' => ['match_all' => new \stdClass()]]], $result);
238+
$this->assertEquals('{"bool":{"must":{"match_all":{}}}}', json_encode($result));
236239
}
237240

238241
public function testGetGeodistParameters()
@@ -255,7 +258,7 @@ public function testGetGeodistParameters()
255258
$expectedArray = [
256259
'bool' => [
257260
'must' => [
258-
'match_all' => []
261+
'match_all' => new \stdClass()
259262
],
260263
'filter' => [
261264
'geo_distance' => [
@@ -269,7 +272,10 @@ public function testGetGeodistParameters()
269272
],
270273
];
271274

272-
$this->assertEquals($expectedArray, $this->selectionFactory->where());
275+
$result = $this->selectionFactory->where();
276+
277+
$this->assertEquals($expectedArray, $result);
278+
$this->assertEquals('{"bool":{"must":{"match_all":{}},"filter":{"geo_distance":{"distance":"100km","location":{"lon":10,"lat":15}}}}}', json_encode($result));
273279
}
274280

275281
public function testWhereWithRandom()

0 commit comments

Comments
 (0)