added base path filter
This commit is contained in:
parent
98b53d3a33
commit
ec5a376733
15 changed files with 104 additions and 44 deletions
|
|
@ -80,7 +80,7 @@ func (i *Index) Delete(id string) error {
|
|||
return i.i.Delete(id)
|
||||
}
|
||||
|
||||
func (i *Index) Search(search string) (results []core.Result, err error) {
|
||||
func (i *Index) Search(search string) (results core.Results, err error) {
|
||||
req := bleve.NewSearchRequest(bleve.NewQueryStringQuery(search))
|
||||
req.Highlight = bleve.NewHighlightWithStyle("html")
|
||||
req.Size = maxSearchResult
|
||||
|
|
@ -98,18 +98,17 @@ func (i *Index) Search(search string) (results []core.Result, err error) {
|
|||
continue
|
||||
}
|
||||
for fragField, frags := range hit.Fragments {
|
||||
if fragField == "text" || fragField == "created" {
|
||||
for _, f := range frags {
|
||||
r.HTML += template.HTML(f)
|
||||
}
|
||||
break
|
||||
}
|
||||
if fragField == "keyword" {
|
||||
var k string
|
||||
for _, f := range frags {
|
||||
k += f
|
||||
}
|
||||
r.Keyword = strings.ReplaceAll(strings.ReplaceAll(k, "<mark>", ""), "</mark>", "")
|
||||
}
|
||||
if fragField == "text" || fragField == "created" {
|
||||
for _, f := range frags {
|
||||
r.HTML += template.HTML(f)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue