feat: demote NUR results in combined search
Alan Pearce alan@alanpearce.eu
Thu, 20 Mar 2025 20:00:59 +0100
1 files changed, 10 insertions(+), 3 deletions(-)
jump to
M internal/index/search.go → internal/index/search.go
@@ -66,6 +66,12 @@ return q } +func setBoost[T query.BoostableQuery](q T, boost float64) T { + q.SetBoost(boost) + + return q +} + func (index *ReadIndex) search( ctx context.Context, request *bleve.SearchRequest, @@ -125,9 +131,10 @@ query.AddMust( setField(bleve.NewTermQuery(source.Key), "Source"), ) } else { - q := bleve.NewTermQuery("nixpkgs") - q.SetField("Source") - q.SetBoost(-150) + q := bleve.NewDisjunctionQuery( + setBoost(setField(bleve.NewTermQuery("nixpkgs"), "Source"), -150), + setBoost(setField(bleve.NewTermQuery("nur"), "Source"), -200), + ) query.AddShould(q) }