Because of the implicit way body: queries are implemented, additional code will be needed for them. --- lib/parse-sexp.cc | 12 +++++++-- test/T081-sexpr-search.sh | 54 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/lib/parse-sexp.cc b/lib/parse-sexp.cc index bfa566b1..a0f5e5bf 100644 --- a/lib/parse-sexp.cc +++ b/lib/parse-sexp.cc @@ -221,6 +221,7 @@ _sexp_to_xapian_query (notmuch_database_t *notmuch, sexp_t *sx, Xapian::Query &o if (strcasecmp (field->name, hd_sexp (sx)->val) == 0) { _sexp_flag_t flags; sexp_t *rest; + const char *term_prefix; notmuch_status_t status = _sexp_parse_keywords (notmuch, sx->list->val, sx->list->next, field->flags_allowed, @@ -228,8 +229,15 @@ _sexp_to_xapian_query (notmuch_database_t *notmuch, sexp_t *sx, Xapian::Query &o if (status) return status; - return _sexp_combine_field (_find_prefix (field->name), field->xapian_op, rest, - output); + term_prefix = _find_prefix (field->name); + + if (flags & SEXP_FLAG_WILDCARD) { + output = Xapian::Query (Xapian::Query::OP_WILDCARD, term_prefix); + return NOTMUCH_STATUS_SUCCESS; + } else { + return _sexp_combine_field (term_prefix, field->xapian_op, rest, + output); + } } } diff --git a/test/T081-sexpr-search.sh b/test/T081-sexpr-search.sh index 6e8687da..d8a89c6f 100755 --- a/test/T081-sexpr-search.sh +++ b/test/T081-sexpr-search.sh @@ -221,4 +221,58 @@ test_expect_success 'notmuch search --query-syntax=sexp "(subject \":foo\")"' test_begin_subtest "unknown keyword after non-keyword" test_expect_success 'notmuch search --query-syntax=sexp "(subject foo :foo)"' +test_begin_subtest "wildcard search for attachment" +notmuch search tag:attachment > EXPECTED +notmuch search --query-syntax=sexp '(attachment :*)' > OUTPUT +test_expect_equal_file EXPECTED OUTPUT + +add_message '[subject]="empty body"' '[body]="."' +notmuch tag +nobody id:${gen_msg_id} + +test_begin_subtest "wildcard search for body" +test_subtest_known_broken +notmuch search not tag:nobody > EXPECTED +notmuch search --query-syntax=sexp '(body :any)' > OUTPUT +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "negated wildcard search for body" +test_subtest_known_broken +notmuch search tag:nobody > EXPECTED +notmuch search --query-syntax=sexp '(not (body :any))' > OUTPUT +test_expect_equal_file EXPECTED OUTPUT + +add_message '[subject]="no tags"' +notag_mid=${gen_msg_id} +notmuch tag -unread -inbox id:${notag_mid} + +test_begin_subtest "wildcard search for 'is'" +notmuch search not id:${notag_mid} > EXPECTED +notmuch search --query-syntax=sexp '(is :any)' > OUTPUT +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "negated wildcard search for 'is'" +notmuch search id:${notag_mid} > EXPECTED +notmuch search --query-syntax=sexp '(not (is :any))' > OUTPUT +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "wildcard search for 'tag'" +notmuch search not id:${notag_mid} > EXPECTED +notmuch search --query-syntax=sexp '(tag :any)' > OUTPUT +test_expect_equal_file EXPECTED OUTPUT + +test_begin_subtest "negated wildcard search for 'tag'" +notmuch search id:${notag_mid} > EXPECTED +notmuch search --query-syntax=sexp '(not (tag :any))' > OUTPUT +test_expect_equal_file EXPECTED OUTPUT + +add_message '[subject]="message with properties"' +notmuch restore <<EOF +#= ${gen_msg_id} foo=bar +EOF + +test_begin_subtest "wildcard search for 'property'" +notmuch search property:foo=bar > EXPECTED +notmuch search --query-syntax=sexp '(property :any)' > OUTPUT +test_expect_equal_file EXPECTED OUTPUT + test_done -- 2.30.2 _______________________________________________ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-leave@notmuchmail.org