From e973c9724829d962ff9e233ef16f489296f9fe3d Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 28 Jul 2026 00:30:55 +0200 Subject: added Posting type to the reverse index struct which will be later used for scoring results --- search/search.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'search/search.go') diff --git a/search/search.go b/search/search.go index ced94b7..f0b1cce 100644 --- a/search/search.go +++ b/search/search.go @@ -21,7 +21,7 @@ func Search(idx *index.InvertedIndex, query string) []string { return nil } - intersection := make([]int, len(baseIDs)) + intersection := make([]index.Posting, len(baseIDs)) copy(intersection, baseIDs) for i := 1; i < len(tokenizedQuery); i++ { @@ -34,12 +34,12 @@ func Search(idx *index.InvertedIndex, query string) []string { lookup := make(map[int]struct{}) for _, id := range nextIDs { - lookup[id] = struct{}{} + lookup[id.DocId] = struct{}{} } - var filtered []int + var filtered []index.Posting for _, id := range intersection { - if _, found := lookup[id]; found { + if _, found := lookup[id.DocId]; found { filtered = append(filtered, id) } } @@ -49,7 +49,7 @@ func Search(idx *index.InvertedIndex, query string) []string { } var results []string for _, id := range intersection { - if title, exists := idx.DocNames[id]; exists { + if title, exists := idx.DocNames[id.DocId]; exists { results = append(results, title) } } -- cgit v1.2.3