It works (but it sucks0
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
"git.mills.io/prologic/spyda"
|
||||
"git.mills.io/prologic/spyda/internal/session"
|
||||
"git.mills.io/prologic/spyda/types"
|
||||
)
|
||||
|
||||
type Meta struct {
|
||||
@@ -52,7 +51,7 @@ type Context struct {
|
||||
Title string
|
||||
Meta Meta
|
||||
|
||||
Results types.Results
|
||||
Results Results
|
||||
Pager *paginator.Paginator
|
||||
|
||||
// Report abuse
|
||||
|
||||
@@ -151,7 +151,7 @@ func (s *Server) SearchHandler() httprouter.Handle {
|
||||
return
|
||||
}
|
||||
|
||||
results, err := s.indexer.Search(q)
|
||||
searchResults, err := s.indexer.Search(q)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("error performing search")
|
||||
ctx.Error = true
|
||||
@@ -160,7 +160,22 @@ func (s *Server) SearchHandler() httprouter.Handle {
|
||||
return
|
||||
}
|
||||
|
||||
log.Debug(results)
|
||||
log.Debug(searchResults)
|
||||
|
||||
var results []Result
|
||||
|
||||
for _, searchResult := range searchResults.Hits {
|
||||
result := Result{
|
||||
ID: searchResult.ID,
|
||||
Title: searchResult.Fields["Title"].(string),
|
||||
Summary: searchResult.Fields["Summary"].(string),
|
||||
URL: searchResult.Fields["URL"].(string),
|
||||
Length: int(searchResult.Fields["Length"].(float64)),
|
||||
}
|
||||
results = append(results, result)
|
||||
}
|
||||
|
||||
ctx.Results = results
|
||||
|
||||
s.render("search", w, ctx)
|
||||
}
|
||||
|
||||
11
internal/results.go
Normal file
11
internal/results.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package internal
|
||||
|
||||
type Result struct {
|
||||
ID string
|
||||
URL string
|
||||
Title string
|
||||
Summary string
|
||||
Length int
|
||||
}
|
||||
|
||||
type Results []Result
|
||||
Reference in New Issue
Block a user