Skip to content

Commit

Permalink
search/bleve: use a more generic interface for the typecheck
Browse files Browse the repository at this point in the history
We've been seeing non-ConjunctionQuery in Must so something is changing
that.
  • Loading branch information
Wessie committed Dec 21, 2024
1 parent 136d602 commit 707fbd1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions search/bleve/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,18 @@ func NewQuery(ctx context.Context, s string) (query.Query, error) {
return q, nil
}

cq, ok := bq.Must.(*query.ConjunctionQuery)
if !ok {
zerolog.Ctx(ctx).Warn().Str("type", fmt.Sprintf("%T", q)).Msg("query was not a ConjuctionQuery")
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...)
default:
zerolog.Ctx(ctx).Warn().Str("type", fmt.Sprintf("%T", q)).Msg("query is unknown type")
return q, nil
}
// move the disjuncts (OR) into the conjuncts (AND) query set
cq.AddQuery(dq.Disjuncts...)

// set the original should to nil
bq.Should = nil

Expand Down

0 comments on commit 707fbd1

Please sign in to comment.