From e7d483f676b2bbf920eb6c51269b5736c09047f3 Mon Sep 17 00:00:00 2001 From: Jeremy Sik Date: Mon, 16 May 2016 17:16:02 +1000 Subject: [PATCH] Fixing issue with translateQuery. (#59) * Fixing issue with translateQuery. * Applying style patch. * Updating tests. --- Controllers/EntityController.php | 2 +- tests/integration/EntityTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Controllers/EntityController.php b/Controllers/EntityController.php index 98a3ed8..0ff78b1 100644 --- a/Controllers/EntityController.php +++ b/Controllers/EntityController.php @@ -496,7 +496,7 @@ private function translateQuery($query) foreach ($value[$fieldKey] as $fieldValue) { if (! empty($fieldValue)) { - $snakeKey = snake_case(substr($key, 1)); + $snakeKey = snake_case($key); array_push($processedQuery['query']['bool']['must'], [ 'nested' => [ diff --git a/tests/integration/EntityTest.php b/tests/integration/EntityTest.php index caced15..e9fc89f 100644 --- a/tests/integration/EntityTest.php +++ b/tests/integration/EntityTest.php @@ -302,7 +302,7 @@ public function testGetAllPaginatedComplexSearch($path) ->with([ 'index' => 'defaultIndex', 'type' => 'someTypeName', - 'body' => ['query' => ['bool' => ['must' => [['match_phrase_prefix' => ['_all' => 'search term']], ['match_phrase_prefix' => ['author_id' => 'some UUID']], ['nested' => ['path' => 'tags', 'query' => ['bool' => ['must' => ['match_phrase_prefix' => ['tags.tag_id' => 'tag ID 1']]]]]], ['nested' => ['path' => 'tags', 'query' => ['bool' => ['must' => ['match_phrase_prefix' => ['tags.tag_id' => 'tag ID 2']]]]]]]]]], + 'body' => ['query' => ['bool' => ['must' => [['match_phrase_prefix' => ['_all' => 'search term']], ['match_phrase_prefix' => ['author_id' => 'some UUID']], ['nested' => ['path' => '_tags', 'query' => ['bool' => ['must' => ['match_phrase_prefix' => ['_tags.tag_id' => 'tag ID 1']]]]]], ['nested' => ['path' => '_tags', 'query' => ['bool' => ['must' => ['match_phrase_prefix' => ['_tags.tag_id' => 'tag ID 2']]]]]]]]]], ]) ->andReturn($resultsMock);