all repos — searchix @ 6c9a3a93f0c55f65539230c4c979816df8e77c1b

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: prioritise exact matches on programs/attr/name field
Alan Pearce alan@alanpearce.eu
Thu, 06 Mar 2025 21:57:01 +0100
commit

6c9a3a93f0c55f65539230c4c979816df8e77c1b

parent

24e3fc96ce2c96401155b86c6bfb6a6fb2e322f8

1 files changed, 3 insertions(+), 0 deletions(-)

jump to
M internal/index/search.gointernal/index/search.go
@@ -161,14 +161,17 @@ } 
 	programsQuery := bleve.NewMatchQuery(keyword)
 	programsQuery.SetField("Programs")
+	programsQuery.SetBoost(2)
 	query.AddShould(programsQuery)
 
 	attrQuery := bleve.NewMatchQuery(keyword)
 	attrQuery.SetField("Attribute")
+	attrQuery.SetBoost(2)
 	query.AddShould(attrQuery)
 
 	nameLiteralQuery := bleve.NewMatchQuery(keyword)
 	nameLiteralQuery.SetField("Name")
+	nameLiteralQuery.SetBoost(2)
 	query.AddShould(nameLiteralQuery)
 
 	search := bleve.NewSearchRequest(query)