Better Understanding of Programmatic Query Construction

Dustin Oprea myselfasunder at gmail.com
Mon Dec 27 04:41:08 GMT 2021


It doesn't seem as if there is much documentation for query building. I've
been mostly biased towards Python documentation in my searches. There
doesn't appear to be a way to search the email archives.

What documentation there is mentions this example:

(
https://github.com/xapian/xapian-docsprint/commit/f04c97f4d1722c2796ba5d807f441d5d2d4eec4d#diff-6ae69d2eefbbb95e7140a8e82ce0751fa6872172d52a05a2c7586e938bf8e4d1R288
)

subq = xapian.Query(xapian.Query.OP_AND, "hello", "world")
q = xapian.Query(xapian.Query.OP_AND, [subq, "foo", xapian.Query("bar", 2)])


Based on this limited amount of information, I tried converting my original
string query from something like:

'TERM1' AND title:"TERM2"


to (each more unbounded/desperate then the previous):

1: q = xapian.Query(xapian.Query.OP_AND, "'TERM1'", "TERM2") (based on the
first statement)
2: q = xapian.Query(xapian.Query.OP_AND, ["'TERM1'", "TERM2"])
3: q = xapian.Query(xapian.Query.OP_AND, ["TERM1", "TERM2"])
4: q = xapian.Query(xapian.Query.OP_AND, ["TERM1"])
5: q = xapian.Query(xapian.Query.OP_OR, ["TERM1"])

Whereas the string query yielded results, I got zero results in each of
these. What am I doing wrong? I'd appreciate someone explaining how to do
literal (read: unstemmed, proper noun) searches. I'm not sure if wrapping
in an inner set of quotes makes sense in this situation.

Also, I'm assuming that the example translates to "hello AND world AND foo
AND ??", but how does that *xapian.Query("bar", 2)* term translate?

Thank you.



Dustin


More information about the Xapian-discuss mailing list