mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 02:48:08 +01:00
Add indexing for the mimetype term
This adds the indexing support for the "mimetype:" term and removes the broken test flag. The indexing is probablistic in Xapian terms, which gives a better experience to end users. Standard content-types of the form "foo/bar" are automatically interpreted as phrases in Xapian due to the embedded slash. Assume, separate messages with application/pdf and application/x-pdf are indexed, then: - mimetype:application/x-pdf will find only the application/x-pdf - mimetype:application/pdf will find only the application/pdf - mimetype:pdf will find both of the messages
This commit is contained in:
parent
0de999aab5
commit
b04bc967f9
3 changed files with 11 additions and 3 deletions
|
@ -254,6 +254,7 @@ static prefix_t PROBABILISTIC_PREFIX[]= {
|
||||||
{ "from", "XFROM" },
|
{ "from", "XFROM" },
|
||||||
{ "to", "XTO" },
|
{ "to", "XTO" },
|
||||||
{ "attachment", "XATTACHMENT" },
|
{ "attachment", "XATTACHMENT" },
|
||||||
|
{ "mimetype", "XMIMETYPE"},
|
||||||
{ "subject", "XSUBJECT"},
|
{ "subject", "XSUBJECT"},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
10
lib/index.cc
10
lib/index.cc
|
@ -318,6 +318,16 @@ _index_mime_part (notmuch_message_t *message,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GMimeContentType *content_type = g_mime_object_get_content_type(part);
|
||||||
|
if (content_type) {
|
||||||
|
char *mime_string = g_mime_content_type_to_string(content_type);
|
||||||
|
if (mime_string)
|
||||||
|
{
|
||||||
|
_notmuch_message_gen_terms (message, "mimetype", mime_string);
|
||||||
|
g_free(mime_string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (GMIME_IS_MULTIPART (part)) {
|
if (GMIME_IS_MULTIPART (part)) {
|
||||||
GMimeMultipart *multipart = GMIME_MULTIPART (part);
|
GMimeMultipart *multipart = GMIME_MULTIPART (part);
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -752,17 +752,14 @@ notmuch show --format=json --include-html id:htmlmessage > OUTPUT
|
||||||
test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.withhtml)"
|
test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.withhtml)"
|
||||||
|
|
||||||
test_begin_subtest "indexes mime-type #1"
|
test_begin_subtest "indexes mime-type #1"
|
||||||
test_subtest_known_broken
|
|
||||||
output=$(notmuch search mimetype:application/unique_identifier | notmuch_search_sanitize)
|
output=$(notmuch search mimetype:application/unique_identifier | notmuch_search_sanitize)
|
||||||
test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)"
|
test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)"
|
||||||
|
|
||||||
test_begin_subtest "indexes mime-type #2"
|
test_begin_subtest "indexes mime-type #2"
|
||||||
test_subtest_known_broken
|
|
||||||
output=$(notmuch search mimetype:text/some_other_identifier | notmuch_search_sanitize)
|
output=$(notmuch search mimetype:text/some_other_identifier | notmuch_search_sanitize)
|
||||||
test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)"
|
test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)"
|
||||||
|
|
||||||
test_begin_subtest "indexes mime-type #3"
|
test_begin_subtest "indexes mime-type #3"
|
||||||
test_subtest_known_broken
|
|
||||||
output=$(notmuch search from:todd and mimetype:multipart/alternative | notmuch_search_sanitize)
|
output=$(notmuch search from:todd and mimetype:multipart/alternative | notmuch_search_sanitize)
|
||||||
test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)"
|
test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue