-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: typesense missing scoutmetadata #868
base: 10.x
Are you sure you want to change the base?
Changes from all commits
7c4fd18
acb57e3
27191c8
e3283cb
8e70c54
558ff31
3841436
bddac47
bcbc773
c8a7bb8
5fd05e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -458,6 +458,19 @@ public function map(Builder $builder, $results, $model) | |
->filter(static function ($model) use ($objectIds) { | ||
return in_array($model->getScoutKey(), $objectIds, false); | ||
}) | ||
->map(static function ($model) use ($hits, $objectIdPositions) { | ||
$result = $hits[$objectIdPositions[$model->getScoutKey()]] ?? []; | ||
|
||
foreach ($result as $key => $value) { | ||
if ($key === 'document') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a test for this case specifically? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When using a join between 2 collections and including fields of a joined collection in your search response, you get those nested objects in the document (https://typesense.org/docs/27.1/api/joins.html#merging-nesting-joined-fields). If the 'document' key is also added to the scout metadata, then there is a way to access the fields of those joined collection objects. |
||
continue; | ||
} | ||
|
||
$model->withScoutMetadata($key, $value); | ||
} | ||
|
||
return $model; | ||
}) | ||
->sortBy(static function ($model) use ($objectIdPositions) { | ||
return $objectIdPositions[$model->getScoutKey()]; | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a test for the fallback of the empty array