* for email address foo@bar.com, also save "foo" and "bar.com" so you can
search for them
This commit is contained in:
@ -593,6 +593,31 @@ xapian_pfx (MuMsgContact *contact)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_address_subfields (Xapian::Document& doc, const char *addr,
|
||||||
|
const std::string& pfx, GStringChunk *strchunk)
|
||||||
|
{
|
||||||
|
const char *at;
|
||||||
|
char *p1, *p2;
|
||||||
|
|
||||||
|
/* add "foo" and "bar.com" as terms as well for
|
||||||
|
* "foo@bar.com" */
|
||||||
|
if (G_UNLIKELY(!(at = (g_strstr_len (addr, -1, "@")))))
|
||||||
|
return;
|
||||||
|
|
||||||
|
p1 = g_strndup(addr, at - addr); // foo
|
||||||
|
p2 = g_strdup (at + 1);
|
||||||
|
|
||||||
|
p1 = mu_str_xapian_escape_in_place_try (p1, TRUE, strchunk);
|
||||||
|
p2 = mu_str_xapian_escape_in_place_try (p2, TRUE, strchunk);
|
||||||
|
|
||||||
|
doc.add_term (pfx + p1);
|
||||||
|
doc.add_term (pfx + p2);
|
||||||
|
|
||||||
|
g_free (p1);
|
||||||
|
g_free (p2);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
each_contact_info (MuMsgContact *contact, MsgDoc *msgdoc)
|
each_contact_info (MuMsgContact *contact, MsgDoc *msgdoc)
|
||||||
{
|
{
|
||||||
@ -615,15 +640,14 @@ each_contact_info (MuMsgContact *contact, MsgDoc *msgdoc)
|
|||||||
|
|
||||||
/* don't normalize e-mail address, but do lowercase it */
|
/* don't normalize e-mail address, but do lowercase it */
|
||||||
if (!mu_str_is_empty(contact->address)) {
|
if (!mu_str_is_empty(contact->address)) {
|
||||||
|
|
||||||
char *escaped;
|
char *escaped;
|
||||||
/* note: escaped is added to stringchunk, no need for
|
/* note: escaped is added to stringchunk, no need for
|
||||||
* freeing */
|
* freeing */
|
||||||
escaped = mu_str_xapian_escape (contact->address,
|
escaped = mu_str_xapian_escape (contact->address, FALSE,
|
||||||
FALSE /*dont esc space*/,
|
|
||||||
msgdoc->_strchunk);
|
msgdoc->_strchunk);
|
||||||
msgdoc->_doc->add_term
|
msgdoc->_doc->add_term (pfx + escaped);
|
||||||
(std::string (pfx + escaped, 0, MuStore::MAX_TERM_LENGTH));
|
add_address_subfields (*msgdoc->_doc, contact->address, pfx,
|
||||||
|
msgdoc->_strchunk);
|
||||||
|
|
||||||
/* store it also in our contacts cache */
|
/* store it also in our contacts cache */
|
||||||
if (msgdoc->_store->contacts())
|
if (msgdoc->_store->contacts())
|
||||||
|
|||||||
Reference in New Issue
Block a user