Add support for highlighting results
This commit is contained in:
1
go.mod
1
go.mod
@@ -39,6 +39,7 @@ require (
|
|||||||
github.com/prologic/bitcask v0.3.10
|
github.com/prologic/bitcask v0.3.10
|
||||||
github.com/prologic/observe v0.0.0-20181231082615-747b185a0928
|
github.com/prologic/observe v0.0.0-20181231082615-747b185a0928
|
||||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be // indirect
|
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be // indirect
|
||||||
|
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563
|
||||||
github.com/renstrom/shortuuid v2.0.3+incompatible
|
github.com/renstrom/shortuuid v2.0.3+incompatible
|
||||||
github.com/robfig/cron v1.2.0
|
github.com/robfig/cron v1.2.0
|
||||||
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
|
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
|
||||||
|
|||||||
1
go.sum
1
go.sum
@@ -377,6 +377,7 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z
|
|||||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be h1:ta7tUOvsPHVHGom5hKW5VXNc2xZIkfCKP8iaqOyYtUQ=
|
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be h1:ta7tUOvsPHVHGom5hKW5VXNc2xZIkfCKP8iaqOyYtUQ=
|
||||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be/go.mod h1:MIDFMn7db1kT65GmV94GzpX9Qdi7N/pQlwb+AN8wh+Q=
|
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be/go.mod h1:MIDFMn7db1kT65GmV94GzpX9Qdi7N/pQlwb+AN8wh+Q=
|
||||||
|
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563 h1:dY6ETXrvDG7Sa4vE8ZQG4yqWg6UnOcbqTAahkV813vQ=
|
||||||
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||||
github.com/renstrom/shortuuid v1.0.0 h1:RBZExpswQ58bdD70uCmUPhPfXNmICC+ir7IY4WNiCQ0=
|
github.com/renstrom/shortuuid v1.0.0 h1:RBZExpswQ58bdD70uCmUPhPfXNmICC+ir7IY4WNiCQ0=
|
||||||
|
|||||||
@@ -212,13 +212,13 @@ func (s *Server) SearchHandler() httprouter.Handle {
|
|||||||
|
|
||||||
var results []Result
|
var results []Result
|
||||||
|
|
||||||
for _, searchResult := range searchResults.Hits {
|
for _, hit := range searchResults.Hits {
|
||||||
result := Result{
|
result := Result{
|
||||||
ID: searchResult.ID,
|
ID: hit.ID,
|
||||||
Title: searchResult.Fields["Title"].(string),
|
Title: hit.Fields["Title"].(string),
|
||||||
Summary: searchResult.Fields["Summary"].(string),
|
Summary: template.HTML(strings.Join(hit.Fragments["Summary"], "")),
|
||||||
URL: searchResult.Fields["URL"].(string),
|
URL: hit.Fields["URL"].(string),
|
||||||
Length: int(searchResult.Fields["Length"].(float64)),
|
Length: int(hit.Fields["Length"].(float64)),
|
||||||
}
|
}
|
||||||
results = append(results, result)
|
results = append(results, result)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package internal
|
package internal
|
||||||
|
|
||||||
|
import "html/template"
|
||||||
|
|
||||||
type Result struct {
|
type Result struct {
|
||||||
ID string
|
ID string
|
||||||
URL string
|
URL string
|
||||||
Title string
|
Title string
|
||||||
Summary string
|
Summary template.HTML
|
||||||
Length int
|
Length int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user