]> git.notmuchmail.org Git - notmuch/blobdiff - database.cc
notmuch dump: Fix the sorting of results.
[notmuch] / database.cc
index 041cffdc9afe49b01a2c54e86a87b88610d25b0d..31afe7cc147afdc3098e8599eb57337b7c7b785d 100644 (file)
@@ -67,15 +67,6 @@ prefix_t BOOLEAN_PREFIX[] = {
     { "ref", "R" }
 };
 
-/* Similarly, these value numbers are also chosen to be sup
- * compatible. */
-
-typedef enum {
-    NOTMUCH_VALUE_MESSAGE_ID = 0,
-    NOTMUCH_VALUE_THREAD = 1,
-    NOTMUCH_VALUE_DATE = 2
-} notmuch_value_t;
-
 static const char *
 find_prefix (const char *name)
 {
@@ -457,9 +448,11 @@ notmuch_database_open (const char *path)
     notmuch->path = xstrdup (path);
 
     try {
-       Xapian::PostingIterator i;
        notmuch->xapian_db = new Xapian::WritableDatabase (xapian_path,
                                                           Xapian::DB_CREATE_OR_OPEN);
+       notmuch->query_parser = new Xapian::QueryParser;
+       notmuch->query_parser->set_default_op (Xapian::Query::OP_AND);
+       notmuch->query_parser->set_database (*notmuch->xapian_db);
     } catch (const Xapian::Error &error) {
        fprintf (stderr, "A Xapian exception occurred: %s\n",
                 error.get_msg().c_str());
@@ -479,6 +472,7 @@ notmuch_database_open (const char *path)
 void
 notmuch_database_close (notmuch_database_t *notmuch)
 {
+    delete notmuch->query_parser;
     delete notmuch->xapian_db;
     free (notmuch->path);
     free (notmuch);
@@ -519,10 +513,10 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
                                           (char *) NULL);
 
     try {
-       doc = Xapian::Document ();
-
        doc.set_data (filename);
 
+       add_term (doc, "type", "mail");
+
        parents = g_ptr_array_new ();
 
        refs = notmuch_message_file_get_header (message, "references");