* mu-query: special-case the empty search expr to mean 'match-all'

This commit is contained in:
Dirk-Jan C. Binnema 2011-07-13 08:18:42 +03:00
parent 9e73fa863e
commit 329a524af7
3 changed files with 9 additions and 3 deletions

View File

@ -350,7 +350,6 @@ mu_query_run (MuQuery *self, const char* searchexpr, gboolean threads,
sortfieldid == MU_MSG_FIELD_ID_NONE,
NULL);
try {
Xapian::Query query (get_query (self, searchexpr, err));
Xapian::Enquire enq (self->_db);
/* note, when our result will be *threaded*, we sort
@ -358,7 +357,13 @@ mu_query_run (MuQuery *self, const char* searchexpr, gboolean threads,
if (!threads && sortfieldid != MU_MSG_FIELD_ID_NONE)
enq.set_sort_by_value ((Xapian::valueno)sortfieldid,
ascending ? true : false);
enq.set_query(query);
if (!mu_str_is_empty(searchexpr)) /* NULL or "" */
enq.set_query(get_query (self, searchexpr, err));
else
enq.set_query(Xapian::Query::MatchAll);
enq.set_cutoff(0,0);
return mu_msg_iter_new (

View File

@ -68,7 +68,7 @@ char* mu_query_version (MuQuery *store)
* manpage, or http://xapian.org/docs/queryparser.html
*
* @param self a valid MuQuery instance
* @param expr the search expression
* @param expr the search expression or "" to match all messages
* @param threads calculate message-threads
* @param sortfield the field id to sort by or MU_MSG_FIELD_ID_NONE if
* sorting is not desired

View File

@ -150,6 +150,7 @@ test_mu_query_01 (void)
{ "foo:pepernoot", 0 },
{ "funky", 1 },
{ "fünkÿ", 1 },
{ "", 13 }
};