meilisearch return search_box_id

This commit is contained in:
xiaomlove
2023-04-07 02:19:28 +08:00
parent 3dff8e457d
commit fe49b6a2ba
3 changed files with 25 additions and 4 deletions

View File

@@ -267,13 +267,21 @@ class MeiliSearchRepository extends BaseRepository
$torrentIdArr = array_column($searchResult->getHits(), 'id');
$fields = Torrent::getFieldsForList();
$idStr = implode(',', $torrentIdArr);
$results['list'] = Torrent::query()
$torrents = Torrent::query()
->select($fields)
->with('basic_category')
->whereIn('id', $torrentIdArr)
->orderByRaw("field(id,$idStr)")
->get()
->toArray()
;
$list = [];
foreach ($torrents as $torrent) {
$searchBoxId = $torrent->basic_category->mode;
$arr = $torrent->toArray();
$arr['search_box_id'] = $searchBoxId;
$list[] = $arr;
}
$results['list'] = $list;
}
return $results;
}