expected=$(cat $EXPECTED/probs)
test_expect_equal "$output" "$expected"
+add_message '[body]="Peter Piper picked a peck of pickled peppers"'
+
+test_begin_subtest "Wildcards"
+output=$(../qparser-test -d < $EXPECTED/wildcards)
+expected=$(cat $EXPECTED/wildcards)
+test_expect_equal "$output" "$expected"
+
test_done
#include "../notmuch-client.h"
}
+static notmuch_database_t *notmuch;
static _notmuch_qparser_t *qparser;
static Xapian::QueryParser xqparser;
static _notmuch_qparser_t *
create_qparser (void *ctx)
{
- _notmuch_qparser_t *qparser = _notmuch_qparser_create (ctx, NULL);
+ _notmuch_qparser_t *qparser = _notmuch_qparser_create (ctx, notmuch);
_notmuch_qparser_add_db_prefix (qparser, "prob", "P", FALSE);
_notmuch_qparser_add_db_prefix (qparser, "lit", "L", TRUE);
_notmuch_qparser_add_db_prefix (qparser, "tag", "K", TRUE);
create_xapian_qparser (void)
{
Xapian::QueryParser xq;
+ if (notmuch)
+ xq.set_database (*notmuch->xapian_db);
xq.set_default_op (Xapian::Query::OP_AND);
xq.add_prefix ("prob", "P");
xq.add_boolean_prefix ("lit", "L");
main (int argc, char **argv)
{
void *ctx;
+ notmuch_config_t *config;
ctx = talloc_new (NULL);
+ if (argc > 1 && strcmp(argv[1], "-d") == 0) {
+ argc--;
+ argv++;
+
+ /* Open the database */
+ config = notmuch_config_open (ctx, NULL, NULL);
+ if (config == NULL)
+ return 1;
+
+ notmuch = notmuch_database_open (notmuch_config_get_database_path (config),
+ NOTMUCH_DATABASE_MODE_READ_ONLY);
+ if (notmuch == NULL)
+ return 1;
+ } else {
+ notmuch = NULL;
+ }
+
qparser = create_qparser (ctx);
xqparser = create_xapian_qparser ();
}
}
+ if (notmuch)
+ notmuch_database_close (notmuch);
return 0;
}
--- /dev/null
+# Basic wildcard expansion
+p* AND x
+[lex] "p"* AND "x"
+[parse] (AND "p"* "x")
+[gen] ((peck:(pos=1) SYNONYM peppers:(pos=1) SYNONYM peter:(pos=1) SYNONYM picked:(pos=1) SYNONYM pickled:(pos=1) SYNONYM piper:(pos=1)) AND x:(pos=2))
+
+# Incompatible; Xapian considers this a syntax error
+*
+[lex] ""*
+[parse] ""*
+[gen] <alldocuments>
+[xapian]
+
+# Wildcard that matches nothing. Xapian handles this differently
+# but equivalently.
+nosuchterm* AND x
+[lex] "nosuchterm"* AND "x"
+[parse] (AND "nosuchterm"* "x")
+[gen] (nosuchterm AND x:(pos=1))
+[xapian]