Closed diamondver closed 2 months ago
This is caused by an extra logic we added to improve search results for anime/manga. So if the query's length is shorter than 4, we do "infix" search, we disable typo tolerance, we prioritise token position, and we disable the search for various variations of the search term (exhaustive search). However this doesn't work in case of Producers, because the logic falls back to the field of the model which contains the titles, which in this case is not marked as "sortable" in the search index. (What a mouthful!)
Ref: https://github.com/jikan-me/jikan-rest/blob/master/app/Services/TypeSenseScoutSearchService.php#L84
Not sure about the best fix yet tho.
I tried this API https://api.jikan.moe/v4/producers?q=pier
, and It seems to work fine. For a while, I will force my users to type more than 4 characters to get the result. Thanks.
Locally I couldn't reproduce this issue, then I've found that the search index wasn't updated for the public api since last time we fixed some issues with the Producer model. I've fixed the search index and this should be working now.
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 `titles` 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/producers?q=a
Environment
No response
Anything else?
If it's an empty string (e.g. https://api.jikan.moe/v4/producers?q=), it doesn't return an error.