Skip to content

Commit 2780556

Browse files
authored
Merge pull request #141 from apisearch-io/feature/fixed-path-by-field
Added _id in path_by_field method
2 parents 7020a36 + 24c6d4d commit 2780556

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

.circleci/config.yml

+15-1
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,25 @@ jobs:
5454
composer update -n --prefer-dist
5555
php vendor/bin/phpunit
5656
57+
php81:
58+
docker:
59+
- image: cimg/php:8.1
60+
61+
working_directory: ~/project
62+
steps:
63+
- checkout
64+
- run:
65+
name: Run tests
66+
command: |
67+
composer update -n --prefer-dist
68+
php vendor/bin/phpunit
69+
5770
workflows:
5871
version: 2
5972
test:
6073
jobs:
6174
- php72
6275
- php73
6376
- php74
64-
- php80
77+
- php80
78+
- php81

Model/Item.php

+4
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,10 @@ public static function createFromArray(array $array): self
671671
*/
672672
public static function getPathByField(string $field)
673673
{
674+
if ('_id' === $field) {
675+
return $field;
676+
}
677+
674678
return in_array($field, ['id', 'type'])
675679
? 'uuid.'.$field
676680
: 'indexed_metadata.'.$field;

Tests/Model/ItemTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -525,4 +525,16 @@ public function testMap()
525525
$this->assertEquals(10, $item->getScore());
526526
$this->assertNull($item->getCoordinate());
527527
}
528+
529+
/**
530+
* @return void
531+
*/
532+
public function testPathByField()
533+
{
534+
$this->assertEquals('_id', Item::getPathByField('_id'));
535+
$this->assertEquals('uuid.id', Item::getPathByField('id'));
536+
$this->assertEquals('uuid.type', Item::getPathByField('type'));
537+
$this->assertEquals('indexed_metadata.another_id', Item::getPathByField('another_id'));
538+
$this->assertEquals('indexed_metadata._field', Item::getPathByField('_field'));
539+
}
528540
}

0 commit comments

Comments
 (0)