fix search

This commit is contained in:
YouROK
2023-02-06 21:09:00 +03:00
parent c88203f8b2
commit bbc0e3afca

View File

@@ -2,7 +2,6 @@ package torrsearch
import (
"server/rutor/models"
"strconv"
)
// Index is an inverted Index. It maps tokens to document IDs.
@@ -21,7 +20,7 @@ func Search(text string) []int {
func (idx Index) add(torrs []*models.TorrentDetails) {
for ID, torr := range torrs {
for _, token := range analyze(torr.Name + " " + torr.GetNames() + " " + strconv.Itoa(torr.Year)) {
for _, token := range analyze(torr.Title) {
ids := idx[token]
if ids != nil && ids[len(ids)-1] == ID {
// Don't add same ID twice.