Search charaters

This commit is contained in:
2025-12-06 16:15:38 +08:00
parent fb1f47c0c0
commit fbe8ac27bf

View File

@@ -13,20 +13,36 @@ import (
) )
type ResourceParams struct { type ResourceParams struct {
Id uint Id uint
Title string Title string
Subtitles []string Subtitles []string
Time time.Time Time time.Time
Characters []ResourceCharacter
}
type ResourceCharacter struct {
Name string
Alias []string
CV string
} }
var index bleve.Index var index bleve.Index
func AddResourceToIndex(r model.Resource) error { func AddResourceToIndex(r model.Resource) error {
cs := make([]ResourceCharacter, 0, len(r.Characters))
for _, c := range r.Characters {
cs = append(cs, ResourceCharacter{
Name: c.Name,
Alias: c.Alias,
CV: c.CV,
})
}
return index.Index(fmt.Sprintf("%d", r.ID), ResourceParams{ return index.Index(fmt.Sprintf("%d", r.ID), ResourceParams{
Id: r.ID, Id: r.ID,
Title: r.Title, Title: r.Title,
Subtitles: r.AlternativeTitles, Subtitles: r.AlternativeTitles,
Time: r.CreatedAt, Time: r.CreatedAt,
Characters: cs,
}) })
} }