[Xapian-tickets] [Xapian] #790: Operators |= and &= with Xapian::Query{}
Xapian
nobody at xapian.org
Sat Jun 29 17:53:37 BST 2019
#790: Operators |= and &= with Xapian::Query{}
-------------------------------+--------------------
Reporter: dpa-xapian | Owner: olly
Type: defect | Status: new
Priority: normal | Milestone: 1.4.x
Component: Other | Version: 1.4.11
Severity: normal | Keywords:
Blocked By: | Blocking:
Operating System: All |
-------------------------------+--------------------
I do expect, that Xapian::Query{} constructs an empty query, that is the
neutral element towards AND and OR operations. Thus in:
{{{
std::vector<std::string> v {"A", "B"};
Xapian::Query q1, q2, qOR {Xapian::Query::OP_OR, v.begin(), v.end()}, qAND
{Xapian::Query::OP_OR, v.begin(), v.end()}
}}}
q1 |= qOR → q1.get_type() will be OR and the q1 terms will be A and B
q2 &= qAND → q2.get_type() will be AND and the q2 terms will be A and B
Instead q1.get_type() == q2.get_type() == LEAF_MATCH_NOTHING and contain
no terms.
Reproducer:
{{{
#include <stdio.h>
#include <string>
#include <xapian.h>
void print_terms(const Xapian::Query& f, std::string s) {
printf("%s: ", s.c_str());
for (Xapian::TermIterator it = f.get_terms_begin(); it !=
f.get_terms_end(); ++it)
printf("%s ", (*it).c_str());
printf(" get_type=%i\n", f.get_type());
}
int main() {
std::vector<std::string> v {"abc", "def", "ghi"};
Xapian::Query t;
print_terms(t, "t");
Xapian::Query q { Xapian::Query::OP_OR, v.begin(), v.end()};
print_terms(q, "q");
t &= q;
print_terms(t, "t2");
return 0;
}
-- actual result
t: get_type=103
q: abc def ghi get_type=1
t2: get_type=103
-- expected result
t: get_type=103
q: abc def ghi get_type=1
t2: abc def ghi get_type=1
}}}
--
Ticket URL: <https://trac.xapian.org/ticket/790>
Xapian <https://xapian.org/>
Xapian
More information about the Xapian-tickets
mailing list