Improved search

This commit is contained in:
Eduard Urbach 2017-07-04 14:34:58 +02:00
parent 780c2e1c56
commit 81d58bfd8e

View File

@ -28,22 +28,23 @@ func updateAnimeIndex() {
} }
for anime := range animeStream { for anime := range animeStream {
if anime.Title.Canonical != "" {
animeSearchIndex.TextToID[strings.ToLower(anime.Title.Canonical)] = anime.ID
}
if anime.Title.Romaji != "" { if anime.Title.Romaji != "" {
animeSearchIndex.TextToID[strings.ToLower(anime.Title.Romaji)] = anime.ID animeSearchIndex.TextToID[strings.ToLower(anime.Title.Romaji)] = anime.ID
} }
if anime.Title.English != "" { // Make sure we only include Japanese titles that
animeSearchIndex.TextToID[strings.ToLower(anime.Title.English)] = anime.ID // don't overlap with the English titles.
} if anime.Title.Japanese != "" && animeSearchIndex.TextToID[strings.ToLower(anime.Title.Japanese)] == "" {
// Make sure we only include Japanese titles that actually contain unicode letters
// because otherwise they might overlap with the English titles.
if anime.Title.Japanese != "" && arn.ContainsUnicodeLetters(anime.Title.Japanese) {
animeSearchIndex.TextToID[strings.ToLower(anime.Title.Japanese)] = anime.ID animeSearchIndex.TextToID[strings.ToLower(anime.Title.Japanese)] = anime.ID
} }
if anime.Title.Canonical != "" { // Same with English titles, don't overwrite other stuff.
animeSearchIndex.TextToID[strings.ToLower(anime.Title.Canonical)] = anime.ID if anime.Title.English != "" && animeSearchIndex.TextToID[strings.ToLower(anime.Title.English)] == "" {
animeSearchIndex.TextToID[strings.ToLower(anime.Title.English)] = anime.ID
} }
for _, synonym := range anime.Title.Synonyms { for _, synonym := range anime.Title.Synonyms {