From ee19b596a8ec8d5b529637c4fd83d3c5410f61cf Mon Sep 17 00:00:00 2001 From: Wessie Date: Sat, 21 Dec 2024 01:30:39 +0100 Subject: [PATCH] search/bleve: account for nil in the type switch --- search/bleve/main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/search/bleve/main.go b/search/bleve/main.go index 44a53080..aac10042 100644 --- a/search/bleve/main.go +++ b/search/bleve/main.go @@ -329,13 +329,14 @@ func NewQuery(ctx context.Context, s string) (query.Query, error) { return q, nil } + // move the should (OR) into the must (AND) query set if possible switch qq := bq.Must.(type) { case *query.ConjunctionQuery: - // move the should (OR) into the must (AND) query set qq.AddQuery(dq.Disjuncts...) case *query.BooleanQuery: - // move the should (OR) into the must (AND) query set qq.AddMust(dq.Disjuncts...) + case nil: + bq.Must = bleve.NewConjunctionQuery(dq.Disjuncts...) default: zerolog.Ctx(ctx).Warn().Str("type", fmt.Sprintf("%T", bq.Must)).Msg("query is unknown type") return q, nil