From 6d6fae289509c9deb27710e6f28d56b1ae587c06 Mon Sep 17 00:00:00 2001 From: Steve Yen Date: Tue, 20 Sep 2016 23:08:42 -0700 Subject: [PATCH] optimize when disjunction query has only a single child On my dev laptop, the bleve-query benchmark of query-string "+text:afternoon +text:coffee" (which gets parsed into a conjection of disjunctions) had throughput of 308qps before this change, and after this change was 342qps. --- query_disjunction.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/query_disjunction.go b/query_disjunction.go index 78e4bd92..23b55cec 100644 --- a/query_disjunction.go +++ b/query_disjunction.go @@ -66,6 +66,10 @@ func (q *disjunctionQuery) SetMin(m float64) Query { } func (q *disjunctionQuery) Searcher(i index.IndexReader, m *IndexMapping, explain bool) (search.Searcher, error) { + if len(q.Disjuncts) == 1 { + return q.Disjuncts[0].Searcher(i, m, explain) + } + ss := make([]search.Searcher, len(q.Disjuncts)) for in, disjunct := range q.Disjuncts { var err error