Skip to content

Commit

Permalink
Fix scout key not matched (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
zingimmick authored Aug 11, 2021
1 parent 47eacc8 commit 2f216c5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitInternalClassFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestClassRequiresCoversFixer;
use PhpCsFixer\Fixer\Strict\StrictParamFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Zing\CodingStandard\Set\ECSSetList;
Expand All @@ -21,6 +22,7 @@
PhpUnitInternalClassFixer::class,
PhpUnitTestClassRequiresCoversFixer::class,
NoSuperfluousPhpdocTagsFixer::class,
StrictParamFixer::class => [__DIR__ . '/src/Engines/OpenSearchEngine.php'],
]);
$parameters->set(
Option::PATHS,
Expand Down
4 changes: 2 additions & 2 deletions src/Engines/OpenSearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public function map(Builder $builder, $results, $model)

return $model->getScoutModelsByIds($builder, $objectIds)
->filter(function ($model) use ($objectIds) {
return in_array($model->getScoutKey(), $objectIds, true);
return in_array($model->getScoutKey(), $objectIds);
})->sortBy(function ($model) use ($objectIdPositions) {
return $objectIdPositions[$model->getScoutKey()];
})->values();
Expand Down Expand Up @@ -249,7 +249,7 @@ public function lazyMap(Builder $builder, $results, $model)
return $model->queryScoutModelsByIds($builder, $objectIds)
->cursor()
->filter(function ($model) use ($objectIds) {
return in_array($model->getScoutKey(), $objectIds, true);
return in_array($model->getScoutKey(), $objectIds);
})->sortBy(function ($model) use ($objectIdPositions) {
return $objectIdPositions[$model->getScoutKey()];
})->values();
Expand Down
2 changes: 1 addition & 1 deletion tests/OpenSearchEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public function testSeachable(): void
"items": [
{
"fields": {
"id": {$model->getKey()},
"id": "{$model->getKey()}",
"name": "我是一条新<em>文档</em>的标题",
"phone": "18312345678",
"index_name": "app_schema_demo"
Expand Down

0 comments on commit 2f216c5

Please sign in to comment.