mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 20:38:08 +01:00
319dd95ebb
The new `body:` field (in Xapian terms) or prefix (in slightly sloppier notmuch) terms allows matching terms that occur only in the body. Unprefixed query terms should continue to match anywhere (header or body) in the message. This follows a suggestion of Olly Betts to use the facility (since Xapian 1.0.4) to add the same field with multiple prefixes. The double indexing of previous versions is thus replaced with a query time expension of unprefixed query terms to the various prefixed equivalent. Reindexing will be needed for 'body:' searches to work correctly; otherwise they will also match messages where the term occur in headers (demonstrated by the new tests in T530-upgrade.sh)
43 lines
1.5 KiB
Bash
Executable file
43 lines
1.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
test_description='search body'
|
|
. $(dirname "$0")/test-lib.sh || exit 1
|
|
|
|
add_message "[body]=thebody-1" "[subject]=subject-1"
|
|
add_message "[body]=nothing-to-see-here-1" "[subject]=thebody-1"
|
|
|
|
test_begin_subtest 'search with body: prefix'
|
|
notmuch search body:thebody | notmuch_search_sanitize > OUTPUT
|
|
cat <<EOF > EXPECTED
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; subject-1 (inbox unread)
|
|
EOF
|
|
test_expect_equal_file EXPECTED OUTPUT
|
|
|
|
test_begin_subtest 'search without body: prefix'
|
|
notmuch search thebody | notmuch_search_sanitize > OUTPUT
|
|
cat <<EOF > EXPECTED
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; subject-1 (inbox unread)
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; thebody-1 (inbox unread)
|
|
EOF
|
|
test_expect_equal_file EXPECTED OUTPUT
|
|
|
|
test_begin_subtest 'negated body: prefix'
|
|
notmuch search thebody and not body:thebody | notmuch_search_sanitize > OUTPUT
|
|
cat <<EOF > EXPECTED
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; thebody-1 (inbox unread)
|
|
EOF
|
|
test_expect_equal_file EXPECTED OUTPUT
|
|
|
|
test_begin_subtest 'search unprefixed for prefixed term'
|
|
notmuch search subject | notmuch_search_sanitize > OUTPUT
|
|
cat <<EOF > EXPECTED
|
|
thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; subject-1 (inbox unread)
|
|
EOF
|
|
test_expect_equal_file EXPECTED OUTPUT
|
|
|
|
test_begin_subtest 'search with body: prefix for term only in subject'
|
|
notmuch search body:subject | notmuch_search_sanitize > OUTPUT
|
|
cat <<EOF > EXPECTED
|
|
EOF
|
|
test_expect_equal_file EXPECTED OUTPUT
|
|
|
|
test_done
|