[Xapian-tickets] [Xapian] #790: Operators |= and &= with Xapian::Query{}

Xapian nobody at xapian.org
Sun Jun 30 23:03:06 BST 2019


#790: Operators |= and &= with Xapian::Query{}
-------------------------+-----------------------------
 Reporter:  dpa-xapian   |             Owner:  olly
     Type:  defect       |            Status:  assigned
 Priority:  normal       |         Milestone:  1.4.12
Component:  Library API  |           Version:  1.4.11
 Severity:  normal       |        Resolution:
 Keywords:               |        Blocked By:
 Blocking:               |  Operating System:  All
-------------------------+-----------------------------

Comment (by olly):

 `Xapian::Query{Xapian::Query::OP_OR, v.begin(), v.end()}` is a query for
 any documents which match any of the terms in `v`.  If `v.empty()` then no
 documents match any of the terms in `v`, so this constructs a
 `MatchNothing` query.

 If you want to filter a query by OR of terms in `v` but handle empty `v`
 as meaning "don't apply a filter" you want something like:

 {{{
 if (!v.empty()) {
     q = Xapian::Query{Xapian::Query::OP_FILTER, q,
 Xapian::Query{Xapian::Query::OP_OR, v.begin(), v.end()}};
 }
 }}}

--
Ticket URL: <https://trac.xapian.org/ticket/790#comment:3>
Xapian <https://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list