diff options
| author | alex <[email protected]> | 2026-07-28 00:30:55 +0200 |
|---|---|---|
| committer | alex <[email protected]> | 2026-07-28 00:30:55 +0200 |
| commit | e973c9724829d962ff9e233ef16f489296f9fe3d (patch) | |
| tree | 324df28e63c5f550bfb2c4f84daa99b554c72eb5 /search | |
| parent | 3038483c570af7b923dda39e857b9cab8f89e5dd (diff) | |
| download | search-engine-e973c9724829d962ff9e233ef16f489296f9fe3d.tar.xz search-engine-e973c9724829d962ff9e233ef16f489296f9fe3d.zip | |
added Posting type to the reverse index struct which will be later used for scoring results
Diffstat (limited to 'search')
| -rw-r--r-- | search/search.go | 10 |
1 files changed, 5 insertions, 5 deletions
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) } } |
