Indexing everything
This commit is contained in:
+17
-4
@@ -8,9 +8,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Search interface {
|
type Search interface {
|
||||||
|
ClearAll() error
|
||||||
IndexArtist(ar *domain.Artist) error
|
IndexArtist(ar *domain.Artist) error
|
||||||
//IndexAlbum(al domain.Album) error
|
IndexAlbum(al *domain.Album) error
|
||||||
//IndexMediaFile(mf domain.MediaFile) error
|
IndexMediaFile(mf *domain.MediaFile) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type search struct {
|
type search struct {
|
||||||
@@ -24,6 +25,18 @@ func NewSearch(ar domain.ArtistRepository, alr domain.AlbumRepository, mr domain
|
|||||||
return search{ar, alr, mr, idx}
|
return search{ar, alr, mr, idx}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s search) IndexArtist(ar *domain.Artist) error {
|
func (s search) ClearAll() error {
|
||||||
return s.indexer.Index(ar.Id, strings.ToLower(ar.Name))
|
return s.indexer.Clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s search) IndexArtist(ar *domain.Artist) error {
|
||||||
|
return s.indexer.Index("ar-"+ar.Id, strings.ToLower(ar.Name))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s search) IndexAlbum(al *domain.Album) error {
|
||||||
|
return s.indexer.Index("al-"+al.Id, strings.ToLower(al.Name))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s search) IndexMediaFile(mf *domain.MediaFile) error {
|
||||||
|
return s.indexer.Index("mf-"+mf.Id, strings.ToLower(mf.Title))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ func (i *Importer) importLibrary() (err error) {
|
|||||||
ars := make(domain.Artists, len(i.scanner.Artists()))
|
ars := make(domain.Artists, len(i.scanner.Artists()))
|
||||||
pls := make(domain.Playlists, len(i.scanner.Playlists()))
|
pls := make(domain.Playlists, len(i.scanner.Playlists()))
|
||||||
|
|
||||||
|
i.search.ClearAll()
|
||||||
|
|
||||||
beego.Debug("Saving updated data")
|
beego.Debug("Saving updated data")
|
||||||
j := 0
|
j := 0
|
||||||
for _, mf := range i.scanner.MediaFiles() {
|
for _, mf := range i.scanner.MediaFiles() {
|
||||||
@@ -103,6 +105,9 @@ func (i *Importer) importLibrary() (err error) {
|
|||||||
if err := i.mfRepo.Put(mf); err != nil {
|
if err := i.mfRepo.Put(mf); err != nil {
|
||||||
beego.Error(err)
|
beego.Error(err)
|
||||||
}
|
}
|
||||||
|
if err := i.search.IndexMediaFile(mf); err != nil {
|
||||||
|
beego.Error("Error indexing artist:", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
j = 0
|
j = 0
|
||||||
@@ -115,6 +120,9 @@ func (i *Importer) importLibrary() (err error) {
|
|||||||
if err := i.albumRepo.Put(al); err != nil {
|
if err := i.albumRepo.Put(al); err != nil {
|
||||||
beego.Error(err)
|
beego.Error(err)
|
||||||
}
|
}
|
||||||
|
if err := i.search.IndexAlbum(al); err != nil {
|
||||||
|
beego.Error("Error indexing artist:", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
j = 0
|
j = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user