jikan-me / jikan-rest

The REST API for Jikan
https://docs.api.jikan.moe/
MIT License
413 stars 268 forks source link

🐛 In the public API's server the `characters` collection in typesense has the wrong schema #488

Closed AinsAlmeyn closed 5 months ago

AinsAlmeyn commented 5 months ago

Is there an existing issue for this?

Current Behavior

The API has returned an error: Typesense\Exceptions\ObjectNotFound Status code: 0 Message: Could not find a field named `name` in the schema for sorting. Trace: /var/www/jikan-rest/vendor/typesense/typesense-php/src/ApiCall.php on line 348

Expected Behavior

The API should have returned a successful response with data.

Steps To Reproduce

Http Request: `GET /v4/characters?q=momonga&order_by=name&sort=desc

Environment

No response

Anything else?

No response

itsTKRaz commented 5 months ago

I had this issue before. To resolve it, you would basically have to wipe your Jikan Database and begin indexing entirely from the beginning with Typesense enabled from the beginning.

To index you run in the server console: php artisan indexer:anime and let it run. Will take a day and a half. After that's done, run: php artisan scout:import "App\Anime"

You need to let the indexer run in it's entirely from the start with Typesense enabled before doing anything. You won't get certain characters and anime to query until the indexer is completed using the commands noted above.

pushrbx commented 5 months ago

@itsTKRaz Thanks for sharing. This is happening on the public api, it's not a self hosted issue. If you self host the issue creation link under error messages have different parameters which will set a different title for the issue.

@irfan-dahir You need to flush the "characters" collection in typesense, and load everything again. :monkey:

irfan-dahir commented 5 months ago

@pushrbx I've run

php artisan scout:flush "App\Character"
php artisan scout:import "App\Character"

However the issue persists. Please advise 😄

pushrbx commented 5 months ago

@pushrbx I've run

php artisan scout:flush "App\Character"
php artisan scout:import "App\Character"

However the issue persists. Please advise 😄

I'll message you on discord

pushrbx commented 5 months ago

I've found the issue: the Character model (and others too) should explicitly set the fields with sort index for typesense.