fixed indexing issue with typesense

- all models have a "title" field, and that's the default sorting field, however this is not being indexed as such for the models, except where explicitly specified (Anime and Manga models)
This commit is contained in:
pushrbx 2024-01-31 18:33:32 +00:00
parent 289bdfb368
commit 8d4a595b75

View File

@ -21,12 +21,20 @@ abstract class JikanApiSearchableModel extends JikanApiModel implements Typesens
*/ */
public function getCollectionSchema(): array public function getCollectionSchema(): array
{ {
$titleAttributeName = $this->getTitleAttributeName();
return [ return [
'name' => $this->searchableAs(), 'name' => $this->searchableAs(),
'fields' => [ 'fields' => [
[ [
'name' => '.*', 'name' => '.*',
'type' => 'auto', 'type' => 'auto',
],
[
'name' => $titleAttributeName,
'type' => 'string',
'sort' => true,
'optional' => false
] ]
] ]
]; ];