···2323 Or or = 15;
2424 Not not = 16;
2525 Branch branch = 17;
2626+ Boost boost = 18;
2627 }
2728}
2829···141142 // exact is true if we want to Pattern to equal branch.
142143 bool exact = 2;
143144}
145145+146146+// Boost multiplies the score of its child by the boost factor.
147147+message Boost {
148148+ Q child = 1;
149149+ double boost = 2;
150150+}
+23
query/query_proto.go
···6677 "github.com/RoaringBitmap/roaring"
88 "github.com/grafana/regexp"
99+910 proto "github.com/sourcegraph/zoekt/grpc/protos/zoekt/webserver/v1"
1011)
1112···4546 return &proto.Q{Query: &proto.Q_Not{Not: v.ToProto()}}
4647 case *Branch:
4748 return &proto.Q{Query: &proto.Q_Branch{Branch: v.ToProto()}}
4949+ case *Boost:
5050+ return &proto.Q{Query: &proto.Q_Boost{Boost: v.ToProto()}}
4851 default:
4952 // The following nodes do not have a proto representation:
5053 // - GobCache: only needed for Gob encoding
···8992 return NotFromProto(v.Not)
9093 case *proto.Q_Branch:
9194 return BranchFromProto(v.Branch), nil
9595+ case *proto.Q_Boost:
9696+ return BoostFromProto(v.Boost)
9297 default:
9398 panic(fmt.Sprintf("unknown query node %T", p.Query))
9499 }
···357362 }
358363 return &proto.Or{
359364 Children: children,
365365+ }
366366+}
367367+368368+func BoostFromProto(p *proto.Boost) (*Boost, error) {
369369+ child, err := QFromProto(p.GetChild())
370370+ if err != nil {
371371+ return nil, err
372372+ }
373373+ return &Boost{
374374+ Child: child,
375375+ Boost: p.GetBoost(),
376376+ }, nil
377377+}
378378+379379+func (q *Boost) ToProto() *proto.Boost {
380380+ return &proto.Boost{
381381+ Child: QToProto(q.Child),
382382+ Boost: q.Boost,
360383 }
361384}
362385