Use the correct analyser for searches
This commit is contained in:
parent
e5a65cf5cf
commit
ade0b748e9
@ -14,6 +14,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/blevesearch/bleve/v2"
|
"github.com/blevesearch/bleve/v2"
|
||||||
|
"github.com/blevesearch/bleve/v2/analysis/lang/en"
|
||||||
"github.com/blevesearch/bleve/v2/search/query"
|
"github.com/blevesearch/bleve/v2/search/query"
|
||||||
"github.com/tardisx/linkwallet/content"
|
"github.com/tardisx/linkwallet/content"
|
||||||
"github.com/tardisx/linkwallet/entity"
|
"github.com/tardisx/linkwallet/entity"
|
||||||
@ -124,11 +125,11 @@ func (m *BookmarkManager) Search(opts SearchOptions) ([]entity.BookmarkSearchRes
|
|||||||
if opts.All {
|
if opts.All {
|
||||||
q = bleve.NewMatchAllQuery()
|
q = bleve.NewMatchAllQuery()
|
||||||
} else {
|
} else {
|
||||||
|
mq := bleve.NewMatchQuery(opts.Query)
|
||||||
|
mq.Analyzer = en.AnalyzerName
|
||||||
|
tq := bleve.NewTermQuery(opts.Query)
|
||||||
|
|
||||||
q = bleve.NewDisjunctionQuery(
|
q = bleve.NewDisjunctionQuery(mq, tq)
|
||||||
bleve.NewMatchQuery(opts.Query),
|
|
||||||
bleve.NewTermQuery(opts.Query),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
req := bleve.NewSearchRequest(q)
|
req := bleve.NewSearchRequest(q)
|
||||||
@ -188,7 +189,6 @@ func (m *BookmarkManager) UpdateIndexForBookmark(bm *entity.Bookmark) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
log.Printf("done bleving")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *BookmarkManager) QueueScrape(bm *entity.Bookmark) {
|
func (m *BookmarkManager) QueueScrape(bm *entity.Bookmark) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user