Ejemplo n.º 1
0
func (q *booleanQuery) Searcher(i index.IndexReader, m *IndexMapping, explain bool) (search.Searcher, error) {
	var err error
	var mustNotSearcher search.Searcher
	if q.MustNot != nil {
		mustNotSearcher, err = q.MustNot.Searcher(i, m, explain)
		if err != nil {
			return nil, err
		}
		if q.Must == nil && q.Should == nil {
			q.Must = NewMatchAllQuery()
		}
	}

	var mustSearcher search.Searcher
	if q.Must != nil {
		mustSearcher, err = q.Must.Searcher(i, m, explain)
		if err != nil {
			return nil, err
		}
	}

	var shouldSearcher search.Searcher
	if q.Should != nil {
		shouldSearcher, err = q.Should.Searcher(i, m, explain)
		if err != nil {
			return nil, err
		}
	}

	if mustSearcher == nil && shouldSearcher != nil && mustNotSearcher == nil {
		return shouldSearcher, nil
	}

	return searchers.NewBooleanSearcher(i, mustSearcher, shouldSearcher, mustNotSearcher, explain)
}
Ejemplo n.º 2
0
func (q *booleanQuery) Searcher(i *indexImpl, explain bool) (search.Searcher, error) {
	var err error

	var mustSearcher search.Searcher
	if q.Must != nil {
		mustSearcher, err = q.Must.Searcher(i, explain)
		if err != nil {
			return nil, err
		}
	}

	var shouldSearcher search.Searcher
	if q.Should != nil {
		shouldSearcher, err = q.Should.Searcher(i, explain)
		if err != nil {
			return nil, err
		}
	}

	var mustNotSearcher search.Searcher
	if q.MustNot != nil {
		mustNotSearcher, err = q.MustNot.Searcher(i, explain)
		if err != nil {
			return nil, err
		}
	}

	return searchers.NewBooleanSearcher(i.i, mustSearcher, shouldSearcher, mustNotSearcher, explain)
}