summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/blevesearch/bleve/search/query/disjunction.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/blevesearch/bleve/search/query/disjunction.go')
-rw-r--r--vendor/github.com/blevesearch/bleve/search/query/disjunction.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/vendor/github.com/blevesearch/bleve/search/query/disjunction.go b/vendor/github.com/blevesearch/bleve/search/query/disjunction.go
index 08f47c4110..dacc3a75b1 100644
--- a/vendor/github.com/blevesearch/bleve/search/query/disjunction.go
+++ b/vendor/github.com/blevesearch/bleve/search/query/disjunction.go
@@ -25,9 +25,10 @@ import (
)
type DisjunctionQuery struct {
- Disjuncts []Query `json:"disjuncts"`
- BoostVal *Boost `json:"boost,omitempty"`
- Min float64 `json:"min"`
+ Disjuncts []Query `json:"disjuncts"`
+ BoostVal *Boost `json:"boost,omitempty"`
+ Min float64 `json:"min"`
+ queryStringMode bool
}
// NewDisjunctionQuery creates a new compound Query.
@@ -43,11 +44,10 @@ func (q *DisjunctionQuery) SetBoost(b float64) {
q.BoostVal = &boost
}
-func (q *DisjunctionQuery) Boost() float64{
+func (q *DisjunctionQuery) Boost() float64 {
return q.BoostVal.Value()
}
-
func (q *DisjunctionQuery) AddQuery(aq ...Query) {
for _, aaq := range aq {
q.Disjuncts = append(q.Disjuncts, aaq)
@@ -58,11 +58,10 @@ func (q *DisjunctionQuery) SetMin(m float64) {
q.Min = m
}
-func (q *DisjunctionQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, explain bool) (search.Searcher, error) {
- ss := make([]search.Searcher, len(q.Disjuncts))
- for in, disjunct := range q.Disjuncts {
- var err error
- ss[in], err = disjunct.Searcher(i, m, explain)
+func (q *DisjunctionQuery) Searcher(i index.IndexReader, m mapping.IndexMapping, options search.SearcherOptions) (search.Searcher, error) {
+ ss := make([]search.Searcher, 0, len(q.Disjuncts))
+ for _, disjunct := range q.Disjuncts {
+ sr, err := disjunct.Searcher(i, m, options)
if err != nil {
for _, searcher := range ss {
if searcher != nil {
@@ -71,8 +70,16 @@ func (q *DisjunctionQuery) Searcher(i index.IndexReader, m mapping.IndexMapping,
}
return nil, err
}
+ if _, ok := sr.(*searcher.MatchNoneSearcher); ok && q.queryStringMode {
+ // in query string mode, skip match none
+ continue
+ }
+ ss = append(ss, sr)
+ }
+ if len(ss) < 1 {
+ return searcher.NewMatchNoneSearcher(i)
}
- return searcher.NewDisjunctionSearcher(i, ss, q.Min, explain)
+ return searcher.NewDisjunctionSearcher(i, ss, q.Min, options)
}
func (q *DisjunctionQuery) Validate() error {