Skip to content

Commit

Permalink
search/bleve: account for nil in the type switch
Browse files Browse the repository at this point in the history
  • Loading branch information
Wessie committed Dec 21, 2024
1 parent 5a430b9 commit ee19b59
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions search/bleve/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ee19b59

Please sign in to comment.