erengy / taiga

A lightweight anime tracker for Windows
https://taiga.moe
GNU General Public License v3.0
2.09k stars 224 forks source link

Algolia search for Kitsu #958

Open CeruleanSky opened 3 years ago

CeruleanSky commented 3 years ago

It seems that Kitsu.io is now promoting Algolia search api.

Kitsu uses Algolia for searching. Algolia's search provides more accurate search results and allows you to build complex search filters to find exactly what you want.

While not often, when searching with Taiga's current query string which uses the previous api, the exact match for a title could be buried hundreds of results deep into the list, especially when it has been recently added to kitsu's database. This often happens when trying to add anime for the upcoming season and prevents an anime from being added to Taiga as it only returns the first 20 results. A current work around is to go to kitsu.io itself and add it manually.

The documentation is still in progress but can be found here: https://hummingbird-me.github.io/api-docs/#tag/Algolia

Using browser developer tools and searching for something on the kitsu.io homepage is one way of seeing it work.

You can probably also ask the kitsu devs directly as well if you need any assistance, and on a side note one of them has given a thumbs up to this issue.

yutamago commented 3 years ago

Hey, it looks like the Algolia search api was already implemented (in a simplified way) in Taiga a long time ago. I just compared the API calls with the documentation and everything is matching (as far as I can see). Same goes for 1.3.1 (latest stable).

A few modifications were done afterwards, but we wont see them in a stable before 1.4.0 gets released.

CeruleanSky commented 3 years ago

I didn't see anything to indicate that algolia was being done, at least for search queries, other than some overlap in the names of the fields, maybe I overlooked it or you are on a private branch: current public develop branch kitsu.cpp

The current query in the latest develop branch, for example doesn't return METAMAN in the results, and in this case, troubling in that it only returns 15 hits so it should be in there:

https://kitsu.io/api/edge/anime?filter[text]=metaman&page[offset]=0&page[limit]=20&fields[anime]=abbreviatedTitles,ageRating,averageRating,canonicalTitle,endDate,episodeCount,episodeLength,popularityRank,posterImage,slug,startDate,status,subtype,titles,animeProductions,categories,synopsis&fields[animeProductions]=producer&fields[categories]=title&fields[producers]=name

Wayback Machine Preserved Results


Algolia query from their homepage gets it as its first hit:

https://kitsu.io/api/edge/algolia-keys https://awqo5j657s-1.algolianet.com/1/indexes/production_media/query?x-algolia-agent=Algolia for vanilla JavaScript (lite) 3.24.12&x-algolia-application-id=AWQO5J657S&x-algolia-api-key=..... POST GraphQL query:

   {   "params": "query=metaman&attributesToRetrieve=[" id "," slug "," kind "," canonicalTitle "," titles "," posterImage "," subtype "," posterImage "]&hitsPerPage=4&queryLanguages=[" en "," ja "]&naturalLanguages=[" en "," ja "]&attributesToHighlight=[]&responseFields=[" hits "," hitsPerPage "," nbHits "," nbPages "," offset "," page "]&removeStopWords=false&removeWordsIfNoResults=allOptional"}

Returned results:

{
    "hits": [{            "titles": {
                "en": "METAMAN",
                "en_cn": "Wang Gu Shenhua Zhi Tian Xuanzhe",
                "zh_cn": "望古神话之天选者"
            },
            "canonicalTitle": "METAMAN",
            "subtype": "ONA",
            "slug": "wang-gu-shenhua-zhi-tian-xuanzhe",
            ....
wopian commented 3 years ago

api/edge is our old JSON:API API and uses ElasticSearch (which we replaced with Algolia standalone and powers search in the new GraphQL API)

erengy commented 3 years ago

@wopian If Taiga switched to the new GraphQL API, would it still be necessary to call Algolia?

wopian commented 3 years ago

@wopian If Taiga switched to the new GraphQL API, would it still be necessary to call Algolia?

Nope. The search methods call Algolia for you.

erengy commented 3 years ago

I have a local branch for the GraphQL API now. It's going to be available as an option once the API covers everything Taiga needs.